mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-30 21:24:21 +01:00
chore: tweak logging and readme for GITLEAKS_CONFIG_TOML feature (#1802)
This commit is contained in:
1 parent
a503b583ba
commit
e273a970a4
2 files changed
+19
-19
No files matched your search
@@ -229,23 +229,23 @@ your `.git/hooks/` directory.
|
|||||||
The order of precedence is:
|
The order of precedence is:
|
||||||
|
|
||||||
1. `--config/-c` option:
|
1. `--config/-c` option:
|
||||||
```bash
|
```bash
|
||||||
gitleaks git --config /home/dev/customgitleaks.toml .
|
gitleaks git --config /home/dev/customgitleaks.toml .
|
||||||
```
|
```
|
||||||
1. Environment variable `GITLEAKS_CONFIG` with the file path:
|
2. Environment variable `GITLEAKS_CONFIG` with the file path:
|
||||||
```bash
|
```bash
|
||||||
export GITLEAKS_CONFIG="/home/dev/customgitleaks.toml"
|
export GITLEAKS_CONFIG="/home/dev/customgitleaks.toml"
|
||||||
gitleaks git .
|
gitleaks git .
|
||||||
```
|
```
|
||||||
1. Environment variable `GITLEAKS_CONFIG_TOML` with the file content:
|
3. Environment variable `GITLEAKS_CONFIG_TOML` with the file content:
|
||||||
```bash
|
```bash
|
||||||
export GITLEAKS_CONFIG_TOML=`cat customgitleaks.toml`
|
export GITLEAKS_CONFIG_TOML=`cat customgitleaks.toml`
|
||||||
gitleaks git .
|
gitleaks git .
|
||||||
```
|
```
|
||||||
1. A `.gitleaks.toml` file within the target path:
|
4. A `.gitleaks.toml` file within the target path:
|
||||||
```bash
|
```bash
|
||||||
gitleaks git .
|
gitleaks git .
|
||||||
```
|
```
|
||||||
|
|
||||||
If none of the four options are used, then gitleaks will use the default config.
|
If none of the four options are used, then gitleaks will use the default config.
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -131,9 +131,9 @@ func initConfig(source string) {
|
|||||||
} else if os.Getenv("GITLEAKS_CONFIG_TOML") != "" {
|
} else if os.Getenv("GITLEAKS_CONFIG_TOML") != "" {
|
||||||
configContent := []byte(os.Getenv("GITLEAKS_CONFIG_TOML"))
|
configContent := []byte(os.Getenv("GITLEAKS_CONFIG_TOML"))
|
||||||
if err := viper.ReadConfig(bytes.NewBuffer(configContent)); err != nil {
|
if err := viper.ReadConfig(bytes.NewBuffer(configContent)); err != nil {
|
||||||
logging.Fatal().Msgf("unable to load gitleaks config from GITLEAKS_CONFIG_TOML env var content(%s), err: %s", configContent, err)
|
logging.Fatal().Err(err).Str("content", os.Getenv("GITLEAKS_CONFIG_TOML")).Msg("unable to load gitleaks config from GITLEAKS_CONFIG_TOML env var")
|
||||||
}
|
}
|
||||||
logging.Debug().Msgf("using gitleaks config from GITLEAKS_CONFIG_TOML env var content: %s", configContent)
|
logging.Debug().Str("content", os.Getenv("GITLEAKS_CONFIG_TOML")).Msg("using gitleaks config from GITLEAKS_CONFIG_TOML env var content")
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
fileInfo, err := os.Stat(source)
|
fileInfo, err := os.Stat(source)
|
||||||
|
|||||||
Reference in new issue
Block a user