Repository navigation
feat(access): permission policies that refuse calls the caller lacks permission for - #28
Merged
Merged
Conversation
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.
Summary
A new
accesspackage lets a test grant a set of permissions and see whether the code under test needs exactly those. The package covers Google Cloud IAM permissions, AWS IAM actions and Azure RBAC actions. Every stand-in takes a policy withWithPolicy:forbidden.UnauthorizedOperation.AccessDenied.AuthorizationFailed, orLinkedAuthorizationFailedfor a resource the request references.Denials()lists the calls refused and what each lacked.Unused()lists grants no call needed.Used()lists what was needed.A call needs its method's permission and those its request adds, from each API's reference:
compute.disks.createandcompute.images.useReadOnly. Metadata needssetMetadata. A service account needssetServiceAccountandiam.serviceAccounts.actAs. An address insert needs eithercreateorcreateInternal.projection=fullneedsgetIamPolicy, and an upload that replaces a live object needsstorage.objects.delete.TagSpecificationneedsec2:CreateTags.s3:ListBucket, and deleting a version needss3:DeleteObjectVersion.s3:PutObjectAcl.AccessDeniedentry in the result, and the rest are deleted.A grant may use
*and matches without regard to case. Grants are not checked against resources or condition keys: a grant covers every resource. Each package's documentation says so.Testing
make checkpasses.sdktest/*/permissions_test.go). They cover a refusal and its error shape, a permission a request field adds, Azure's linked refusal, S3's per-key DeleteObjects result, andUsed/Unused/Denials.accesshas its own tests, run with-race.make benchagainst canary, 6 runs each, with benchstat:Checklist
make checkpasses