From e73b80d5ee22aeff8c59b2b78fdd1379314a3afe Mon Sep 17 00:00:00 2001 From: Hector Ventura Date: Thu, 24 Sep 2026 09:17:30 -0500 Subject: [PATCH] fix: bring the partition literals that merged past the gate back under it (#4314) Three pull requests merged after the partition-literal gate (#4270) without ever running it, because their CI started before the gate existed on their base, so main has failed the gate for every pull request since: CostAnomalyService (#4221) spelled its own partition alternation in the SNS topic ARN pattern, EcrService (#4304) did the same in the pull-through-cache credential ARN pattern and compared a host against public.ecr.aws, and IamService (#4298) built the credential report's root ARN with a literal arn:aws:. The two patterns now use AwsArnUtils.PARTITION_REGEX, the root ARN is minted through AwsArnUtils like every other IAM ARN in the file, and the ECR Public host carries the gate's escape comment: it is that registry's fixed name and the service exists only in the commercial partition. --- .../hectorvent/floci/services/ce/CostAnomalyService.java | 2 +- .../io/github/hectorvent/floci/services/ecr/EcrService.java | 4 ++-- .../io/github/hectorvent/floci/services/iam/IamService.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/hectorvent/floci/services/ce/CostAnomalyService.java b/src/main/java/io/github/hectorvent/floci/services/ce/CostAnomalyService.java index 4509d0d6ec..26496a1cff 100644 --- a/src/main/java/io/github/hectorvent/floci/services/ce/CostAnomalyService.java +++ b/src/main/java/io/github/hectorvent/floci/services/ce/CostAnomalyService.java @@ -36,7 +36,7 @@ public class CostAnomalyService implements Resettable { private static final Pattern EMAIL = Pattern.compile( "^[a-zA-Z0-9.!#$%&'*+=?^_`{|}~-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$"); private static final Pattern SNS = Pattern.compile( - "^arn:aws[a-zA-Z-]*:sns:[a-zA-Z0-9-]+:[0-9]{12}:[a-zA-Z0-9_-]+(\\.fifo)?$"); + "^arn:" + AwsArnUtils.PARTITION_REGEX + ":sns:[a-zA-Z0-9-]+:[0-9]{12}:[a-zA-Z0-9_-]+(\\.fifo)?$"); private final AccountAwareStorageBackend monitors; private final AccountAwareStorageBackend subscriptions; diff --git a/src/main/java/io/github/hectorvent/floci/services/ecr/EcrService.java b/src/main/java/io/github/hectorvent/floci/services/ecr/EcrService.java index 778e41d464..90ac23310e 100644 --- a/src/main/java/io/github/hectorvent/floci/services/ecr/EcrService.java +++ b/src/main/java/io/github/hectorvent/floci/services/ecr/EcrService.java @@ -47,7 +47,7 @@ public class EcrService implements ResourceProvider { + "(?:(?:\\.|_|__|-+)[a-z0-9]+)*)*/?|ROOT)"); private static final Pattern REGISTRY_ID = Pattern.compile("[0-9]{12}"); private static final Pattern CREDENTIAL_ARN = Pattern.compile( - "arn:aws(?:-\\w+)*:secretsmanager:[a-zA-Z0-9-:]+:secret:ecr-pullthroughcache/" + "arn:" + AwsArnUtils.PARTITION_REGEX + ":secretsmanager:[a-zA-Z0-9-:]+:secret:ecr-pullthroughcache/" + "[a-zA-Z0-9/_+=.@-]+"); private static final Set UPSTREAM_REGISTRIES = Set.of( "ecr", "ecr-public", "quay", "k8s", "docker-hub", @@ -954,7 +954,7 @@ public class EcrService implements ResourceProvider { if (host.equals("registry-1.docker.io")) { return "docker-hub"; } - if (host.equals("public.ecr.aws")) { + if (host.equals("public.ecr.aws")) { // partition-literal: ECR Public's fixed registry host; the service exists only in the commercial partition return "ecr-public"; } if (host.equals("quay.io")) { diff --git a/src/main/java/io/github/hectorvent/floci/services/iam/IamService.java b/src/main/java/io/github/hectorvent/floci/services/iam/IamService.java index 5b2e8b362e..3814f0697e 100644 --- a/src/main/java/io/github/hectorvent/floci/services/iam/IamService.java +++ b/src/main/java/io/github/hectorvent/floci/services/iam/IamService.java @@ -2959,7 +2959,7 @@ public class IamService implements SessionAccountLookup, ResourceProvider { } private String rootAccountReportRow() { - String arn = "arn:aws:iam::" + regionResolver.getAccountId() + ":root"; + String arn = AwsArnUtils.Arn.of("iam", "", regionResolver.getAccountId(), "root").toString(); return String.join(",", "", arn, "N/A", "FALSE", "N/A", "N/A", "not_supported",