Skip to content

Commit

Permalink
Fixed dec SLA and SKU rules
Browse files Browse the repository at this point in the history
  • Loading branch information
cmendible committed Dec 11, 2023
1 parent 3497b2f commit 26fbebb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
17 changes: 14 additions & 3 deletions internal/scanners/dec/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ func (a *DataExplorerScanner) GetRules() map[string]scanners.AzureRule {
Description: "Azure Data Explorer SLA",
Severity: scanners.SeverityHigh,
Eval: func(target interface{}, scanContext *scanners.ScanContext) (bool, string) {
return false, "99.99%"
c := target.(*armkusto.Cluster)
sla := "99.9%"
if c.SKU != nil && c.SKU.Name != nil && strings.HasPrefix(string(*c.SKU.Name), "Dev") {
sla = "None"
}

return sla == "None", sla
},
Url: "https://www.microsoft.com/licensing/docs/view/Service-Level-Agreements-SLA-for-Online-Services",
Field: scanners.OverviewFieldSLA,
Expand All @@ -43,11 +49,16 @@ func (a *DataExplorerScanner) GetRules() map[string]scanners.AzureRule {
Id: "dec-003",
Category: scanners.RulesCategoryReliability,
Subcategory: scanners.RulesSubcategoryReliabilitySKU,
Description: "Azure Data Explorer SKU",
Description: "Azure Data Explorer Production Cluster should not use Dev SKU",
Severity: scanners.SeverityHigh,
Eval: func(target interface{}, scanContext *scanners.ScanContext) (bool, string) {
c := target.(*armkusto.Cluster)
return false, string(*c.SKU.Name)
broken := false
if c.SKU != nil && c.SKU.Name != nil {
sku := string(*c.SKU.Name)
broken = strings.HasPrefix(sku, "Dev")
}
return broken, string(*c.SKU.Name)
},
Url: "https://learn.microsoft.com/en-us/azure/data-explorer/manage-cluster-choose-sku",
Field: scanners.OverviewFieldSKU,
Expand Down
26 changes: 23 additions & 3 deletions internal/scanners/dec/rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,36 @@ func TestDataExplorerScanner_Rules(t *testing.T) {
result: "",
},
},
{
name: "DataExplorerScanner SLA None",
fields: fields{
rule: "dec-002",
target: &armkusto.Cluster{
SKU: &armkusto.AzureSKU{
Name: ref.Of(armkusto.AzureSKUNameDevNoSLAStandardD11V2),
},
},
scanContext: &scanners.ScanContext{},
},
want: want{
broken: true,
result: "None",
},
},
{
name: "DataExplorerScanner SLA",
fields: fields{
rule: "dec-002",
target: &armkusto.Cluster{},
target: &armkusto.Cluster{
SKU: &armkusto.AzureSKU{
Name: ref.Of(armkusto.AzureSKUNameStandardD11V2),
},
},
scanContext: &scanners.ScanContext{},
},
want: want{
broken: false,
result: "99.99%",
result: "99.9%",
},
},
{
Expand All @@ -69,7 +89,7 @@ func TestDataExplorerScanner_Rules(t *testing.T) {
scanContext: &scanners.ScanContext{},
},
want: want{
broken: false,
broken: true,
result: "Dev(No SLA)_Standard_D11_v2",
},
},
Expand Down

0 comments on commit 26fbebb

Please sign in to comment.