Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add unassessed risk type and exit early for app risk statu… #626

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ func (r *Application) With(m *model.Application, tags []model.ApplicationTag) {
})
r.Effort = m.Analyses[len(m.Analyses)-1].Effort
}
r.Risk = assessment.RiskUnknown
r.Risk = assessment.RiskUnassessed
}

//
Expand Down
2 changes: 1 addition & 1 deletion api/archetype.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ func (r *Archetype) With(m *model.Archetype) {
ref.With(m.Review.ID, "")
r.Review = ref
}
r.Risk = assessment.RiskUnknown
r.Risk = assessment.RiskUnassessed
}

//
Expand Down
42 changes: 20 additions & 22 deletions assessment/pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import (
//
// Assessment risk
const (
RiskUnknown = "unknown"
RiskRed = "red"
RiskYellow = "yellow"
RiskGreen = "green"
RiskUnassessed = "unassessed"
RiskUnknown = "unknown"
RiskRed = "red"
RiskYellow = "yellow"
RiskGreen = "green"
)

//
Expand Down Expand Up @@ -48,26 +49,23 @@ const (
//
// Risk returns the single highest risk score for a group of assessments.
func Risk(assessments []Assessment) (risk string) {
risk = RiskUnknown
// Return "unassessed" immediately if there are no assessments
if len(assessments) == 0 {
return
return RiskUnassessed
}
red := 0
yellow := 0
unknown := 0
green := 0
if len(assessments) > 0 {
for _, a := range assessments {
switch a.Risk() {
case RiskRed:
red++
case RiskYellow:
yellow++
case RiskGreen:
green++
default:
unknown++
}

red, yellow, unknown, green := 0, 0, 0, 0

for _, a := range assessments {
switch a.Risk() {
case RiskRed:
red++
case RiskYellow:
yellow++
case RiskGreen:
green++
default:
unknown++
}
}

Expand Down
Loading