-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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 Security Center Service Custom Module samples (Get, List, Update) #9913
base: main
Are you sure you want to change the base?
Conversation
Here is the summary of changes. You are about to add 3 region tags.
This comment is generated by snippet-bot.
|
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 @lovenishs04 and reviewers,
I'm currently reviewing this pull request and will post my detailed review in a few minutes. In the meantime, here's a quick summary to help everyone get up to speed:
This pull request adds Java samples for the Security Command Center Management API's Organization Security Center Service Custom Module. Specifically, it includes samples for:
- Get: Retrieving a Security Center service.
- List: Listing all Security Center services.
- Update: Updating a Security Center service.
The changes involve creating new Java classes (GetSecurityCenterService.java
, ListSecurityCenterServices.java
, UpdateSecurityCenterService.java
) and corresponding unit tests (SecurityCenterServiceTest.java
). These classes use the google-cloud-securitycentermanagement
library to interact with the Security Command Center API. The code is well-documented and includes clear instructions and comments.
The intent is to provide developers with clear, concise, and readily usable code examples for common Security Command Center tasks. This will improve the developer experience and make it easier to integrate Security Command Center into their applications.
Here's a little haiku to lighten the mood:
Secure the cloud's keep,
Code samples guide the way clear,
Safety's code unfolds.
Looking forward to the discussion!
Best,
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 adds samples for the Security Command Center Management API's Organization Security Center Service Custom Module. The samples cover Get, List, and Update operations. The code generally looks good, but there are a few improvements that can be made regarding clarity, error handling, and documentation.
I've referenced the Sample Format Guide in this review, specifically the sections on TODO comments and placeholder values.
It's important to address the TODOs and ensure the README is updated before merging. The checklist in the PR description mentions several important items that need to be confirmed.
|
||
public static void main(String[] args) throws IOException { | ||
// https://cloud.google.com/security-command-center/docs/reference/security-center-management/rest/v1/organizations.locations.securityCenterServices/get | ||
// TODO: Developer should replace project_id with a real project ID before running this code |
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 TODO comment should be more actionable. Instead of just stating what the developer needs to do, consider providing a more descriptive placeholder or example. Per the Sample Format Guide, placeholder values should be enclosed in angle brackets.
// TODO: Developer should replace project_id with a real project ID before running this code | |
// TODO: Replace <project-id> with your project ID | |
String projectId = "<project-id>"; |
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
public static void main(String[] args) throws IOException { | ||
// https://cloud.google.com/security-command-center/docs/reference/security-center-management/rest/v1/organizations.locations.securityCenterServices/get | ||
// TODO: Developer should replace project_id with a real project ID before running this code | ||
String projectId = "project_id"; |
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
// Replace service with one of the valid values: | ||
// container-threat-detection, event-threat-detection, security-health-analytics, | ||
// vm-threat-detection, web-security-scanner | ||
String service = "service"; |
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
|
||
public static void main(String[] args) throws IOException { | ||
// https://cloud.google.com/security-command-center/docs/reference/security-center-management/rest/v1/organizations.locations.securityCenterServices/list | ||
// TODO: Developer should replace project_id with a real project ID before running this code |
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.
Make this TODO comment more actionable and use angle brackets for the placeholder, as per the Sample Format Guide.
// TODO: Developer should replace project_id with a real project ID before running this code | |
// TODO: Replace <project-id> with your project ID | |
String projectId = "<project-id>"; |
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
public static void main(String[] args) throws IOException { | ||
// https://cloud.google.com/security-command-center/docs/reference/security-center-management/rest/v1/organizations.locations.securityCenterServices/list | ||
// TODO: Developer should replace project_id with a real project ID before running this code | ||
String projectId = "project_id"; |
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
|
||
public static void main(String[] args) throws IOException { | ||
// https://cloud.google.com/security-command-center/docs/reference/security-center-management/rest/v1/organizations.locations.securityCenterServices/patch | ||
// TODO: Developer should replace project_id with a real project ID before running this code |
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.
Ensure the TODO comment is actionable and uses angle brackets for placeholders, consistent with the Sample Format Guide.
// TODO: Developer should replace project_id with a real project ID before running this code | |
// TODO: Replace <project-id> with your project ID | |
String projectId = "<project-id>"; |
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
public static void main(String[] args) throws IOException { | ||
// https://cloud.google.com/security-command-center/docs/reference/security-center-management/rest/v1/organizations.locations.securityCenterServices/patch | ||
// TODO: Developer should replace project_id with a real project ID before running this code | ||
String projectId = "project_id"; |
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
// Replace service with one of the valid values: | ||
// container-threat-detection, event-threat-detection, security-health-analytics, | ||
// vm-threat-detection, web-security-scanner | ||
String service = "service"; |
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
|
||
@RunWith(JUnit4.class) | ||
public class SecurityCenterServiceTest { | ||
// TODO(Developer): Replace the below variable |
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 a TODO, provide clear instructions on setting the environment variable. This improves the clarity and usability of the test code. For example:
// Set the SCC_PROJECT_ID environment variable. See https://cloud.google.com/docs/authentication/getting-started for more details.
private static final String PROJECT_ID = System.getenv("SCC_PROJECT_ID");
// TODO(Developer): Replace the below variable | |
// Set the SCC_PROJECT_ID environment variable. See https://cloud.google.com/docs/authentication/getting-started for more details. | |
private static final String PROJECT_ID = System.getenv("SCC_PROJECT_ID"); |
Description
Fixes # b/347346449, b/347346682, b/347346802
This PR adds SCC Managament API Org Security Center Service Custom Module Samples for Get, List and Update.
Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.
Checklist
pom.xml
parent set to latestshared-configuration
mvn clean verify
requiredmvn -P lint checkstyle:check
requiredmvn -P lint clean compile pmd:cpd-check spotbugs:check
advisory only