mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-28 20:24:22 +01:00
feat: use STDOUT when report file not specified (#1642)
* feat: use STDOUT when report file not specified Signed-off-by: Bryce Thuilot <bryce@thuilot.io> * fix: update tests Signed-off-by: Bryce Thuilot <bryce@thuilot.io> * fix: use only '-' for stdout report Signed-off-by: Bryce Thuilot <bryce@thuilot.io> --------- Signed-off-by: Bryce Thuilot <bryce@thuilot.io>
This commit is contained in:
1 parent
ed205a5f63
commit
f3adda07ca
3 files changed
+33
-22
No files matched your search
+10
-1
@@ -283,8 +283,17 @@ func findingSummaryAndExit(findings []report.Finding, cmd *cobra.Command, cfg co
|
||||
// write report if desired
|
||||
reportPath, _ := cmd.Flags().GetString("report-path")
|
||||
ext, _ := cmd.Flags().GetString("report-format")
|
||||
|
||||
if reportPath != "" {
|
||||
if err := report.Write(findings, cfg, ext, reportPath); err != nil {
|
||||
reportWriter := os.Stdout
|
||||
if reportPath != "-" {
|
||||
reportWriter, err = os.Create(reportPath)
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("could not create report file")
|
||||
}
|
||||
}
|
||||
|
||||
if err = report.Write(findings, cfg, ext, reportWriter); err != nil {
|
||||
log.Fatal().Err(err).Msg("could not write")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user