From f78c945a4aa0d3c52b3d15f565a6d2ad51fdef48 Mon Sep 17 00:00:00 2001 From: "Sascha L. Teichmann" Date: Mon, 28 Aug 2023 17:08:50 +0200 Subject: [PATCH] Fix downloader logging docs and some comments. --- cmd/csaf_downloader/config.go | 4 +-- cmd/csaf_downloader/forwarder.go | 2 +- cmd/csaf_downloader/main.go | 2 +- docs/csaf_downloader.md | 54 +++++++++++++++++--------------- 4 files changed, 32 insertions(+), 30 deletions(-) diff --git a/cmd/csaf_downloader/config.go b/cmd/csaf_downloader/config.go index e43686b8..e78e998a 100644 --- a/cmd/csaf_downloader/config.go +++ b/cmd/csaf_downloader/config.go @@ -77,7 +77,7 @@ type config struct { ForwardQueue int `long:"forwardqueue" description:"Maximal queue LENGTH before forwarder" value-name:"LENGTH" toml:"forward_queue"` ForwardInsecure bool `long:"forwardinsecure" description:"Do not check TLS certificates from forward endpoint" toml:"forward_insecure"` - LogFile string `long:"logfile" description:"FILE to log download to" value-name:"FILE" toml:"log_file"` + LogFile string `long:"logfile" description:"FILE to log downloading to" value-name:"FILE" toml:"log_file"` //lint:ignore SA5008 We are using choice or than once: debug, info, warn, error LogLevel logLevel `long:"loglevel" description:"LEVEL of logging details" value-name:"LEVEL" choice:"debug" choice:"info" choice:"warn" choice:"error" toml:"log_level"` @@ -173,7 +173,7 @@ func (ll logLevel) slogLevel() slog.Level { // prepareDirectory ensures that the working directory // exists and is setup properly. func (cfg *config) prepareDirectory() error { - // If no special given use current working directory. + // If not given use current working directory. if cfg.Directory == "" { dir, err := os.Getwd() if err != nil { diff --git a/cmd/csaf_downloader/forwarder.go b/cmd/csaf_downloader/forwarder.go index 6efdfbe2..da7ef7e9 100644 --- a/cmd/csaf_downloader/forwarder.go +++ b/cmd/csaf_downloader/forwarder.go @@ -130,7 +130,7 @@ func replaceExt(fname, nExt string) string { return fname[:len(fname)-len(ext)] + nExt } -// buildRequest creates an HTTP request suited ti forward the given advisory. +// buildRequest creates an HTTP request suited to forward the given advisory. func (f *forwarder) buildRequest( filename, doc string, status validationStatus, diff --git a/cmd/csaf_downloader/main.go b/cmd/csaf_downloader/main.go index 5840791c..e8563f09 100644 --- a/cmd/csaf_downloader/main.go +++ b/cmd/csaf_downloader/main.go @@ -50,7 +50,7 @@ func main() { options.ErrorCheck(cfg.prepare()) if len(domains) == 0 { - slog.Info("No domains given.") + slog.Warn("No domains given.") return } diff --git a/docs/csaf_downloader.md b/docs/csaf_downloader.md index e858cffa..122f5b15 100644 --- a/docs/csaf_downloader.md +++ b/docs/csaf_downloader.md @@ -7,34 +7,36 @@ A tool to download CSAF documents from CSAF providers. csaf_downloader [OPTIONS] domain... Application Options: - -d, --directory=DIR DIRectory to store the downloaded files in - --insecure Do not check TLS certificates from provider - --ignoresigcheck Ignore signature check results, just warn on mismatch - --client-cert=CERT-FILE TLS client certificate file (PEM encoded data) - --client-key=KEY-FILE TLS client private key file (PEM encoded data) - --client-passphrase=PASSPHRASE Optional passphrase for the client cert (limited, experimental, see doc) - --version Display version of the binary - -v, --verbose Verbose output - -n, --nostore Do not store files - -r, --rate= The average upper limit of https operations per second (defaults to - unlimited) - -w, --worker=NUM NUMber of concurrent downloads (default: 2) - -t, --timerange=RANGE RANGE of time from which advisories to download - -f, --folder=FOLDER Download into a given subFOLDER - -i, --ignorepattern=PATTERN Do not download files if their URLs match any of the given PATTERNs - -H, --header= One or more extra HTTP header fields - --validator=URL URL to validate documents remotely - --validatorcache=FILE FILE to cache remote validations - --validatorpreset=PRESETS One or more PRESETS to validate remotely (default: [mandatory]) - -m, --validationmode=MODE[strict|unsafe] MODE how strict the validation is (default: strict) - --forwardurl=URL URL of HTTP endpoint to forward downloads to - --forwardheader= One or more extra HTTP header fields used by forwarding - --forwardqueue=LENGTH Maximal queue LENGTH before forwarder - --forwardinsecure Do not check TLS certificates from forward endpoint - -c, --config=TOML-FILE Path to config TOML file + -d, --directory=DIR DIRectory to store the downloaded files in + --insecure Do not check TLS certificates from provider + --ignoresigcheck Ignore signature check results, just warn on mismatch + --client-cert=CERT-FILE TLS client certificate file (PEM encoded data) + --client-key=KEY-FILE TLS client private key file (PEM encoded data) + --client-passphrase=PASSPHRASE Optional passphrase for the client cert (limited, experimental, see doc) + --version Display version of the binary + -v, --verbose Verbose output + -n, --nostore Do not store files + -r, --rate= The average upper limit of https operations per second (defaults to + unlimited) + -w, --worker=NUM NUMber of concurrent downloads (default: 2) + -t, --timerange=RANGE RANGE of time from which advisories to download + -f, --folder=FOLDER Download into a given subFOLDER + -i, --ignorepattern=PATTERN Do not download files if their URLs match any of the given PATTERNs + -H, --header= One or more extra HTTP header fields + --validator=URL URL to validate documents remotely + --validatorcache=FILE FILE to cache remote validations + --validatorpreset=PRESETS One or more PRESETS to validate remotely (default: [mandatory]) + -m, --validationmode=MODE[strict|unsafe] MODE how strict the validation is (default: strict) + --forwardurl=URL URL of HTTP endpoint to forward downloads to + --forwardheader= One or more extra HTTP header fields used by forwarding + --forwardqueue=LENGTH Maximal queue LENGTH before forwarder (default: 5) + --forwardinsecure Do not check TLS certificates from forward endpoint + --logfile=FILE FILE to log downloading to (default: downloader.log) + --loglevel=LEVEL[debug|info|warn|error] LEVEL of logging details (default: info) + -c, --config=TOML-FILE Path to config TOML file Help Options: - -h, --help Show this help message + -h, --help Show this help message ``` Will download all CSAF documents for the given _domains_, by trying each as a CSAF provider.