Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(securitycenter): Add Resource SCC Management API Org ETD Custom … #3943

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lovenishs04
Copy link

…modules

Description

Fixes # b/347347710, b/347347103, b/347347367, b/347347656, b/347347732
This PR adds SCC Managament API Org Event Threat Detection Custom Module Code Samples for Create, Delete, List ,Get & Update.

Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.

Checklist

  • I have followed guidelines from CONTRIBUTING.MD and Samples Style Guide
  • Tests pass: npm test (see Testing)
  • Lint pass: npm run lint (see Style)
  • These samples need a new API enabled in testing projects to pass (let us know which ones)
  • These samples need a new/updated env vars in testing projects set to pass (let us know which ones)
  • This pull request is from a branch created directly off of GoogleCloudPlatform/nodejs-docs-samples. Not a fork.
  • This sample adds a new sample directory, and I updated the CODEOWNERS file with the codeowners for this sample
  • This sample adds a new sample directory, and I created GitHub Actions workflow for this sample
  • This sample adds a new Product API, and I updated the Blunderbuss issue/PR auto-assigner with the codeowners for this sample
  • Please merge this PR for me once it is approved

@lovenishs04 lovenishs04 requested review from a team as code owners January 9, 2025 05:41
Copy link

snippet-bot bot commented Jan 9, 2025

Here is the summary of changes.

You are about to add 5 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

Copy link
Contributor

@code-review-assist code-review-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @lovenishs04 and reviewers,

I'm currently reviewing this pull request and will provide my feedback in a few minutes. In the meantime, I'm providing this summary of the pull request's content to help you and other reviewers quickly understand the changes and intent.

This pull request, titled "feat(securitycenter): Add Resource SCC Management API Org ETD Custom …", aims to add code samples for the Security Command Center (SCC) Management API's Organization Event Threat Detection Custom Module. The description mentions that it addresses several internal Google issues (b/347347710, b/347347103, b/347347367, b/347347656, b/347347732).

Here's a summary of the changes:

  • New files added:
    • security-center/snippets/management_api/createEventThreatDetectionCustomModule.js: This file contains code to create a new event threat detection custom module. (Lines 1-94)
    • security-center/snippets/management_api/deleteEventThreatDetectionCustomModule.js: This file provides code for deleting an existing event threat detection custom module. (Lines 1-63)
    • security-center/snippets/management_api/getEventThreatDetectionCustomModule.js: This file shows how to retrieve an existing event threat detection custom module. (Lines 1-60)
    • security-center/snippets/management_api/listEventThreatDetectionCustomModules.js: This file demonstrates listing all event threat detection custom modules under a given parent resource. (Lines 1-58)
    • security-center/snippets/management_api/updateEventThreatDetectionCustomModule.js: This file contains code to update an existing event threat detection custom module. (Lines 1-73)
    • security-center/snippets/system-test/management_api/eventThreatDetectionCustomModule.test.js: This file includes system tests for the new custom module functionalities. (Lines 1-181)
  • security-center/snippets/package.json updated: The @google-cloud/securitycentermanagement dependency was added. (Line 18)

The pull request includes comprehensive unit tests. The author has also diligently checked off all items in the provided checklist.


And now, a little haiku to lighten the mood:

Code flows like a stream,
Tests run, a green light appears,
Bugs flee in the night.

@product-auto-label product-auto-label bot added api: securitycenter Issues related to the Security Command Center API. samples Issues that are directly related to samples. labels Jan 9, 2025
Copy link
Contributor

@code-review-assist code-review-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @lovenishs04 and reviewers,

I'm currently reviewing this pull request and will provide feedback shortly. In the meantime, here's a summary to help everyone get up to speed:

This pull request, feat(securitycenter): Add Resource SCC Management API Org ETD Custom …, aims to add code samples for the Security Command Center (SCC) Management API's Organization Event Threat Detection Custom Module. Specifically, it includes samples for creating, deleting, listing, getting, and updating custom modules.

Here's a breakdown of the changes:

  • New files added:
    • security-center/snippets/management_api/createEventThreatDetectionCustomModule.js (lines 1-94): Implements the creation of a new event threat detection custom module.
    • security-center/snippets/management_api/deleteEventThreatDetectionCustomModule.js (lines 1-63): Implements the deletion of an existing event threat detection custom module.
    • security-center/snippets/management_api/getEventThreatDetectionCustomModule.js (lines 1-60): Implements retrieving an existing event threat detection custom module.
    • security-center/snippets/management_api/listEventThreatDetectionCustomModules.js (lines 1-58): Implements listing all event threat detection custom modules under a given parent resource.
    • security-center/snippets/management_api/updateEventThreatDetectionCustomModule.js (lines 1-73): Implements updating an existing event threat detection custom module.
    • security-center/snippets/system-test/management_api/eventThreatDetectionCustomModule.test.js (lines 1-181): Adds comprehensive tests for the new functionality.
  • security-center/snippets/package.json (line 14-18): Updated dependencies to include @google-cloud/securitycentermanagement.

The PR addresses issues b/347347710, b/347347103, b/347347367, b/347347656, and b/347347732.

The author has indicated that all tests and lint checks have passed. They have also stated that they have followed all contributing guidelines.

I'll be looking at the code quality, test coverage, and overall functionality in more detail shortly.


And now, a little haiku to brighten your day:

Code flows like a stream,
Tests run green, a joyful sight,
Bugs flee in the night.

Copy link
Contributor

Gemini encountered an error creating the review. You can try again by commenting @code-review-assist review.

Copy link
Contributor

@code-review-assist code-review-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @lovenishs04 and reviewers,

I'm currently reviewing this pull request and will provide my feedback in a few minutes. In the meantime, I'm giving you a summary of the pull request's content to help you and other reviewers quickly understand the changes and their purpose.

This pull request, titled "feat(securitycenter): Add Resource SCC Management API Org ETD Custom …", aims to add code samples for the Security Command Center (SCC) Management API's Organization Event Threat Detection Custom Module. The description mentions it addresses several internal Google issues (b/347347710, b/347347103, b/347347367, b/347347656, b/347347732).

Here's a summary of the changes:

  • New files added:
    • security-center/snippets/management_api/createEventThreatDetectionCustomModule.js - Adds functionality to create a new event threat detection custom module. (Lines 1-94)
    • security-center/snippets/management_api/deleteEventThreatDetectionCustomModule.js - Adds functionality to delete an existing event threat detection custom module. (Lines 1-63)
    • security-center/snippets/management_api/getEventThreatDetectionCustomModule.js - Adds functionality to retrieve an existing event threat detection custom module. (Lines 1-60)
    • security-center/snippets/management_api/listEventThreatDetectionCustomModules.js - Adds functionality to list all event threat detection custom modules under a given parent resource. (Lines 1-58)
    • security-center/snippets/management_api/updateEventThreatDetectionCustomModule.js - Adds functionality to update an existing event threat detection custom module. (Lines 1-73)
    • security-center/snippets/system-test/management_api/eventThreatDetectionCustomModule.test.js - Adds comprehensive test cases for the above functionalities. (Lines 1-181)
  • security-center/snippets/package.json updated: Added @google-cloud/securitycentermanagement as a dependency. (Line 18)

The code samples cover the Create, Delete, List, Get, and Update operations for the SCC Management API's Organization Event Threat Detection Custom Module. The test file includes unit tests to verify the functionality of each sample.

I'll be looking at the code closely to ensure it meets our quality standards. I'll also check for proper error handling, documentation, and adherence to style guidelines.


And now, a little haiku to lighten the mood:

Code flows like a stream,
Tests run, a green light appears,
Bugs flee in the night.

Copy link
Contributor

Gemini encountered an error creating the review. You can try again by commenting @code-review-assist review.

Copy link
Contributor

@code-review-assist code-review-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @lovenishs04 and reviewers,

I'm currently reviewing this pull request and will provide feedback in a few minutes. In the meantime, I'm providing this summary to help you and other reviewers quickly understand the changes and intent.

This pull request, feat(securitycenter): Add Resource SCC Management API Org ETD Custom …, aims to add code samples for the Security Command Center (SCC) Management API's Organization Event Threat Detection Custom Module. Specifically, it includes samples for creating, deleting, listing, getting, and updating custom modules.

Here's a breakdown of the changes:

  • New files added:
    • security-center/snippets/management_api/createEventThreatDetectionCustomModule.js (lines 1-94): Implements the creation of a new event threat detection custom module.
    • security-center/snippets/management_api/deleteEventThreatDetectionCustomModule.js (lines 1-63): Implements the deletion of an existing event threat detection custom module.
    • security-center/snippets/management_api/getEventThreatDetectionCustomModule.js (lines 1-60): Implements retrieving an existing event threat detection custom module.
    • security-center/snippets/management_api/listEventThreatDetectionCustomModules.js (lines 1-58): Implements listing all event threat detection custom modules under a given parent resource.
    • security-center/snippets/management_api/updateEventThreatDetectionCustomModule.js (lines 1-73): Implements updating an existing event threat detection custom module.
    • security-center/snippets/system-test/management_api/eventThreatDetectionCustomModule.test.js (lines 1-181): Adds comprehensive test cases for the new functionality.
  • security-center/snippets/package.json (lines 14-18): Updated dependencies to include @google-cloud/securitycentermanagement.

The pull request addresses issues b/347347710, b/347347103, b/347347367, b/347347656, and b/347347732. The author has also completed the provided checklist.

I'll be looking at code style, test coverage, and overall functionality in my full review.


And now, a little haiku to lighten the mood:

Code flows like a stream,
Tests run, green lights fill the screen,
A bug's silent scream.

Copy link
Contributor

@code-review-assist code-review-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request adds Security Command Center Management API organization-level event threat detection custom modules code samples. The samples cover Create, Delete, List, Get, and Update operations. Overall, the code is well-structured and easy to understand. However, there are a few minor improvements that can be made.

Comment on lines +36 to +38
//TODO(developer): Update the following references for your own environment before running the sample.
// const organizationId = 'YOUR_ORGANIZATION_ID';
// const location = 'LOCATION_ID';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

Instead of using TODO(developer), consider using JSDoc style comments to explain the parameters and provide examples.

Suggested change
//TODO(developer): Update the following references for your own environment before running the sample.
// const organizationId = 'YOUR_ORGANIZATION_ID';
// const location = 'LOCATION_ID';
/**
* @param {string} organizationId Your organization's ID.
* @param {string} customModuleDisplayName The human readable name to be displayed for the module.
* @param {string} [location=global] The location for the module.
*/

Comment on lines +41 to +42
// define the event threat detection custom module configuration, update the EnablementState
// below
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

The comment about updating EnablementState is not clear. Rephrase it to be more descriptive and explain the purpose of EnablementState.

Suggested change
// define the event threat detection custom module configuration, update the EnablementState
// below
// The enablement state can be ENABLED or DISABLED.
// Set to ENABLED to activate the custom module.

const {describe, it, before, after} = require('mocha');
const uuid = require('uuid').v4;

// TODO(developer): update for your own environment
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

Update the TODO with instructions on how to set the organization ID environment variable.

Suggested change
// TODO(developer): update for your own environment
// Replace with your organization ID. Set the GCLOUD_ORGANIZATION environment variable.

// Creates a new client.
const client = new SecurityCenterManagementClient();

// cleanupExistingCustomModules clean up all the existing custom module
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

Add a comment explaining why the cleanupExistingCustomModules function is necessary.

Suggested change
// cleanupExistingCustomModules clean up all the existing custom module
// Clean up existing test custom modules to prevent conflicts and ensure a clean test environment.

Comment on lines +69 to +86
// define the metadata and other config parameters severity, description,
// recommendation and ips below
const config = {
fields: {
metadata: {
structValue: {
fields: {
severity: {stringValue: 'MEDIUM'},
description: {stringValue: 'add your description here'},
recommendation: {stringValue: 'add your recommendation'},
},
},
},
ips: {
listValue: {
values: [{stringValue: '0.0.0.0'}],
},
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

Instead of hardcoding the severity, description, and recommendation, consider using variables or environment variables to make the test more flexible and avoid hardcoding values within the tests.

const severity = process.env.SEVERITY || 'MEDIUM';
const description = process.env.DESCRIPTION || 'add your description here';
const recommendation = process.env.RECOMMENDATION || 'add your recommendation';
const ips = process.env.IPS || ['0.0.0.0'];

// define the metadata and other config parameters severity, description,
// recommendation and ips
const config = {
  fields: {
    metadata: {
      structValue: {
        fields: {
          severity: {stringValue: severity},
          description: {stringValue: description},
          recommendation: {stringValue: recommendation},
        },
      },
    },
    ips: {
      listValue: {
        values: ips.map(ip => ({stringValue: ip})),
      },
    },
  },
};

Copy link
Contributor

@code-review-assist code-review-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @lovenishs04 and reviewers,

I'm currently reviewing this pull request and will provide a full review shortly. In the meantime, here's a summary to help everyone quickly understand the changes:

This pull request, feat(securitycenter): Add Resource SCC Management API Org ETD Custom …, aims to add code samples for the Security Command Center (SCC) Management API's Organization Event Threat Detection Custom Module. Specifically, it includes samples for creating, deleting, listing, getting, and updating these custom modules.

Here's a breakdown of the changes:

  • New files added:
    • security-center/snippets/management_api/createEventThreatDetectionCustomModule.js (lines 1-94): Implements the creation of a new event threat detection custom module.
    • security-center/snippets/management_api/deleteEventThreatDetectionCustomModule.js (lines 1-63): Implements the deletion of an existing event threat detection custom module.
    • security-center/snippets/management_api/getEventThreatDetectionCustomModule.js (lines 1-60): Implements retrieving an existing event threat detection custom module.
    • security-center/snippets/management_api/listEventThreatDetectionCustomModules.js (lines 1-58): Implements listing all event threat detection custom modules under a given parent resource.
    • security-center/snippets/management_api/updateEventThreatDetectionCustomModule.js (lines 1-73): Implements updating an existing event threat detection custom module.
    • security-center/snippets/system-test/management_api/eventThreatDetectionCustomModule.test.js (lines 1-181): Adds comprehensive system tests for all the above functionalities.
  • security-center/snippets/package.json (line 14-18): Updates the dependencies to include @google-cloud/securitycentermanagement.

The PR addresses issues b/347347710, b/347347103, b/347347367, b/347347656, and b/347347732.

The author has also included a checklist to ensure all necessary steps have been followed (testing, linting, etc.).

I'll provide a more detailed review shortly.


A little coding haiku for your enjoyment:

Code flows like a stream,
Tests run green, a joyful sight,
Bugs flee in the night.

Copy link
Contributor

Gemini encountered an error creating the review. You can try again by commenting @code-review-assist review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: securitycenter Issues related to the Security Command Center API. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant