feat(aws): add identity/network baseline rules and collector enhancem…#106
feat(aws): add identity/network baseline rules and collector enhancem…#106j3ttt wants to merge 2 commits intoantgroup:mainfrom
Conversation
Summary of ChangesHello @j3ttt, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly expands the AWS security posture assessment capabilities by adding numerous new baseline rules focused on identity and network access. To facilitate these new checks, the underlying data collectors for various AWS services have been upgraded to retrieve more granular configuration details. A new documentation file has also been introduced to standardize the process for future rule and collector development, ensuring consistency and clarity in how security rules are implemented and supported by data collection. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request significantly enhances several AWS collectors to gather more detailed information, particularly around network exposure and identity/access configurations. It adds details like security groups for ElastiCache and OpenSearch, network exposure information for ElastiCache, listeners for ELBs, Access Analyzer results for account settings, parsed policy documents for IAM roles, and access key last-used timestamps for IAM users. To complement these data enhancements, a comprehensive set of new Rego rules has been added to improve security posture assessment. The changes are well-structured and greatly increase the platform's security detection capabilities. I have a few suggestions to improve code consistency and robustness.
| func stringPtr(v string) *string { | ||
| return &v | ||
| } |
There was a problem hiding this comment.
This helper function stringPtr duplicates functionality from the AWS SDK. It's more idiomatic and consistent with other parts of the codebase to use aws.String() from the github.com/aws/aws-sdk-go-v2/aws package. Please remove this local helper and replace its usages with aws.String(). This will require adding an import for github.com/aws/aws-sdk-go-v2/aws.
| func parsePolicyDocument(raw string) map[string]interface{} { | ||
| decoded, err := url.QueryUnescape(raw) | ||
| if err != nil { | ||
| decoded = raw | ||
| } | ||
|
|
||
| var doc map[string]interface{} | ||
| if err := json.Unmarshal([]byte(decoded), &doc); err == nil { | ||
| return doc | ||
| } | ||
| if err := json.Unmarshal([]byte(raw), &doc); err == nil { | ||
| return doc | ||
| } | ||
| return nil | ||
| } |
There was a problem hiding this comment.
The parsePolicyDocument function currently returns nil if JSON unmarshalling fails, without logging the error. This can silently hide issues with malformed policy documents, making debugging difficult. It would be beneficial to log a warning when both unmarshalling attempts fail.
| func parsePolicyDocument(raw string) map[string]interface{} { | |
| decoded, err := url.QueryUnescape(raw) | |
| if err != nil { | |
| decoded = raw | |
| } | |
| var doc map[string]interface{} | |
| if err := json.Unmarshal([]byte(decoded), &doc); err == nil { | |
| return doc | |
| } | |
| if err := json.Unmarshal([]byte(raw), &doc); err == nil { | |
| return doc | |
| } | |
| return nil | |
| } | |
| func parsePolicyDocument(raw string) map[string]interface{} { | |
| decoded, err := url.QueryUnescape(raw) | |
| if err != nil { | |
| decoded = raw | |
| } | |
| var doc map[string]interface{} | |
| if err := json.Unmarshal([]byte(decoded), &doc); err == nil { | |
| return doc | |
| } | |
| if err := json.Unmarshal([]byte(raw), &doc); err == nil { | |
| return doc | |
| } | |
| log.GetWLogger().Warn("failed to unmarshal IAM policy document", zap.String("document", raw)) | |
| return nil | |
| } |
| func stringPtr(v string) *string { | ||
| return &v | ||
| } |
There was a problem hiding this comment.
This helper function stringPtr duplicates functionality from the AWS SDK. It's more idiomatic and consistent with other parts of the codebase to use aws.String() from the github.com/aws/aws-sdk-go-v2/aws package. Please remove this local helper and replace its usage with aws.String(). This will require adding an import for github.com/aws/aws-sdk-go-v2/aws.
…ents
Thank you for your contribution to CloudRec!
What About:
java)go)opa)Description:
Explain the purpose of the PR.