Repository navigation
test(cmd): guardrail against new aws-sdk imports in cmd/ (#327) - #345
Merged
Merged
Conversation
Adds cmd/aws_imports_test.go: an AST-based test that parses every non-test cmd/*.go and fails if it imports an aws-sdk-go-v2/service/* package outside a per-file allowlist seeded with the current (post-#326) baseline. A new direct SDK import — or an existing file reaching for a new service — fails the test, steering AWS work into a pkg/* store/client instead. It also flags allowlist entries that a file no longer imports, so the list tightens as more logic moves into pkg/*. Now feasible because the #326 store extraction removed the raw DynamoDB calls from bot/team/pipeline/list-sweeps/collect; the remaining allowed imports are store-client construction (dynamodb.NewFromConfig), STS caller-identity, and the launch/queue EC2/S3 paths. Verified: passes on the baseline; negative-tested (injecting a service/kms import into cancel.go fails with an actionable message, green again after removal). Test-only; go vet + full cmd suite green.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Closes #327. Final audit follow-up (#328), unblocked by the #326 store extraction. Test-only, no runtime change.
What
cmd/aws_imports_test.go— an AST-basedgo/parsertest that walks every non-testcmd/*.goand fails if it imports anaws-sdk-go-v2/service/*package outside a per-file allowlist seeded with the current (post-#326) baseline. It also flags allowlist entries a file no longer imports, so the list tightens as more logic moves intopkg/*rather than rotting.Why now
Before #326,
cmd/reached for DynamoDB directly all over. Now bot/team/pipeline/list-sweeps/collect go throughpkg/*stores, so the remaining allowed SDK imports are legitimate and bounded:dynamodb.NewFromConfighanded to apkgstore),A new direct SDK import — or an existing file reaching for a new service — now fails with an actionable message pointing the author at the
pkg/*pattern (or to justify it by extending the allowlist in the same PR).Verification
service/kmsimport intocancel.gofails the test with the expected message; green again after removal.go vet ./cmd,gofmt, fullcmdsuite green (excl. pre-existingTestCatalogValid/ feat(plugin): permissions declaration block (#388) #392).