Skip to content

Commit

Permalink
start to connect audit to diff
Browse files Browse the repository at this point in the history
  • Loading branch information
attiasas committed Feb 20, 2025
1 parent 038f777 commit e3b5bf1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions commands/audit/auditparams.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ type AuditParams struct {
configProfile *xscservices.ConfigProfile
scanResultsOutputDir string
startTime time.Time
// Diff mode, scan only the files affected by the diff.
filesToScan []string
}

func NewAuditParams() *AuditParams {
Expand Down Expand Up @@ -133,3 +135,12 @@ func (params *AuditParams) createXrayGraphScanParams() *services.XrayGraphScanPa
ScanType: services.Dependency,
}
}

func (params *AuditParams) SetFilesToScan(filesToScan []string) *AuditParams {
params.filesToScan = filesToScan
return params
}

func (params *AuditParams) FilesToScan() []string {
return params.filesToScan
}
1 change: 1 addition & 0 deletions commands/git/audit/gitaudit.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func toAuditParams(params GitAuditParams, changes *scm.ChangesRelevantToScan) *s
auditParams.SetThreads(params.threads).SetWorkingDirs([]string{params.repositoryLocalPath}).SetExclusions(params.exclusions).SetScansToPerform(params.scansToPerform)
if changedPaths := changes.GetChangedFilesPaths(); len(changedPaths) > 0 {
log.Debug(fmt.Sprintf("Diff targets: %v", changedPaths))
auditParams.SetFilesToScan(changedPaths)
}
// Output params
auditParams.SetOutputFormat(params.outputFormat)
Expand Down
2 changes: 1 addition & 1 deletion utils/scm/filediff.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func detectRelevantChanges(filePatches []goDiff.FilePatch) (changes ChangesRelev
return
}

func processFileChunksForRelevantChanges(fileChunks []goDiff.Chunk /*isNewFile*/, _ bool) (relevantChanges []Range) {
func processFileChunksForRelevantChanges(fileChunks []goDiff.Chunk, /*isNewFile*/_ bool) (relevantChanges []Range) {
// SARIF locations start at 1
row, col := 1, 1
for _, diffChunk := range fileChunks {
Expand Down

0 comments on commit e3b5bf1

Please sign in to comment.