mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(ram): give resource-tag conditions the tags of the resource share a request names (#8713)
The generated request resources give RAM's resource-share type the aws:ResourceTag/ and ram:ResourceTag/ keys, but RamService answered no tags, so a condition on a share's tags saw none. RamService.storedTags now reads the share stored under the ARN in the owning account the ARN names, in place, matched on the whole ARN shares are kept by, when the caller may see it as GetResourceShares shows it: one it owns or one made visible to it, so a decision never turns on a share RAM hides from the caller. A share is immutable and tagging stores a new one under the service's lock, so the lookup always reads one whole set of tags.
This commit is contained in:
1 parent
751c97dde6
commit
da39feee4e
5 files changed
+76
-3
No files matched your search
@@ -1208,6 +1208,33 @@ class IamRestRouteEnforcementIntegrationTest {
|
||||
request(user, "ram", "DELETE", "/deleteresourceshare?resourceShareArn=" + encoded(share), null).statusCode(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* An {@code aws:ResourceTag} condition reads the tags RAM holds on the resource share a request names, so an allow
|
||||
* on one team's tag lets the caller update that team's share and not another's.
|
||||
*/
|
||||
@Test
|
||||
void aRamResourceTagConditionReadsTheTagsOfTheResourceShare() {
|
||||
String tagged = taggedShare("data");
|
||||
String other = taggedShare("web");
|
||||
String user = user("route-ram-tags");
|
||||
|
||||
policy(user, "{\"Effect\":\"Allow\",\"Action\":\"ram:UpdateResourceShare\",\"Resource\":\"*\","
|
||||
+ "\"Condition\":{\"StringEquals\":{\"aws:ResourceTag/team\":\"data\"}}}");
|
||||
request(user, "ram", "POST", "/updateresourceshare", "{\"resourceShareArn\":\"" + tagged + "\"}")
|
||||
.statusCode(200);
|
||||
refused(request(user, "ram", "POST", "/updateresourceshare", "{\"resourceShareArn\":\"" + other + "\"}"),
|
||||
"ram:UpdateResourceShare");
|
||||
}
|
||||
|
||||
/** A resource share an administrator makes and tags with the team, deleted after the test; its ARN. */
|
||||
private String taggedShare(String team) {
|
||||
String share = madeShare(adminOf("ram").body("{\"name\":\"route-share-" + suffix() + "\"}")
|
||||
.post("/createresourceshare").then());
|
||||
adminOf("ram").body("{\"resourceShareArn\":\"" + share + "\",\"tags\":[{\"key\":\"team\",\"value\":\""
|
||||
+ team + "\"}]}").post("/tagresource").then().statusCode(200);
|
||||
return share;
|
||||
}
|
||||
|
||||
@Test
|
||||
void ramCreateIsCheckedOnTheShareItMakesAndThePermissionsItNames() {
|
||||
String user = user("route-ram-create");
|
||||
|
||||
@@ -70,6 +70,27 @@ class RamServiceTest {
|
||||
service.initializeStorage();
|
||||
}
|
||||
|
||||
/**
|
||||
* IAM's tag lookup reads the tags held on the share the whole ARN names, in the owning account the ARN names, as
|
||||
* tagging leaves them, when the caller may see the share: the caller's own share gives its tags, another account's
|
||||
* share not shared with it gives none, as RAM hides it; nothing for another share's ARN or one that is not a
|
||||
* share's.
|
||||
*/
|
||||
@Test
|
||||
void storedTagsAreTheTagsOfTheShareTheArnNamesWhenTheCallerMaySeeIt() {
|
||||
String caller = "000000000000";
|
||||
ResourceShare own = service.createResourceShare("tagged", List.of(), List.of(), false, "us-east-1", caller);
|
||||
service.tagResource(own.getResourceShareArn(), Map.of("team", "data"), caller, "us-east-1");
|
||||
service.tagResource(own.getResourceShareArn(), Map.of("env", "prod"), caller, "us-east-1");
|
||||
ResourceShare hidden = service.createResourceShare("hidden", List.of(), List.of(), false, "us-east-1", OWNER);
|
||||
service.tagResource(hidden.getResourceShareArn(), Map.of("team", "data"), OWNER, "us-east-1");
|
||||
|
||||
assertEquals(Map.of("team", "data", "env", "prod"), service.storedTags(own.getResourceShareArn()));
|
||||
assertEquals(Map.of(), service.storedTags(hidden.getResourceShareArn()));
|
||||
assertEquals(Map.of(), service.storedTags(own.getResourceShareArn() + "0"));
|
||||
assertEquals(Map.of(), service.storedTags("arn:aws:s3:::bucket"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void deletedShareStopsExposingItsResourcesAndPrincipals() {
|
||||
// Real RAM keeps a deleted share visible (status DELETED) for a retention
|
||||
|
||||
Reference in new issue
Block a user