diff --git a/internal/scanners/apim/rules.go b/internal/scanners/apim/rules.go index 1b9f550c..aa6db6da 100644 --- a/internal/scanners/apim/rules.go +++ b/internal/scanners/apim/rules.go @@ -217,5 +217,17 @@ func (a *APIManagementScanner) GetRules() map[string]scanners.AzureRule { }, Url: "https://learn.microsoft.com/en-us/azure/api-management/configure-custom-domain?tabs=custom", }, + "apim-012": { + Id: "apim-012", + Category: scanners.RulesCategoryReliability, + Subcategory: scanners.RulesSubcategoryReliabilityReliability, + Description: "APIM: Migrate instance hosted on the stv1 platform to stv2", + Severity: scanners.SeverityHigh, + Eval: func(target interface{}, scanContext *scanners.ScanContext) (bool, string) { + c := target.(*armapimanagement.ServiceResource) + return *c.Properties.PlatformVersion == armapimanagement.PlatformVersionStv1, "" + }, + Url: "https://learn.microsoft.com/en-us/azure/api-management/migrate-stv1-to-stv2?tabs=portal", + }, } } diff --git a/internal/scanners/apim/rules_test.go b/internal/scanners/apim/rules_test.go index 9605bc5e..12ed0019 100644 --- a/internal/scanners/apim/rules_test.go +++ b/internal/scanners/apim/rules_test.go @@ -324,6 +324,38 @@ func TestAPIManagementScanner_Rules(t *testing.T) { result: "", }, }, + { + name: "APIManagementScanner stv1", + fields: fields{ + rule: "apim-012", + target: &armapimanagement.ServiceResource{ + Properties: &armapimanagement.ServiceProperties{ + PlatformVersion: ref.Of(armapimanagement.PlatformVersionStv1), + }, + }, + scanContext: &scanners.ScanContext{}, + }, + want: want{ + broken: true, + result: "", + }, + }, + { + name: "APIManagementScanner stv2", + fields: fields{ + rule: "apim-012", + target: &armapimanagement.ServiceResource{ + Properties: &armapimanagement.ServiceProperties{ + PlatformVersion: ref.Of(armapimanagement.PlatformVersionStv2), + }, + }, + scanContext: &scanners.ScanContext{}, + }, + want: want{ + broken: false, + result: "", + }, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {