Skip to content

Commit

Permalink
Added and fixed DisableLocalAuth rules
Browse files Browse the repository at this point in the history
  • Loading branch information
cmendible committed Jul 21, 2023
1 parent 792bd87 commit 3d36c1d
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 4 deletions.
3 changes: 2 additions & 1 deletion internal/scanners/appcs/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ func (a *AppConfigurationScanner) GetRules() map[string]scanners.AzureRule {
Severity: scanners.SeverityMedium,
Eval: func(target interface{}, scanContext *scanners.ScanContext) (bool, string) {
c := target.(*armappconfiguration.ConfigurationStore)
return c.Properties.DisableLocalAuth != nil && !*c.Properties.DisableLocalAuth, ""
localAuth := c.Properties.DisableLocalAuth != nil && *c.Properties.DisableLocalAuth
return !localAuth, ""
},
Url: "https://learn.microsoft.com/en-us/azure/azure-app-configuration/howto-disable-access-key-authentication?tabs=portal#disable-access-key-authentication",
},
Expand Down
13 changes: 13 additions & 0 deletions internal/scanners/cog/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,18 @@ func (a *CognitiveScanner) GetRules() map[string]scanners.AzureRule {
},
Url: "https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/tag-resources?tabs=json",
},
"cog-008": {
Id: "cog-008",
Category: scanners.RulesCategorySecurity,
Subcategory: scanners.RulesSubcategorySecurityIdentity,
Description: "Cognitive Service Account should have local authentication disabled",
Severity: scanners.SeverityMedium,
Eval: func(target interface{}, scanContext *scanners.ScanContext) (bool, string) {
c := target.(*armcognitiveservices.Account)
localAuth := c.Properties.DisableLocalAuth != nil && *c.Properties.DisableLocalAuth
return !localAuth, ""
},
Url: "https://learn.microsoft.com/en-us/azure/ai-services/policy-reference#azure-ai-services",
},
}
}
30 changes: 30 additions & 0 deletions internal/scanners/cog/rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,36 @@ func TestCognitiveScanner_Rules(t *testing.T) {
result: "",
},
},
{
name: "CognitiveScanner DisableLocalAuth nil",
fields: fields{
rule: "cog-008",
target: &armcognitiveservices.Account{
Properties: &armcognitiveservices.AccountProperties{},
},
scanContext: &scanners.ScanContext{},
},
want: want{
broken: true,
result: "",
},
},
{
name: "CognitiveScanner DisableLocalAuth true",
fields: fields{
rule: "cog-008",
target: &armcognitiveservices.Account{
Properties: &armcognitiveservices.AccountProperties{
DisableLocalAuth: to.BoolPtr(true),
},
},
scanContext: &scanners.ScanContext{},
},
want: want{
broken: false,
result: "",
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion internal/scanners/evgd/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ func (a *EventGridScanner) GetRules() map[string]scanners.AzureRule {
Severity: scanners.SeverityMedium,
Eval: func(target interface{}, scanContext *scanners.ScanContext) (bool, string) {
c := target.(*armeventgrid.Domain)
return c.Properties.DisableLocalAuth != nil && !*c.Properties.DisableLocalAuth, ""
localAuth := c.Properties.DisableLocalAuth != nil && *c.Properties.DisableLocalAuth
return !localAuth, ""
},
Url: "https://learn.microsoft.com/en-us/azure/event-grid/authenticate-with-access-keys-shared-access-signatures",
},
Expand Down
3 changes: 2 additions & 1 deletion internal/scanners/evh/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ func (a *EventHubScanner) GetRules() map[string]scanners.AzureRule {
Severity: scanners.SeverityMedium,
Eval: func(target interface{}, scanContext *scanners.ScanContext) (bool, string) {
c := target.(*armeventhub.EHNamespace)
return c.Properties.DisableLocalAuth != nil && !*c.Properties.DisableLocalAuth, ""
localAuth := c.Properties.DisableLocalAuth != nil && *c.Properties.DisableLocalAuth
return !localAuth, ""
},
Url: "https://learn.microsoft.com/en-us/azure/event-hubs/authorize-access-event-hubs#shared-access-signatures",
},
Expand Down
3 changes: 2 additions & 1 deletion internal/scanners/sb/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ func (a *ServiceBusScanner) GetRules() map[string]scanners.AzureRule {
Severity: scanners.SeverityMedium,
Eval: func(target interface{}, scanContext *scanners.ScanContext) (bool, string) {
c := target.(*armservicebus.SBNamespace)
return c.Properties.DisableLocalAuth != nil && !*c.Properties.DisableLocalAuth, ""
localAuth := c.Properties.DisableLocalAuth != nil && *c.Properties.DisableLocalAuth
return !localAuth, ""
},
Url: "https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-sas",
},
Expand Down

0 comments on commit 3d36c1d

Please sign in to comment.