-
Notifications
You must be signed in to change notification settings - Fork 2k
feat(securitycenter): Add Resource SCC Management API Org SHA Custom … #3945
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 SHA Custom … #3945
Conversation
|
Here is the summary of changes. You are about to add 4 region tags.
This comment is generated by snippet-bot.
|
ghost
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi team,
I'm currently reviewing this pull request and will provide feedback shortly. In the meantime, here's a summary for you and other reviewers to quickly get up to speed:
This pull request adds code samples for the Security Command Center Management API's Org Security Health Analytics Custom Module. The intent is to provide examples for creating, updating, getting, and getting the effective state of custom modules. The PR addresses issues b/347347427, b/347347480, b/347347258, and b/347347835.
Here's a breakdown of the changes:
- New files added:
security-center/snippets/management_api/createSecurityHealthAnalyticsCustomModule.js: This file contains a sample for creating a custom module. (Lines 1-99)security-center/snippets/management_api/getEffectiveSecurityHealthAnalyticsCustomModule.js: This file shows how to retrieve an existing effective custom module. (Lines 1-52)security-center/snippets/management_api/getSecurityHealthAnalyticsCustomModule.js: This file demonstrates retrieving an existing custom module. (Lines 1-51)security-center/snippets/management_api/updateSecurityHealthAnalyticsCustomModule.js: This file provides a sample for updating a custom module. (Lines 1-69)security-center/snippets/system-test/managemnt_api/securityHealthAnalyticsCustomModule.test.js: This file contains system tests for the new samples. (Lines 1-175)
security-center/snippets/package.jsonupdated: Added@google-cloud/securitycentermanagementas a dependency and updated versions of other dependencies. (Lines 13-27)
The code samples utilize the @google-cloud/securitycentermanagement library. The tests use Mocha and Chai for assertions and include setup and teardown to create and delete the custom module for testing purposes.
I'll be checking the following during my review:
- Adherence to the
CONTRIBUTING.MDand Samples Style Guide. - Test coverage and correctness.
- Code style and readability.
- Error handling and robustness.
Let me know if you have any questions.
And now, a little haiku to lighten the mood:
Code flows like a stream,
Tests run, a green light appears,
A bug's silent scream.
ghost
left a comment
There was a problem hiding this 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 Health Analytics custom module code samples. The code generally looks good, but there are some minor improvements that can be made. The system tests could be improved by parameterizing the organization ID and cleaning up after themselves. The checklist is incomplete, so please review and update it accordingly.
| // define the CEL expression here and this will scans for keys that have not been rotated in | ||
| // the last 30 days, change it according to the your requirements |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment mentions 30 days, but the expression uses '2592000s', which is also 30 days. It would be clearer to use duration('30d') for consistency and readability.
| // define the CEL expression here and this will scans for keys that have not been rotated in | |
| // the last 30 days, change it according to the your requirements | |
| // define the CEL expression here and this will scans for keys that have not been rotated in | |
| // the last 30 days, change it according to the your requirements | |
| const expr = { | |
| expression: `has(resource.rotationPeriod) && (resource.rotationPeriod > duration('30d'))`, | |
| }; | |
| description: 'add your description here', | ||
| recommendation: 'add your recommendation here', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of placeholder comments, provide a more descriptive example or remove them entirely. This will make the sample more practical.
| description: 'add your description here', | |
| recommendation: 'add your recommendation here', | |
| description: 'CryptoKey has not been rotated in the last 30 days.', | |
| recommendation: 'Rotate the CryptoKey within 30 days of creation or last rotation.' |
| // TODO(developers): update for your own environment | ||
| const organizationId = '1081635000895'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace the placeholder organization ID with a valid one or a way to dynamically get the organization ID for testing. Don't hardcode global since it's already a default parameter.
| // TODO(developers): update for your own environment | |
| const organizationId = '1081635000895'; | |
| // TODO(developer): Replace with your organization ID | |
| const organizationId = process.env.SCC_ORGANIZATION_ID || 'YOUR_ORGANIZATION_ID'; | |
| const locationId = 'global'; |
| console.log( | ||
| `Custome Module ${customModuleDisplayName} deleted successfully.` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const output = exec( | ||
| `node management_api/updateSecurityHealthAnalyticsCustomModule.js ${data.orgId} ${data.customModuleId} ${locationId}` | ||
| ); | ||
| // assert.include(output, data.customModuleName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
closing this PR, has raised the same PR from the main branch #3952 |
…Module code samples
Description
Fixes # b/347347427, b/347347480, b/347347258, b/347347835
This PR adds SCC Managament API Org Security Health Analytics Custom Module Code Samples for Create, Update, Get and GetEffective.
Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.
Checklist
npm test(see Testing)npm run lint(see Style)GoogleCloudPlatform/nodejs-docs-samples. Not a fork.