Skip to content

Commit

Permalink
change return value in case there is no Research Severity to the norm…
Browse files Browse the repository at this point in the history
…al severity score
  • Loading branch information
dortam888 committed Jul 15, 2024
1 parent 384e681 commit 26f0265
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions utils/resultstable.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const (
directDependencyPathLength = 2
nodeModules = "node_modules"
NpmPackageTypeIdentifier = "npm://"
noJfrogResearchInformation = -1
)

// PrintViolationsTable prints the violations in 4 tables: security violations, license compliance violations, operational risk violations and ignore rule URLs.
Expand Down Expand Up @@ -276,8 +275,8 @@ func sortVulnerabilityOrViolationRows(rows []formats.VulnerabilityOrViolationRow
if rows[i].Applicable != rows[j].Applicable {
return jasutils.ConvertApplicableToScore(rows[i].Applicable) > jasutils.ConvertApplicableToScore(rows[j].Applicable)
}
priorityI := getJfrogResearchPriority(rows[i].JfrogResearchInformation)
priorityJ := getJfrogResearchPriority(rows[j].JfrogResearchInformation)
priorityI := getJfrogResearchPriority(rows[i])
priorityJ := getJfrogResearchPriority(rows[j])
if priorityI != priorityJ {
return priorityI > priorityJ
}
Expand All @@ -286,13 +285,14 @@ func sortVulnerabilityOrViolationRows(rows []formats.VulnerabilityOrViolationRow
}

// getJfrogResearchPriority returns the score of JFrog Research Severity.
// If there is no such severity will return the const value noJfrogResearchInformation which is less than all possible scores
func getJfrogResearchPriority(jfrogResearchInformation *formats.JfrogResearchInformation) int {
if jfrogResearchInformation == nil {
return noJfrogResearchInformation
// If there is no such severity will return the normal severity score.
// When vulnerability with JFrog Reasearch to a vulnerability without we'll compare the JFrog Research Severity to the normal severity
func getJfrogResearchPriority(vulnerabilityOrViolation formats.VulnerabilityOrViolationRow) int {
if vulnerabilityOrViolation.JfrogResearchInformation == nil {
return vulnerabilityOrViolation.SeverityNumValue
}

return jfrogResearchInformation.SeverityNumValue
return vulnerabilityOrViolation.JfrogResearchInformation.SeverityNumValue
}

// PrintLicensesTable prints the licenses in a table.
Expand Down

0 comments on commit 26f0265

Please sign in to comment.