-
Notifications
You must be signed in to change notification settings - Fork 6.5k
feat(securitycenter): Add Resource SCC Mgmt API Org SHA Custom Modules (Create, Get, List, Delete, Update) #13004
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
Conversation
…Create, Get, Delete, List, Update)
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 @vijaykanthm and reviewers,
Gemini is currently reviewing this pull request and will post a full review in a few minutes. In the meantime, here's a quick summary to help everyone get up to speed:
This pull request adds Python sample code for interacting with the Security Health Analytics Custom Modules API. Specifically, it provides examples for creating, getting, listing, deleting, and updating custom modules within an organization. The intent is to improve the documentation and provide developers with readily available code snippets for common tasks related to Security Health Analytics Custom Modules. The changes include the addition of several new Python files (securitycenter/snippets_management_api/noxfile_config.py
, securitycenter/snippets_management_api/requirements-test.txt
, securitycenter/snippets_management_api/requirements.txt
, securitycenter/snippets_management_api/security_health_analytics_custom_module_test.py
, securitycenter/snippets_management_api/security_health_analytics_custom_modules.py
) containing the sample code and associated test files, along with updates to the requirements.txt
and requirements-test.txt
files to include necessary dependencies.
The code is well-structured and includes comprehensive unit tests to ensure functionality. The noxfile_config.py
file configures the testing environment, and the security_health_analytics_custom_modules.py
file contains the core functions for interacting with the API. The tests in security_health_analytics_custom_module_test.py
cover all the CRUD operations (Create, Read, Update, Delete).
Here's a little something to brighten your day:
Code flows like a stream,
Tests catch bugs, a helpful gleam,
Clean code, a joyful dream.
Thanks,
Gemini
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 introduces new functionality to manage Security Health Analytics custom modules. Overall, the code is well-organized and the tests are comprehensive. A few minor improvements are suggested below.
|
||
TEST_CONFIG_OVERRIDE = { | ||
# You can opt out from the test for specific Python versions. | ||
"ignored_versions": ["2.7", "3.7", "3.9", "3.10", "3.11"], |
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.
import time | ||
import random | ||
|
||
#Replace these variables before running the sample. |
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.
Consider adding a comment explaining the purpose of each environment variable. This will improve readability and make it easier for others to understand how to configure the tests.
#Replace these variables before running the sample. | |
#Replace these variables before running the sample. | |
# GCLOUD_ORGANIZATION: The organization ID. | |
ORGANIZATION_ID = os.environ["GCLOUD_ORGANIZATION"] | |
LOCATION = "global" | |
PREFIX = "python_sample_sha_custom_module" # Prefix used for identifying test modules |
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.
Addressed
"custom_config": { | ||
"description": "Sample custom module for testing purpose. Please do not delete.", | ||
"predicate": { | ||
"expression": "has(resource.rotationPeriod) && (resource.rotationPeriod > duration('2592000s'))", |
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.
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.
Addressed
"title": "GCE Instance High Severity", | ||
"description": "Custom module to detect high severity issues on GCE instances.", | ||
}, | ||
"recommendation": "Ensure proper security configurations on GCE instances.", |
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 title and description in the predicate refer to "GCE Instance High Severity", but the resource selector targets cloudkms.googleapis.com/CryptoKey
. This is a mismatch. Change the title and description to accurately reflect that the predicate applies to Cloud KMS CryptoKeys, not GCE instances.
"title": "GCE Instance High Severity", | |
"description": "Custom module to detect high severity issues on GCE instances.", | |
}, | |
"recommendation": "Ensure proper security configurations on GCE instances.", | |
"title": "Cloud KMS CryptoKey Rotation Period", | |
"description": "Custom module to check if the rotation period of a Cloud KMS CryptoKey exceeds 30 days.", | |
}, | |
"recommendation": "Review and adjust the rotation period for Cloud KMS CryptoKeys to align with your security policies.", |
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.
Addressed
"description": "The name of the instance", | ||
"expression": "resource.name", | ||
"location": "global", | ||
"title": "Instance Name", |
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.
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.
Addressed
Here is the summary of changes. You are about to add 5 region tags.
This comment is generated by snippet-bot.
|
This PR conflicts with #13023 in it's current state. Discussing offline |
Merge remote to local.
Description
Fixes b/347347639, b/347347585, b/347347681, b/347347739, b/347347584
This PR adds SCC Managament API Org SHA Custom Module Samples to Create, Get, List, Delete & Update.
Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.
Checklist
nox -s py-3.9
(see Test Environment Setup)nox -s lint
(see Test Environment Setup)