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(security-command-center): add v2 version of SetMuteUndefinedFinding.java #9589

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

hegemonic
Copy link
Contributor

Description

Adds a v2 equivalent of security-command-center/snippets/src/main/java/muteconfig/SetMuteUndefinedFinding.java.

Checklist

  • I have followed Sample Format Guide
  • pom.xml parent set to latest shared-configuration
  • Appropriate changes to README are included in PR
  • 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)
  • Tests pass: mvn clean verify required
  • Lint passes: mvn -P lint checkstyle:check required
  • Static Analysis: mvn -P lint clean compile pmd:cpd-check spotbugs:check advisory only
  • This sample adds a new sample directory, and I updated the CODEOWNERS file with the codeowners 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

@hegemonic hegemonic requested review from yoshi-approver and a team as code owners October 16, 2024 20:37
@product-auto-label product-auto-label bot added samples Issues that are directly related to samples. api: securitycenter Issues related to the Security Command Center API. labels Oct 16, 2024
@hegemonic hegemonic marked this pull request as draft October 16, 2024 20:39
@hegemonic
Copy link
Contributor Author

Blocked until #9580 is merged.

Copy link

snippet-bot bot commented Oct 16, 2024

Here is the summary of changes.

You are about to add 1 region tag.

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

@hegemonic hegemonic marked this pull request as ready for review October 21, 2024 19:02
@hegemonic
Copy link
Contributor Author

Blocked until #9580 is merged.

That PR was merged, and this one is ready to review.

@hegemonic
Copy link
Contributor Author

@telpirion Friendly ping.

* limitations under the License.
*/

package vtwo.muteconfig;
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: rename to v2.muteconfig.

question: I see that there is a muteconfig package already in the parent java/ folder. How do we plan to disambiguate between the two packages?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Every existing file under security-command-center/snippets/src/main/java/vtwo follows the naming convention that I've used here. The existing files all use a package name that starts with vtwo, not v2. Also, the existing files often have package names that overlap with the parent java/ folder.

Can I ask that you allow me to add this sample with the package name vtwo.muteconfig, and that you work with the sample owners (the Security Command Center product team) to improve the package names as a follow-on task?

@owenhuyn FYI.

// Reset mute state of an individual finding.
// If a finding is already reset, resetting it again has no effect.
// Various mute states are: MUTE_UNSPECIFIED/MUTE/UNMUTE/UNDEFINED.
public static Finding setMuteUndefined(String findingPath) throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: don't return an object, instead process the result in the sample.

See https://googlecloudplatform.github.io/samples-style-guide/#result.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this repo's SAMPLE_FORMAT.md file, it says the opposite:

Snippet methods should return data that can be used in the calling method to show the user how to interact with a returned object programmatically.

In #9547, I tried to log information instead of returning a result, as you're suggesting, and I was told to return a result instead.

I'd like to keep this code as-is, given that it's consistent with the instructions in this repo.

Finding finding = SetMuteFinding.setMute(FINDING_1.getName());
assertThat(finding.getMute()).isEqualTo(Mute.MUTED);
finding = SetUnmuteFinding.setUnmute(FINDING_1.getName());
assertThat(finding.getMute()).isEqualTo(Mute.UNMUTED);
finding = SetMuteUndefinedFinding.setMuteUndefined(FINDING_1.getName());
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: don't check for a result; instead parse stdout to ensure that something was printed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd like to keep this code as-is, given that it's consistent with the instructions in this repo.

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.

2 participants