From 5c56ba1652eed4f4e65fb5bee1d2e82f5cd30a45 Mon Sep 17 00:00:00 2001 From: Tejaswi Salaigari Date: Fri, 6 Sep 2024 15:59:47 -0500 Subject: [PATCH] added NetworkSecurityPerimeterConfigurationNameParameter to exclusion list --- .../rulesets/generated/spectral/az-arm.js | 7 ++++- .../functions/resource-name-restriction.ts | 7 ++++- .../test/resource-names-restriction.test.ts | 29 +++++++++++++++++-- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/packages/rulesets/generated/spectral/az-arm.js b/packages/rulesets/generated/spectral/az-arm.js index dd34faf1..86287af9 100644 --- a/packages/rulesets/generated/spectral/az-arm.js +++ b/packages/rulesets/generated/spectral/az-arm.js @@ -2585,7 +2585,12 @@ const reservedResourceNamesModelAsEnum = (pathItem, _opts, ctx) => { return errors; }; -const EXCEPTION_LIST = ["resourceGroupName", "privateEndpointConnectionName", "managementGroupName"]; +const EXCEPTION_LIST = [ + "resourceGroupName", + "privateEndpointConnectionName", + "managementGroupName", + "networkSecurityPerimeterConfigurationName", +]; const resourceNameRestriction = (paths, _opts, ctx) => { if (paths === null || typeof paths !== "object") { return []; diff --git a/packages/rulesets/src/spectral/functions/resource-name-restriction.ts b/packages/rulesets/src/spectral/functions/resource-name-restriction.ts index 1ce9b665..e88c98cb 100644 --- a/packages/rulesets/src/spectral/functions/resource-name-restriction.ts +++ b/packages/rulesets/src/spectral/functions/resource-name-restriction.ts @@ -1,7 +1,12 @@ // Check conformance to Azure parameter naming conventions: //system-defined parameters => needs to be excluded from validation -const EXCEPTION_LIST = ["resourceGroupName", "privateEndpointConnectionName", "managementGroupName"] +const EXCEPTION_LIST = [ + "resourceGroupName", + "privateEndpointConnectionName", + "managementGroupName", + "networkSecurityPerimeterConfigurationName", +] export const resourceNameRestriction = (paths: any, _opts: any, ctx: any) => { if (paths === null || typeof paths !== "object") { return [] diff --git a/packages/rulesets/src/spectral/test/resource-names-restriction.test.ts b/packages/rulesets/src/spectral/test/resource-names-restriction.test.ts index 66934811..c405a83f 100644 --- a/packages/rulesets/src/spectral/test/resource-names-restriction.test.ts +++ b/packages/rulesets/src/spectral/test/resource-names-restriction.test.ts @@ -32,7 +32,7 @@ test("ResourceNameRestriction should find errors on path level", () => { return linter.run(oasDoc).then((results) => { expect(results.length).toBe(1) expect(results[0].path.join(".")).toBe( - "paths./subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/My.NS/foo/{fooName}" + "paths./subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/My.NS/foo/{fooName}", ) expect(results[0].message).toContain("The resource name parameter 'fooName' should be defined with a 'pattern' restriction.") }) @@ -61,7 +61,7 @@ test("ResourceNameRestriction should find errors on operation level", () => { return linter.run(oasDoc).then((results) => { expect(results.length).toBe(1) expect(results[0].path.join(".")).toBe( - "paths./subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/My.NS/foo/{fooName}" + "paths./subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/My.NS/foo/{fooName}", ) expect(results[0].message).toContain("The resource name parameter 'fooName' should be defined with a 'pattern' restriction.") }) @@ -138,6 +138,31 @@ test("ResourceNameRestriction should find no errors for system-defined variables responses: {}, }, }, + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/My.NS/foo/{fooName}/networkSecurityPerimeterConfiguration/{networkSecurityPerimeterConfigurationName}": + { + parameters: [ + { + name: "fooName", + in: "path", + required: true, + type: "string", + pattern: "[a-zA-Z_0-9]+", + "x-ms-parameter-location": "method", + }, + { + name: "networkSecurityPerimeterConfigurationName", + in: "path", + required: true, + type: "string", + description: "The name of the network security perimeter configuration associated with the Azure resource.", + "x-ms-parameter-location": "method", + }, + ], + get: { + parameters: [], + responses: {}, + }, + }, }, } return linter.run(oasDoc).then((results) => {