Skip to content

Commit

Permalink
feat: update scoring logic
Browse files Browse the repository at this point in the history
Signed-off-by: deggja <[email protected]>
  • Loading branch information
deggja committed Aug 31, 2024
1 parent 2f34050 commit 0067c63
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ changelog:
regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$'
order: 0
- title: "Bug fixes"
regexp: '^.*?bug(\([[:word:]]+\))??!?:.+$'
regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$'
order: 1
- title: "Documentation Updates"
regexp: '^.*?docs(\([[:word:]]+\))??!?:.+$'
Expand Down
18 changes: 11 additions & 7 deletions backend/pkg/k8s/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,18 +397,22 @@ func IsSystemNamespace(namespace string) bool {

// Scoring logic
func CalculateScore(hasPolicies bool, hasDenyAll bool, unprotectedPodsCount int) int {
score := 42 // Start with the highest score
score := 50 // Start with a base score of 50

if !hasPolicies {
score -= 20
}
if hasDenyAll {
score += 20 // Add 20 points for having deny-all policies
} else if !hasPolicies {
score -= 20 // Subtract 20 points if there are no policies at all
}

// Deduct score based on the number of unprotected pods
score -= unprotectedPodsCount

if score < 1 {
score = 1 // Minimum score
}
if score > 100 {
score = 100
} else if score < 1 {
score = 1
}

return score
}
Expand Down

0 comments on commit 0067c63

Please sign in to comment.