mirror of
https://github.com/floci-io/floci.git
synced 2026-11-30 00:45:17 -05:00
chore(core): gate comparisons of a partition with the literal "aws" (#4892)
* chore(core): gate comparisons of a partition with the literal "aws" The five checks #4791 fixed compared a parsed ARN's partition with "aws", so RDS, ElastiCache and RAM broke silently outside the commercial partition, and make partition-check could not see them: a bare "aws" is not an arn:aws: prefix. partition_literals.py gains a gated aws-partition-compare category, scanned over the code with comments and text blocks blanked, that catches "aws".equals(...), .equals("aws"), their equalsIgnoreCase forms and Objects.equals with "aws". Run against main before #4791 it reports exactly those five sites. The three remaining uses compare an account, a command name and a reserved SSM name prefix, not a partition, and are escaped with a reason. AGENTS.md states the rule next to the other partition rules, so reviews flag it too. The audit table sizes its columns to the longest category name. Part of #4272. * chore(core): end the Objects.equals match at its call and gate switch labels on "aws" Greptile on #4892: the Objects.equals arm read past the call's closing parenthesis, so foo(Objects.equals(a, b), "aws") matched a comparison that is not there; each argument now allows one level of nested calls and the match ends at the call's own parenthesis. And a switch on a partition branched on "aws" without a match, so case labels naming "aws", alone or in a list, are caught too. main has none, so no new escapes and the baseline stays empty.
This commit is contained in:
1 parent
c800cc375e
commit
ae216f22a0
6 files changed
+70
-9
No files matched your search
@@ -2023,7 +2023,7 @@ public class IamQueryHandler {
|
||||
// An AWS-managed policy carries the literal "aws" in the account field
|
||||
// (arn:aws:iam::aws:policy/...) and is served from the global catalog, so it is not a
|
||||
// foreign account and must not be rejected as one.
|
||||
boolean awsManaged = "aws".equals(parsed.accountId());
|
||||
boolean awsManaged = "aws".equals(parsed.accountId()); // partition-literal: managed-policy account
|
||||
if (!awsManaged && parsed.accountId() != null && !parsed.accountId().isEmpty()
|
||||
&& !parsed.accountId().equals(accountId)) {
|
||||
throw new AwsException("NoSuchEntity", "The ARN " + arn + " cannot be found.", 404);
|
||||
|
||||
+1
-1
@@ -131,7 +131,7 @@ final class EksTokenMinter {
|
||||
}
|
||||
var fileName = Path.of(command).getFileName();
|
||||
var commandName = fileName == null ? command : fileName.toString();
|
||||
if (!"aws".equals(commandName)) {
|
||||
if (!"aws".equals(commandName)) { // partition-literal: kubeconfig exec command
|
||||
return false;
|
||||
}
|
||||
return findSubcommandIndex(exec.path("args")) >= 0;
|
||||
|
||||
@@ -366,7 +366,7 @@ public class SsmService implements ResourceProvider {
|
||||
private static void rejectReservedName(String name) {
|
||||
String bare = name == null ? "" : name.startsWith("/") ? name.substring(1) : name;
|
||||
String lower = bare.toLowerCase(Locale.ROOT);
|
||||
if (lower.equals("aws") || lower.equals("ssm")
|
||||
if (lower.equals("aws") || lower.equals("ssm") // partition-literal: reserved name prefix
|
||||
|| lower.startsWith("aws/") || lower.startsWith("ssm/")) {
|
||||
throw new AwsException("ValidationException",
|
||||
"Parameter name: can't be prefixed with \"aws\" or \"ssm\" (case-insensitive). "
|
||||
|
||||
Reference in new issue
Block a user