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 advanced security fields to audit simple-json struct #944

Merged
merged 9 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions xray/utils/resultstable.go
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ func getApplicableCveValue(extendedResults *ExtendedScanResults, xrayCves []form
}
for _, relatedResult := range relatedResults {
cveExistsInResult = true
if isApplicableResult(relatedResult) {
if IsApplicableResult(relatedResult) {
return Applicable
}
}
Expand All @@ -943,7 +943,7 @@ func getCveApplicability(cve formats.CveRow, applicabilityScanResults []*sarif.R
}
// Set applicable details
applicability = &formats.Applicability{
Status: isApplicableResult(relatedResult),
Status: IsApplicableResult(relatedResult),
ScannerDescription: description,
}
// Add new evidences from locations
Expand Down
16 changes: 13 additions & 3 deletions xray/utils/sarifutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package utils

import (
"fmt"
"os"
"strconv"
"strings"

Expand Down Expand Up @@ -94,6 +95,9 @@ func GetDiffFromRun(sources []*sarif.Run, targets []*sarif.Run) (runWithNewOnly
if combinedSource == nil {
return
}
if len(targets) == 0 {
return combinedSource
}
combinedTarget := sarif.NewRunWithInformationURI(targets[0].Tool.Driver.Name, getRunInformationUri(targets[0]))
AggregateMultipleRunsIntoSingle(targets, combinedTarget)
if combinedTarget == nil {
Expand Down Expand Up @@ -340,9 +344,15 @@ func GetStartLocationInFile(location *sarif.Location) string {
}

func ExtractRelativePath(resultPath string, projectRoot string) string {
attiasas marked this conversation as resolved.
Show resolved Hide resolved
osFilePrefix := "file:///private/"
filePrefix := "file://"
relativePath := strings.ReplaceAll(strings.ReplaceAll(resultPath, projectRoot, ""), filePrefix, "")
return relativePath
resultPath = strings.ReplaceAll(resultPath, osFilePrefix, "")
resultPath = strings.TrimSuffix(strings.ReplaceAll(resultPath, filePrefix, ""), string(os.PathSeparator))
if resultPath == projectRoot {
return ""
}
s := strings.ReplaceAll(resultPath, projectRoot, "")
return s
}

func GetResultSeverity(result *sarif.Result) string {
Expand All @@ -361,7 +371,7 @@ func ConvertToSarifLevel(severity string) string {
return string(noneLevel)
}

func isApplicableResult(result *sarif.Result) bool {
func IsApplicableResult(result *sarif.Result) bool {
return !(result.Kind != nil && *result.Kind == "pass")
}

Expand Down
Loading