Skip to content

Commit 2787ae4

Browse files
authored
Modify rule TenantLevelAPIsNotAllowed RPC-Uri-V1-11 from ARM error to warning (#783)
* Modified rule TenantLevelAPIsNotAllowed RPC-Uri-V1-11 to be a warning
1 parent 21c0234 commit 2787ae4

File tree

8 files changed

+30
-29
lines changed

8 files changed

+30
-29
lines changed

docs/rules.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -942,12 +942,6 @@ For more detail, pls refer to https://github.com/microsoft/api-guidelines/blob/v
942942

943943
Please refer to [path-resource-type-name-camel-case.md](./path-resource-type-name-camel-case.md) for details.
944944

945-
### Post201Response
946-
947-
Using post for a create operation is discouraged.
948-
949-
Please refer to [post201-response.md](./post201-response.md) for details.
950-
951945
### PostOperationIdContainsUrlVerb
952946

953947
A POST operation's operationId should contain the verb indicated at the end of the corresponding url.
@@ -962,6 +956,12 @@ Long-running POST operations must have responses with 202 and default return cod
962956

963957
Please refer to [post-response-codes.md](./post-response-codes.md) for details.
964958

959+
### Post201Response
960+
961+
Using post for a create operation is discouraged.
962+
963+
Please refer to [post201-response.md](./post201-response.md) for details.
964+
965965
### PreviewVersionOverOneYear
966966

967967
Per [Retirement-of-Previews](https://dev.azure.com/msazure/AzureWiki/_wiki/wikis/AzureWiki.wiki/37683/Retirement-of-Previews), service, feature, API, and SKU in preview for over one year need to move to GA or retire.
@@ -1246,7 +1246,7 @@ Please refer to [tags-are-not-allowed-for-proxy-resources.md](./tags-are-not-all
12461246

12471247
### TenantLevelAPIsNotAllowed
12481248

1249-
Tenant level APIs are strongly discouraged and subscription or resource group level APIs are preferred instead. The reason for this guidance is that tenant level APIs have a really broad scope and blast radius. We permit APIs to be at this broad scope under rare conditions. Some ARM feature sets also do not cover tenant level APIs such as the use of AFEC. Additionally, if you intend to bypass the standard RBAC constructs and make the APIs unauthorized, you will need an approval from the PAS team before the open API spec can be merged.
1249+
This rule checks for the tenant level APIs.
12501250

12511251
Please refer to [tenant-level-apis-not-allowed.md](./tenant-level-apis-not-allowed.md) for details.
12521252

docs/tenant-level-apis-not-allowed.md

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Category
44

5-
ARM Error
5+
ARM Warning
66

77
## Applies to
88

@@ -14,22 +14,11 @@ ARM OpenAPI(swagger) specs
1414

1515
## Description
1616

17-
Tenant level APIs are strongly discouraged and subscription or resource group level APIs are preferred instead. The reason for this guidance is that tenant level APIs have a really broad scope and blast radius. We permit APIs to be at this broad scope under rare conditions. Some ARM feature sets also do not cover tenant level APIs such as the use of AFEC. Additionally, if you intend to bypass the standard RBAC constructs and make the APIs unauthorized, you will need an approval from the PAS team before the open API spec can be merged.
17+
This rule checks for the tenant level APIs.
1818

1919
## How to fix the violation
2020

21-
The error can be fixed in one of the following two ways
22-
23-
1. Do not define tenant level APIs
24-
2. Address both the sub sections below
25-
26-
1. Provide a justification as to why you need the APIs to have the broad tenant scope to the ARM API reviewer. To do this, please attend the ARM API review office hours to have a conversation with the ARM API reviewer. To book a slot, please visit aka.ms\armofficehoursinfo.
27-
28-
2. In addition to modeling the API at the tenant scope, if you also intend to add the API to the "allowUnauthorizedActions" list in your ARM manifest, you must present your design and get an exception from the PAS team. Once you get an approval, please share the evidence of the approval by dropping a screenshot of the written approval as a comment on the PR. Please proceed by adding a suppression for the linter error indicating that the exception has been approved by the PAS team. If you do not intend to add the API to the "allowUnauthorizedActions" list in your ARM manifest, please add a suppression indicating the same.
29-
30-
Please use the following guidance to add a suppression - https://github.com/Azure/autorest/blob/main/docs/generate/suppress-warnings.md#suppress-warnings
31-
32-
To get an approval from PAS, please book their office hours slot at https://aka.ms/azurerbacofficehours . You will have to present the scenario and explain why the API needs to be unauthorized. If the service team would like to reach out over email, they can send an email to [email protected]
21+
Tenant level APIs are strongly discouraged and subscription or resource group level APIs are preferred instead. Please note that these APIs require a review from the security RBAC team during manifest check-in. For details, refer to the Manifest security review process: https://eng.ms/docs/microsoft-security/identity/auth-authz/access-control-managed-identityacmi/policy-administration-service/pas-wiki/livesite/security/manifest
3322

3423
## Good Examples
3524

packages/rulesets/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Change Log - @microsoft.azure/openapi-validator-rulesets
22

3+
## 2.1.8
4+
5+
### Patches
6+
7+
- Modified the rule TenantLevelAPIsNotAllowed RPC-Uri-V1-11 from error to warning
8+
9+
## 2.1.7
10+
11+
### Patches
12+
13+
- Updated autorest package.json to 2.2.4
14+
-
315
## 2.1.6
416

517
### Patches

packages/rulesets/generated/spectral/az-arm.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2978,7 +2978,7 @@ const tenantLevelAPIsNotAllowed = (pathItems, _opts, ctx) => {
29782978
for (const apiPath of apiPaths) {
29792979
if (pathItems[apiPath]["put"] && !apiPath.endsWith("/operations") && apiPath.startsWith("/providers")) {
29802980
errors.push({
2981-
message: `${apiPath} is a tenant level api. Tenant level APIs are strongly discouraged and subscription or resource group level APIs are preferred instead. If you cannot model your APIs at these levels, you will need to present your design and get an exception from PAS team.`,
2981+
message: `${apiPath} is a tenant level api. Tenant level APIs are strongly discouraged and subscription or resource group level APIs are preferred instead. Please note that these APIs require a review from the security RBAC team during manifest check-in. For details, refer to the Manifest security review process: https://eng.ms/docs/microsoft-security/identity/auth-authz/access-control-managed-identityacmi/policy-administration-service/pas-wiki/livesite/security/manifest`,
29822982
path: [...path, apiPath],
29832983
});
29842984
break;
@@ -3976,9 +3976,9 @@ const ruleset = {
39763976
},
39773977
TenantLevelAPIsNotAllowed: {
39783978
rpcGuidelineCode: "RPC-Uri-V1-11",
3979-
description: "Tenant level APIs are strongly discouraged and subscription or resource group level APIs are preferred instead. Design presentation and getting an exception from the PAS team is needed if APIs cannot be modelled at subscription or resource group level.",
3979+
description: "Tenant level APIs require a review from the security RBAC team during manifest check-in. For details, refer to the Manifest security review process: https://eng.ms/docs/microsoft-security/identity/auth-authz/access-control-managed-identityacmi/policy-administration-service/pas-wiki/livesite/security/manifest",
39803980
message: "{{error}}",
3981-
severity: "error",
3981+
severity: "warn",
39823982
resolved: true,
39833983
formats: [oas2],
39843984
given: "$[paths,'x-ms-paths']",

packages/rulesets/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@microsoft.azure/openapi-validator-rulesets",
3-
"version": "2.1.7",
3+
"version": "2.1.8",
44
"description": "Azure OpenAPI Validator",
55
"main": "dist/index.js",
66
"scripts": {

packages/rulesets/src/spectral/az-arm.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -950,9 +950,9 @@ const ruleset: any = {
950950
TenantLevelAPIsNotAllowed: {
951951
rpcGuidelineCode: "RPC-Uri-V1-11",
952952
description:
953-
"Tenant level APIs are strongly discouraged and subscription or resource group level APIs are preferred instead. Design presentation and getting an exception from the PAS team is needed if APIs cannot be modelled at subscription or resource group level.",
953+
"Tenant level APIs require a review from the security RBAC team during manifest check-in. For details, refer to the Manifest security review process: https://eng.ms/docs/microsoft-security/identity/auth-authz/access-control-managed-identityacmi/policy-administration-service/pas-wiki/livesite/security/manifest",
954954
message: "{{error}}",
955-
severity: "error",
955+
severity: "warn",
956956
resolved: true,
957957
formats: [oas2],
958958
given: "$[paths,'x-ms-paths']",

packages/rulesets/src/spectral/functions/tenant-level-apis-not-allowed.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const tenantLevelAPIsNotAllowed = (pathItems: any, _opts: any, ctx: any)
1717
for (const apiPath of apiPaths) {
1818
if (pathItems[apiPath]["put"] && !apiPath.endsWith("/operations") && apiPath.startsWith("/providers")) {
1919
errors.push({
20-
message: `${apiPath} is a tenant level api. Tenant level APIs are strongly discouraged and subscription or resource group level APIs are preferred instead. If you cannot model your APIs at these levels, you will need to present your design and get an exception from PAS team.`,
20+
message: `${apiPath} is a tenant level api. Tenant level APIs are strongly discouraged and subscription or resource group level APIs are preferred instead. Please note that these APIs require a review from the security RBAC team during manifest check-in. For details, refer to the Manifest security review process: https://eng.ms/docs/microsoft-security/identity/auth-authz/access-control-managed-identityacmi/policy-administration-service/pas-wiki/livesite/security/manifest`,
2121
path: [...path, apiPath],
2222
})
2323
break

packages/rulesets/src/spectral/test/tenant-level-apis-not-allowed.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Spectral } from "@stoplight/spectral-core"
22
import linterForRule from "./utils"
33

44
const ERROR_MESSAGE =
5-
"is a tenant level api. Tenant level APIs are strongly discouraged and subscription or resource group level APIs are preferred instead. If you cannot model your APIs at these levels, you will need to present your design and get an exception from PAS team."
5+
"is a tenant level api. Tenant level APIs are strongly discouraged and subscription or resource group level APIs are preferred instead. Please note that these APIs require a review from the security RBAC team during manifest check-in. For details, refer to the Manifest security review process: https://eng.ms/docs/microsoft-security/identity/auth-authz/access-control-managed-identityacmi/policy-administration-service/pas-wiki/livesite/security/manifest"
66

77
let linter: Spectral
88

0 commit comments

Comments
 (0)