Files
floci/tools
Priamo Germosen 16bdd60072 fix(iam): check an AWS Backup recovery point on the ARN its request names (#9884)
The Service Reference gives AWS Backup's recovery point the format
arn:${Partition}:${Vendor}:${Region}:*:${ResourceType}:${RecoveryPointId}, a wildcard where the account goes, which
no ARN a request names matches as written, so every request naming a recovery point by its ARN
(DescribeRecoveryPoint, DeleteRecoveryPoint, StartRestoreJob and the rest) was checked on *.

The AWS Backup Developer Guide's table of resource ARNs gives each kind of recovery point's ARN with the account, or
nothing, in that place. tools/aws/fetch_backup_arn_formats.py vendors the table's recovery point rows as they stand
into tools/aws/sources/backup-arn-formats.json, refusing a row with anything else there, and writes the Service
Reference's format with the account variable in place of the wildcard. ARN_FORMAT_SOURCES grants it for backup, and
with_vendored_formats now takes a vendored format that has a variable for each of the reference's wildcards and
nothing else changed. The table's recovery point format becomes
arn:${Partition}:${Vendor}:${Region}:${Account}:${ResourceType}:${RecoveryPointId}.

Some rows give a recovery point no colon between its type and id, which that format does not fit (an EBS snapshot's
arn:aws:ec2:region::snapshot/*, a DynamoDB backup's table/*/backup/*). The fetcher also writes each row as a format
of its own, the last wildcard as ${RecoveryPointId} and one before it as ${Resource}, and the table gives the
recovery point those its format does not fit already (alternateFormats): EBS snapshots, EC2 images, FSx backups and
DynamoDB backups. RequestResourceMembers matches a type's ARN against its format or any of them.

The generic recovery point format also fits an IAM role whose path holds a colon, and the rule for an ARN member had
typed the roles StartRestoreJob, StartCopyJob and StartScanJob pass as recovery points. The generator now reads the
generated passed-roles table, as it reads the authorized-actions one, and reads no resource of an action from a
member it gives as a role the operation passes, whose ARN iam:PassRole is checked on: 98 rows in 83 operations go,
of which only those five could fit a role's ARN.

test_fetch_backup_arn_formats.py checks the fetcher's copy, its formats and refusals;
test_regen_iam_request_resources.py the account wildcard's replacement, the alternates kept and the passed-role rows
dropped; RequestResourceMembersTest the alternates' read and refusals; ResourceArnBuilderTest that DescribeRecoveryPoint
is checked on the ARN in its path, a Backup one sent encoded or not and an EBS one as an SDK encodes it, and
StartRestoreJob on its recovery point and not on the role it passes; IamRequestResourceEnforcementIntegrationTest that a
grant on one recovery point's ARN lets the caller describe that one and not another.
2026-12-01 07:44:42 -04:00
..