Skip to content

Commit

Permalink
If there's no operation level security, check the global security for…
Browse files Browse the repository at this point in the history
… nullable items
  • Loading branch information
TheTeaCat authored and daveshanley committed Jan 30, 2024
1 parent 48454e6 commit 527aec2
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions functions/owasp/check_security.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,25 @@ func (cd CheckSecurity) RunRule(nodes []*yaml.Node, context model.RuleFunctionCo
}
}
}

if !nullable && opValue.Security == nil && len(globalSecurity) >= 1 {
for i := range globalSecurity {
if globalSecurity[i].Value.Requirements == nil || globalSecurity[i].Value.Requirements.Len() <= 0 {
securityNode := globalSecurity[i].Value.GoLow().Requirements.ValueNode
result := model.RuleFunctionResult{
Message: vacuumUtils.SuppliedOrDefault(context.Rule.Message,
fmt.Sprintf("`security` has null elements for path `%s` in method `%s`", path, opType)),
StartNode: securityNode,
EndNode: securityNode,
Path: globalSecurity[i].GenerateJSONPath(),
Rule: context.Rule,
}
pathItem.AddRuleFunctionResult(base.ConvertRuleResult(&result))
results = append(results, result)
continue
}
}
}
}
}
}
Expand Down

0 comments on commit 527aec2

Please sign in to comment.