Skip to content

Commit

Permalink
added APIM platform version check
Browse files Browse the repository at this point in the history
  • Loading branch information
cmendible committed Jan 30, 2024
1 parent 913a794 commit 2e37166
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/scanners/apim/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
}
}
32 changes: 32 additions & 0 deletions internal/scanners/apim/rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 2e37166

Please sign in to comment.