Deprecate detect and protect. Add git, dir, stdin (#1504)

* init backwards compatible cmd

* update readme, todos

* ...

* moar comments, sprucing up root

* readme change
This commit is contained in:
Zachary Rice authored and GitHub committed 2024-09-13 19:44:22 -05:00
1 parent e93a7c0d26
commit 44ad62e0b1
7 files changed
+270 -64

No files matched your search

+2 -9
View File
@@ -30,7 +30,7 @@ const configDescription = `config file path
order of precedence:
1. --config/-c
2. env var GITLEAKS_CONFIG
3. (--source/-s)/.gitleaks.toml
3. (target path)/.gitleaks.toml
If none of the three options are used, then gitleaks will use the default config`
var rootCmd = &cobra.Command{
@@ -43,7 +43,6 @@ func init() {
cobra.OnInitialize(initLog)
rootCmd.PersistentFlags().StringP("config", "c", "", configDescription)
rootCmd.PersistentFlags().Int("exit-code", 1, "exit code when leaks have been encountered")
rootCmd.PersistentFlags().StringP("source", "s", ".", "path to source")
rootCmd.PersistentFlags().StringP("report-path", "r", "", "report file")
rootCmd.PersistentFlags().StringP("report-format", "f", "json", "output format (json, csv, junit, sarif)")
rootCmd.PersistentFlags().StringP("baseline-path", "b", "", "path to baseline with issues that can be ignored")
@@ -55,10 +54,8 @@ func init() {
rootCmd.PersistentFlags().Uint("redact", 0, "redact secrets from logs and stdout. To redact only parts of the secret just apply a percent value from 0..100. For example --redact=20 (default 100%)")
rootCmd.Flag("redact").NoOptDefVal = "100"
rootCmd.PersistentFlags().Bool("no-banner", false, "suppress banner")
rootCmd.PersistentFlags().String("log-opts", "", "git log options")
rootCmd.PersistentFlags().StringSlice("enable-rule", []string{}, "only enable specific rules by id, ex: `gitleaks detect --enable-rule=atlassian-api-token --enable-rule=slack-access-token`")
rootCmd.PersistentFlags().StringSlice("enable-rule", []string{}, "only enable specific rules by id")
rootCmd.PersistentFlags().StringP("gitleaks-ignore-path", "i", ".", "path to .gitleaksignore file or folder containing one")
rootCmd.PersistentFlags().Bool("follow-symlinks", false, "scan files that are symlinks to other files")
err := viper.BindPFlag("config", rootCmd.PersistentFlags().Lookup("config"))
if err != nil {
log.Fatal().Msgf("err binding config %s", err.Error())
@@ -261,10 +258,6 @@ func Detector(cmd *cobra.Command, cfg config.Config, source string) *detect.Dete
detector.Config.Rules = ruleOverride
}
// set follow symlinks flag
if detector.FollowSymlinks, err = cmd.Flags().GetBool("follow-symlinks"); err != nil {
log.Fatal().Err(err).Msg("")
}
return detector
}