Skip to content

fix: resource id would be empty when jsonPath get the wrong way#72

Merged
j3ttt merged 1 commit intoantgroup:mainfrom
j3ttt:fix/aws-empty
Sep 2, 2025
Merged

fix: resource id would be empty when jsonPath get the wrong way#72
j3ttt merged 1 commit intoantgroup:mainfrom
j3ttt:fix/aws-empty

Conversation

@j3ttt
Copy link
Collaborator

@j3ttt j3ttt commented Sep 2, 2025

Thank you for your contribution to CloudRec!

What About:

  • Server (java)
  • Collector (go)
  • Rule (opa)

Description:

fix: resource id would be empty when jsonPath get the wrong way

Summary by Sourcery

Fix resource ID extraction for various AWS collectors by correcting JSONPath expressions and propagating IDs through detail structs

Enhancements:

  • Correct JSONPath for ResourceId and ResourceName in AWS collectors (IAM account settings, GuardDuty detectors, SQS queues, EC2 flow logs, network interfaces, and OpenSearch domains)
  • Add and populate explicit ID fields (AccountId, DetectorId) in detail structs to ensure resource IDs are not empty

@gemini-code-assist
Copy link
Contributor

Important

Installation incomplete: to start using Gemini Code Assist, please ask the organization owner(s) to visit the Gemini Code Assist Admin Console and sign the Terms of Services.

@sourcery-ai
Copy link

sourcery-ai bot commented Sep 2, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Correct JSONPath mappings in AWS collector RowField configurations, add explicit ID fields to detail structs for AccountSettings and GuardDuty detectors, and perform minor whitespace cleanup.

Class diagram for updated AccountSettingsDetail and DetectorDetail structs

classDiagram
    class AccountSettingsDetail {
        map<string, int32> AccountSummary
        string AccountId
        // todo
        //EnabledFeatures []types.FeatureType
    }
    class DetectorDetail {
        string DetectorId
        *guardduty.GetDetectorOutput Detector
        *types.Administrator Administrator
        map<string, string> Tags
    }
Loading

File-Level Changes

Change Details Files
Fix JSONPath expressions for ResourceId and ResourceName in RowField definitions
  • Correct AccountSettings JSONPath to "$.AccountId" for both ResourceId and ResourceName
  • Update GuardDuty detector JSONPath to use "$.DetectorId"
  • Adjust SQS queue JSONPath to use "$.Url" and "$.Name"
  • Change EC2 FlowLog JSONPath to "$.FlowLog.FlowLogId"
  • Change EC2 NetworkInterface JSONPath to "$.NetworkInterface.NetworkInterfaceId"
  • Update OpenSearch domain JSONPath to "$.DomainStatus.DomainId" and "$.DomainStatus.DomainName"
collector/aws/collector/iam/account_settings.go
collector/aws/collector/guardduty/detector.go
collector/aws/collector/sqs/queue.go
collector/aws/collector/ec2/flowlog.go
collector/aws/collector/ec2/networkinterface.go
collector/aws/collector/opensearch/domain.go
Add identifier fields to detail structs and populate them
  • Introduce AccountId field in AccountSettingsDetail and set it from context
  • Add DetectorId field in DetectorDetail and assign the parsed detector ID
collector/aws/collector/iam/account_settings.go
collector/aws/collector/guardduty/detector.go
Remove trailing whitespace in SQS detail function
  • Delete stray blank line in describeSQSQueueDetail after tag retrieval
collector/aws/collector/sqs/queue.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • Add json struct tags to the new AccountId and DetectorId fields so they will be included properly when serializing the detail structs.
  • Consider centralizing or validating the JSONPath expressions against actual AWS SDK response models to avoid manual duplication and future mismatches.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Add json struct tags to the new AccountId and DetectorId fields so they will be included properly when serializing the detail structs.
- Consider centralizing or validating the JSONPath expressions against actual AWS SDK response models to avoid manual duplication and future mismatches.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@j3ttt j3ttt merged commit eae81f7 into antgroup:main Sep 2, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant