Skip to content

Commit b99698b

Browse files
committed
docs: update cli call syntax and output format
1 parent 4f50db9 commit b99698b

File tree

11 files changed

+78
-17
lines changed

11 files changed

+78
-17
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ Available Commands:
8181

8282
Flags:
8383
--auth-basic-token string authentication token used to fetch remote repositories
84+
--concurrent int concurrent worker used to run analysus
8485
-c, --config string path to watchdog configuration file
8586
--docs-link string link to documentation
8687
-h, --help help for watchdog
@@ -90,7 +91,6 @@ Flags:
9091
--logs-format string logging level (default "json")
9192
--logs-level string logging level (default "info")
9293
--logs-path string path to logs (default "/var/log/watchdog/watchdog.log")
93-
--max-workers int coccurent worker used to run analysus
9494
--output string path to output file
9595
--output-format string report format (default "text")
9696
--plugins-directory string path to plugins directory (default "plugins")

cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func Execute(ctx context.Context) error {
2727
func init() {
2828
cobra.OnInitialize(initConfig)
2929
rootCommand.PersistentFlags().Bool("profile", false, "collect the profile to hercules.pprof.")
30-
rootCommand.PersistentFlags().Int("max-workers", 0, "coccurent worker used to run analysus")
30+
rootCommand.PersistentFlags().Int("concurrent", 0, "concurrent worker used to run analysus")
3131
rootCommand.PersistentFlags().Int("security.reveal-secrets", 0, "full or partial reveal of secrets in report and logs")
3232
rootCommand.PersistentFlags().String("auth-basic-token", "", "authentication token used to fetch remote repositories")
3333
rootCommand.PersistentFlags().String("hook-input", "", "standard input <old-value> SP <new-value> SP <ref-name> LF")

config/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ logs_level: info
3636
logs_format: json
3737
# logs path
3838
logs_path: /var/log/watchdog/watchdog.log
39-
# number of cocurrent worker user to run analysis
40-
max_workers: 8
39+
# number of cocurrent worker used to run analysis
40+
concurrent: 4
4141
# output file for analysis report
4242
output:
4343
# report format
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
$primary: #024BB0;
2+
$secondary: #FA5716;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
title: "Configuration"
3+
linkTitle: "Configuration"
4+
weight: 2
5+
description: >
6+
Learn how to configure Watchdog.
7+
---
8+
9+
Watchdog configuration uses the [YAML](https://yaml.org/) format.
10+
11+
The file to be edited can be found in:
12+
1. `/etc/watchdog/config.yaml` on \*nix systems when Watchdog is executed as root
13+
2. `~/.watchdog/config.yaml` on \*nix systems when Watchdog is executed as non-root
14+
2. `./config.yaml` on other systems
15+
16+
Configuration example:
17+
18+
```yaml
19+
concurrent: 4
20+
logs_level: "warning"
21+
```

docs/content/en/docs/deployment/gitlab.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ For a global deployment, you must create one of the `pre-receive.d`,` post-recei
2424
HOOKS=("pre-receive" "post-receive" "update")
2525
HOOK_TYPE=$(cd $(dirname "${BASH_SOURCE[0]}") >/dev/null 2>&1 && echo ${PWD##*/})
2626
while read -r OLDREV NEWREV REFNAME; do
27-
/usr/local/bin/watchdog \
27+
/usr/local/bin/watchdog analyze \
2828
--docs-link="https://groupe-edf.github.io/watchdog/docs/" \
2929
--hook-type="pre-receive" \
3030
--hook-input="$OLDREV $NEWREV $REFNAME" \

docs/content/en/docs/quickstart/output.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ remote: Operation took 43.319478ms
4343
Format
4444
--------------------
4545

46+
### logfmt
47+
4648
The default output format of the messages is [logfmt] (https://brandur.org/logfmt) prefixed by `GL-HOOK-ERR:` to have the possibility of uploading these messages on the Gitlab graphical interface in the case of a direct modification of the code on Gitlab.
4749

4850
```bash
@@ -55,4 +57,30 @@ severity=high handler=file condition=extension commit=eda373cc message="'*.exe'
5557
* **commit** The current hash of the commit (On 8 characters)
5658
* **message** Issue description
5759

58-
Only high severity issues block commits from being persisted in the Git repository.
60+
Only high severity issues block commits from being persisted in the Git repository.
61+
62+
### json
63+
```bash
64+
[
65+
{
66+
"author": "Habib MAALEM",
67+
"commit": "9560bbeb3b93d9a6d545133dea3e26e0f1fd7a66",
68+
"condition": "secret",
69+
"email": "[email protected]",
70+
"handler": "security",
71+
"leaks": [
72+
{
73+
"file": "src/main/resources/rsa_server.key",
74+
"line_number": 1,
75+
"rule": "ASYMMETRIC_PRIVATE_KEY",
76+
"severity": "MAJOR",
77+
"tags": [
78+
"key"
79+
]
80+
}
81+
],
82+
"message": "Secrets, token and passwords are forbidden, `src/main/resources/rsa_server.key:----***********************`",
83+
"severity": "low"
84+
}
85+
]
86+
```

docs/content/en/docs/quickstart/usage.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ On the developer side, to invoke customs hooks, the user must add a configuratio
1212

1313
``` bash
1414
$ ll /workspaces/project-name
15-
|--docs/
16-
|--src/
17-
|--tests/
18-
|--.gitignore
19-
|--.githooks.yml
15+
|__ docs/
16+
|__ src/
17+
|__ tests/
18+
|__ .gitignore
19+
|__ .githooks.yml
2020
```
2121

2222
.githooks.yml

internal/config/config.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ type Options struct {
3030
LogsPath string `mapstructure:"logs-path"`
3131
MaxFileSize uint
3232
MaxRepositorySize uint
33-
// MaxWorkers max workers running at the same time
34-
MaxWorkers int `mapstructure:"max-workers"`
33+
// Concurrent max workers running at the same time
34+
Concurrent int `mapstructure:"concurrent"`
3535
Output string `mapstructure:"output"`
3636
OutputFormat string `mapstructure:"output-format"`
3737
PluginsDirectory string `mapstructure:"plugins-directory"`
@@ -62,8 +62,8 @@ func (options *Options) Validate() error {
6262
if options.LogsPath == "" {
6363
options.LogsPath = LogsPath
6464
}
65-
if options.MaxWorkers == 0 {
66-
options.MaxWorkers = runtime.NumCPU()
65+
if options.Concurrent == 0 {
66+
options.Concurrent = runtime.NumCPU()
6767
}
6868
return nil
6969
}

internal/core/analyzer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (analyzer *Analyzer) Analyze(ctx context.Context, commitIter object.CommitI
3939
ctx, cancel := context.WithCancel(ctx)
4040
defer cancel()
4141
defer commitIter.Close()
42-
maxWorkers := make(chan struct{}, analyzer.Options.MaxWorkers)
42+
maxWorkers := make(chan struct{}, analyzer.Options.Concurrent)
4343
if len(analyzer.GitHooks.Hooks) > 0 {
4444
analyzer.Logger.WithFields(logging.Fields{
4545
"correlation_id": util.GetRequestID(ctx),

0 commit comments

Comments
 (0)