From b1d59bf8905b3dae1b1f84afa76b0e7c6293d59e Mon Sep 17 00:00:00 2001 From: Zach Date: Tue, 13 Jun 2023 16:05:04 -0500 Subject: [PATCH] fix broken vet, format some stuff --- cmd/detect.go | 4 ++-- cmd/generate/config/rules/authress.go | 2 +- cmd/protect.go | 4 ++-- detect/detect.go | 4 ++-- detect/utils.go | 2 +- report/junit_test.go | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cmd/detect.go b/cmd/detect.go index 78524d1b..bcbe0f8e 100644 --- a/cmd/detect.go +++ b/cmd/detect.go @@ -20,7 +20,7 @@ func init() { detectCmd.Flags().Bool("no-git", false, "treat git repo as a regular directory and scan those files, --log-opts has no effect on the scan when --no-git is set") detectCmd.Flags().Bool("pipe", false, "scan input from stdin, ex: `cat some_file | gitleaks detect --pipe`") detectCmd.Flags().Bool("follow-symlinks", false, "scan files that are symlinks to other files") - detectCmd.Flags().StringP("gitleaks-ignore-path","i",".","path to .gitleaksignore file or folder containing one") + detectCmd.Flags().StringP("gitleaks-ignore-path", "i", ".", "path to .gitleaksignore file or folder containing one") } var detectCmd = &cobra.Command{ @@ -81,7 +81,7 @@ func runDetect(cmd *cobra.Command, args []string) { log.Fatal().Err(err).Msg("") } - gitleaksIgnorePath, err:= cmd.Flags().GetString("gitleaks-ignore-path") + gitleaksIgnorePath, err := cmd.Flags().GetString("gitleaks-ignore-path") if err != nil { log.Fatal().Err(err).Msg("could not get .gitleaksignore path") } diff --git a/cmd/generate/config/rules/authress.go b/cmd/generate/config/rules/authress.go index 1e701440..8db53366 100644 --- a/cmd/generate/config/rules/authress.go +++ b/cmd/generate/config/rules/authress.go @@ -13,7 +13,7 @@ func Authress() *config.Rule { Description: "Authress Service Client Access Key", RuleID: "authress-service-client-access-key", SecretGroup: 1, - Regex: generateUniqueTokenRegex(`(?:sc|ext|scauth|authress)_[a-z0-9]{5,30}\.[a-z0-9]{4,6}\.acc_[a-z0-9-]{10,32}\.[a-z0-9+/_=-]{30,120}`), + Regex: generateUniqueTokenRegex(`(?:sc|ext|scauth|authress)_[a-z0-9]{5,30}\.[a-z0-9]{4,6}\.acc_[a-z0-9-]{10,32}\.[a-z0-9+/_=-]{30,120}`), Keywords: []string{"sc_", "ext_", "scauth_", "authress_"}, } diff --git a/cmd/protect.go b/cmd/protect.go index af37519b..58e4ae22 100644 --- a/cmd/protect.go +++ b/cmd/protect.go @@ -17,7 +17,7 @@ import ( func init() { protectCmd.Flags().Bool("staged", false, "detect secrets in a --staged state") protectCmd.Flags().String("log-opts", "", "git log options") - protectCmd.Flags().StringP("gitleaks-ignore-path","i",".","path to .gitleaksignore file or folder containing one") + protectCmd.Flags().StringP("gitleaks-ignore-path", "i", ".", "path to .gitleaksignore file or folder containing one") rootCmd.AddCommand(protectCmd) } @@ -75,7 +75,7 @@ func runProtect(cmd *cobra.Command, args []string) { log.Fatal().Err(err).Msg("") } - gitleaksIgnorePath, err:= cmd.Flags().GetString("gitleaks-ignore-path") + gitleaksIgnorePath, err := cmd.Flags().GetString("gitleaks-ignore-path") if err != nil { log.Fatal().Err(err).Msg("could not get .gitleaksignore path") } diff --git a/detect/detect.go b/detect/detect.go index d56839c9..479c69bb 100644 --- a/detect/detect.go +++ b/detect/detect.go @@ -156,10 +156,10 @@ func (d *Detector) AddGitleaksIgnore(gitleaksIgnorePath string) error { // https://github.com/securego/gosec/issues/512 defer func() { - if err := file.Close(); err != nil { + if err := file.Close(); err != nil { log.Warn().Msgf("Error closing .gitleaksignore file: %s\n", err) } - }() + }() scanner := bufio.NewScanner(file) for scanner.Scan() { diff --git a/detect/utils.go b/detect/utils.go index 52ce0134..32454b18 100644 --- a/detect/utils.go +++ b/detect/utils.go @@ -101,7 +101,7 @@ func printFinding(f report.Finding, noColor bool) { skipColor := noColor finding := "" var secret lipgloss.Style - + // Matches from filenames do not have a |line| or |secret| if !isFileMatch { matchInLineIDX := strings.Index(f.Line, f.Match) diff --git a/report/junit_test.go b/report/junit_test.go index de59b66d..06c56659 100644 --- a/report/junit_test.go +++ b/report/junit_test.go @@ -65,7 +65,7 @@ func TestWriteJunit(t *testing.T) { for _, test := range tests { // create tmp file using os.TempDir() - tmpfile, err := os.Create(filepath.Join(tmpPath, test.testReportName+".xml")) + tmpfile, err := os.Create(filepath.Join(t.TempDir(), test.testReportName+".xml")) if err != nil { os.Remove(tmpfile.Name()) t.Error(err)