Skip to content

Commit

Permalink
Fixing issue #169
Browse files Browse the repository at this point in the history
  • Loading branch information
cmendible committed Dec 5, 2023
1 parent 433ec78 commit 0f78c04
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 9 deletions.
18 changes: 10 additions & 8 deletions internal/scanners/logic/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,21 @@ func (a *LogicAppScanner) GetRules() map[string]scanners.AzureRule {
service := target.(*armlogic.Workflow)
http := false
if service.Properties.Definition != nil {
triggers := service.Properties.Definition.(map[string]interface{})["triggers"].(map[string]interface{})
for _, t := range triggers {
trigger := t.(map[string]interface{})
if trigger["type"] == "Request" && trigger["kind"] == "Http" {
http = true
break
}
triggers, ok := service.Properties.Definition.(map[string]interface{})["triggers"]
if ok {
for _, t := range triggers.(map[string]interface{}) {
trigger := t.(map[string]interface{})
if trigger["type"] == "Request" && trigger["kind"] == "Http" {
http = true
break
}
}
}
}

broken := http

if http && service.Properties.AccessControl != nil && service.Properties.AccessControl.Triggers == nil {
if http && service.Properties.AccessControl != nil && service.Properties.AccessControl.Triggers != nil {
broken = len(service.Properties.AccessControl.Triggers.AllowedCallerIPAddresses) == 0
}
return broken, ""
Expand Down
60 changes: 59 additions & 1 deletion internal/scanners/logic/rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,37 @@ func TestLogicAppScanner_Rules(t *testing.T) {
},
},
{
name: "LogicAppScanner Limit Http Triggers",
name: "LogicAppScanner No Http Triggers",
fields: fields{
rule: "logic-004",
target: &armlogic.Workflow{
ID: ref.Of("test"),
Properties: &armlogic.WorkflowProperties{
Definition: map[string]interface{}{},
},
},
scanContext: &scanners.ScanContext{},
},
want: want{
broken: false,
result: "",
},
},
{
name: "LogicAppScanner Limit Http Triggers without access control",
fields: fields{
rule: "logic-004",
target: &armlogic.Workflow{
ID: ref.Of("test"),
Properties: &armlogic.WorkflowProperties{
Definition: map[string]interface{}{
"triggers": map[string]interface{}{
"trigger1": map[string]interface{}{
"type": "Request",
"kind": "Http",
},
},
},
AccessControl: &armlogic.FlowAccessControlConfiguration{
Triggers: &armlogic.FlowAccessControlConfigurationPolicy{
AllowedCallerIPAddresses: []*armlogic.IPAddressRange{},
Expand All @@ -61,6 +86,39 @@ func TestLogicAppScanner_Rules(t *testing.T) {
},
scanContext: &scanners.ScanContext{},
},
want: want{
broken: true,
result: "",
},
},
{
name: "LogicAppScanner Limit Http Triggers",
fields: fields{
rule: "logic-004",
target: &armlogic.Workflow{
ID: ref.Of("test"),
Properties: &armlogic.WorkflowProperties{
Definition: map[string]interface{}{
"triggers": map[string]interface{}{
"trigger1": map[string]interface{}{
"type": "Request",
"kind": "Http",
},
},
},
AccessControl: &armlogic.FlowAccessControlConfiguration{
Triggers: &armlogic.FlowAccessControlConfigurationPolicy{
AllowedCallerIPAddresses: []*armlogic.IPAddressRange{
{
AddressRange : ref.Of("127.0.0.1/32"),
},
},
},
},
},
},
scanContext: &scanners.ScanContext{},
},
want: want{
broken: false,
result: "",
Expand Down

0 comments on commit 0f78c04

Please sign in to comment.