Feat/ec2 full checks#10
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Expands the AWS EC2 plugin to collect richer compliance evidence per instance (security groups, EBS volumes, account-owned snapshots and their share permissions, AMIs, and Fast Snapshot Restore state) across multiple configurable AWS regions, and upgrades the plugin to the v2 runner/agent protocol. Also bumps Go and many dependencies, adds a Makefile, and annotates the build artifact with the new plugin protocol version.
Changes:
- Multi-region scan + full EC2/EBS/AMI/FSR evidence collection composed into a single
EC2PolicyInput, plus pagination overDescribeInstances/DescribeVolumes/DescribeSnapshots/DescribeImages/DescribeFastSnapshotRestores. - Upgrade to
RunnerV2GRPCPlugin, adding anInitmethod and forwardingPolicyDatafromConfigure, withorg.ccf.plugin.protocol.version=2annotation set on the published OCI artifact. - Major dependency / Go toolchain bump (agent
v0.7.0-rc1, AWS SDK, OPA, etc.), new Makefile, and.gitignoreentry for.config/.
Reviewed changes
Copilot reviewed 4 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| main.go | Implements multi-region scan, snapshot/AMI/FSR collection, V2 plugin interface, region config parsing, helper functions. |
| Makefile | New build/test/run helpers; includes an unconditional opa CLI presence check. |
| go.mod | Go 1.26.1 + bumped/added direct & indirect deps (agent v0.7.0-rc1, AWS SDK, OPA, etc.). |
| go.sum | Checksums updated to match new module graph; contains some stale/partial entries. |
| .github/workflows/build-and-upload.yml | Annotates published OCI artifacts with org.ccf.plugin.protocol.version=2. |
| .gitignore | Ignores local .config/ directory used by make run. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| for _, createVolumePermission := range result.CreateVolumePermissions { | ||
| if string(createVolumePermission.Group) == "all" { |
Comment on lines
+120
to
127
| for _, region := range regions { | ||
| cfg, err := config.LoadDefaultConfig(ctx, config.WithRegion(region)) | ||
| if err != nil { | ||
| l.logger.Error("unable to get instance", "error", err) | ||
| l.logger.Error("unable to load SDK config", "region", region, "error", err) | ||
| evalStatus = proto.ExecutionStatus_FAILURE | ||
| accumulatedErrors = errors.Join(accumulatedErrors, err) | ||
| break | ||
| continue | ||
| } |
Comment on lines
+605
to
+614
| result, err := client.DescribeImages(ctx, &ec2.DescribeImagesInput{ | ||
| Owners: []string{"self"}, | ||
| Filters: []types.Filter{ | ||
| { | ||
| Name: aws.String("block-device-mapping.snapshot-id"), | ||
| Values: snapshotIDs, | ||
| }, | ||
| }, | ||
| NextToken: nextToken, | ||
| }) |
Comment on lines
+537
to
+543
| result, err := client.DescribeSnapshotAttribute(ctx, &ec2.DescribeSnapshotAttributeInput{ | ||
| Attribute: types.SnapshotAttributeNameCreateVolumePermission, | ||
| SnapshotId: aws.String(snapshotID), | ||
| }) | ||
| if err != nil { | ||
| return nil, err | ||
| } |
Comment on lines
+658
to
+680
| var nextToken *string | ||
|
|
||
| for { | ||
| result, err := client.DescribeFastSnapshotRestores(ctx, &ec2.DescribeFastSnapshotRestoresInput{ | ||
| Filters: []types.Filter{ | ||
| { | ||
| Name: aws.String("snapshot-id"), | ||
| Values: snapshotIDs, | ||
| }, | ||
| }, | ||
| NextToken: nextToken, | ||
| }) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| fastSnapshotRestore = append(fastSnapshotRestore, result.FastSnapshotRestores...) | ||
| if aws.ToString(result.NextToken) == "" { | ||
| return fastSnapshotRestore, nil | ||
| } | ||
|
|
||
| nextToken = result.NextToken | ||
| } |
Comment on lines
+743
to
+758
| parts := strings.Split(regionValue, ",") | ||
| regions := make([]string, 0, len(parts)) | ||
| seen := make(map[string]struct{}, len(parts)) | ||
| for _, part := range parts { | ||
| region := strings.Trim(part, " []\"'") | ||
| if region == "" { | ||
| continue | ||
| } | ||
|
|
||
| if _, exists := seen[region]; exists { | ||
| continue | ||
| } | ||
|
|
||
| seen[region] = struct{}{} | ||
| regions = append(regions, region) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.