fix: allow ALL ASN values in policy rule validation

This commit is contained in:
copilot-swe-agent[bot]
2026-06-16 23:44:35 +00:00
committed by GitHub
parent d6fe357fcb
commit 5e26ceaf02
3 changed files with 42 additions and 5 deletions

View File

@@ -1,4 +1,7 @@
import { isValidUrlGlobPattern } from "./validators";
import {
getResourceRuleValueValidationError,
isValidUrlGlobPattern
} from "./validators";
import { assertEquals } from "@test/assert";
function runTests() {
@@ -236,6 +239,28 @@ function runTests() {
"Path with isolated percent sign should be invalid"
);
// ASN validation tests
assertEquals(
getResourceRuleValueValidationError("ASN", "AS15169"),
null,
"Standard ASN should be valid"
);
assertEquals(
getResourceRuleValueValidationError("ASN", "ALL"),
null,
"ALL ASN selector should be valid"
);
assertEquals(
getResourceRuleValueValidationError("ASN", "AS0"),
null,
"AS0 alias should be valid"
);
assertEquals(
getResourceRuleValueValidationError("ASN", "not-an-asn"),
"Invalid ASN provided",
"Invalid ASN should return an error"
);
console.log("All tests passed!");
}

View File

@@ -100,7 +100,9 @@ export function getResourceRuleValueValidationError(
? null
: "Invalid country code provided";
case "ASN":
return /^AS\d+$/i.test(value.trim())
return /^AS\d+$/i.test(value.trim()) ||
value.trim().toUpperCase() === "ALL" ||
value.trim().toUpperCase() === "AS0"
? null
: "Invalid ASN provided";
default: