Skip to content

Commit

Permalink
Revert "Add new options to control resultWriter (#1047)"
Browse files Browse the repository at this point in the history
This reverts commit a5df3a0.
  • Loading branch information
yahavi authored Nov 30, 2023
1 parent 48419a7 commit e014ba6
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions xray/utils/resultwriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,14 @@ type ResultsWriter struct {
isMultipleRoots bool
// PrintExtended, If true, show extended results.
printExtended bool
// IncludeSecrets, If true, also include secrets results as part of the output.
includeSecrets bool
// WriteFullScanResults, If true, write the full scan results to a file.
writeFullScanResults bool
// The scanType (binary,dependency)
scanType services.ScanType
// Messages - Option array of messages, to be displayed if the format is Table
messages []string
}

func NewResultsWriter(scanResults *Results) *ResultsWriter {
return &ResultsWriter{results: scanResults, includeSecrets: true, writeFullScanResults: true}
return &ResultsWriter{results: scanResults}
}

func (rw *ResultsWriter) SetOutputFormat(format OutputFormat) *ResultsWriter {
Expand Down Expand Up @@ -91,11 +87,6 @@ func (rw *ResultsWriter) SetIncludeLicenses(licenses bool) *ResultsWriter {
return rw
}

func (rw *ResultsWriter) SetIncludeSecrets(includeSecrets bool) *ResultsWriter {
rw.includeSecrets = includeSecrets
return rw
}

func (rw *ResultsWriter) SetIsMultipleRootProject(isMultipleRootProject bool) *ResultsWriter {
rw.isMultipleRoots = isMultipleRootProject
return rw
Expand All @@ -109,11 +100,7 @@ func (rw *ResultsWriter) SetPrintExtendedTable(extendedTable bool) *ResultsWrite
func (rw *ResultsWriter) SetExtraMessages(messages []string) *ResultsWriter {
rw.messages = messages
return rw
}

func (rw *ResultsWriter) SetWriteFullScanResults(writeFullScanResults bool) *ResultsWriter {
rw.writeFullScanResults = writeFullScanResults
return rw
}

// PrintScanResults prints the scan results in the specified format.
Expand All @@ -138,7 +125,7 @@ func (rw *ResultsWriter) PrintScanResults() error {
func (rw *ResultsWriter) printScanResultsTables() (err error) {
printMessages(rw.messages)
violations, vulnerabilities, licenses := SplitScanResults(rw.results.ScaResults)
if rw.writeFullScanResults && rw.results.IsIssuesFound() {
if rw.results.IsIssuesFound() {
var resultsPath string
if resultsPath, err = writeJsonResults(rw.results); err != nil {
return
Expand All @@ -159,10 +146,8 @@ func (rw *ResultsWriter) printScanResultsTables() (err error) {
return
}
}
if rw.includeSecrets {
if err = PrintSecretsTable(rw.results.ExtendedScanResults.SecretsScanResults, rw.results.ExtendedScanResults.EntitledForJas); err != nil {
return
}
if err = PrintSecretsTable(rw.results.ExtendedScanResults.SecretsScanResults, rw.results.ExtendedScanResults.EntitledForJas); err != nil {
return
}
if err = PrintIacTable(rw.results.ExtendedScanResults.IacScanResults, rw.results.ExtendedScanResults.EntitledForJas); err != nil {
return
Expand Down

0 comments on commit e014ba6

Please sign in to comment.