Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: move log level and debug flags to General #1257

Merged
merged 4 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/_data/bearer_ignore_add.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ options:
- name: config-file
default_value: bearer.yml
usage: Load configuration from the specified path.
- name: debug
default_value: "false"
usage: Enable debug logs. Equivalent to --log-level=debug
- name: debug-profile
default_value: "false"
usage: Generate profiling data for debugging
Expand All @@ -35,6 +38,9 @@ options:
- name: host
default_value: my.bearer.sh
usage: Specify the Host for sending the report.
- name: log-level
default_value: info
usage: Set log level (error, info, debug, trace)
- name: no-color
default_value: "false"
usage: Disable color in output
Expand Down
6 changes: 6 additions & 0 deletions docs/_data/bearer_ignore_migrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ options:
- name: config-file
default_value: bearer.yml
usage: Load configuration from the specified path.
- name: debug
default_value: "false"
usage: Enable debug logs. Equivalent to --log-level=debug
- name: debug-profile
default_value: "false"
usage: Generate profiling data for debugging
Expand All @@ -27,6 +30,9 @@ options:
- name: host
default_value: my.bearer.sh
usage: Specify the Host for sending the report.
- name: log-level
default_value: info
usage: Set log level (error, info, debug, trace)
- name: no-color
default_value: "false"
usage: Disable color in output
Expand Down
6 changes: 6 additions & 0 deletions docs/_data/bearer_ignore_remove.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ options:
- name: config-file
default_value: bearer.yml
usage: Load configuration from the specified path.
- name: debug
default_value: "false"
usage: Enable debug logs. Equivalent to --log-level=debug
- name: debug-profile
default_value: "false"
usage: Generate profiling data for debugging
Expand All @@ -23,6 +26,9 @@ options:
- name: host
default_value: my.bearer.sh
usage: Specify the Host for sending the report.
- name: log-level
default_value: info
usage: Set log level (error, info, debug, trace)
- name: no-color
default_value: "false"
usage: Disable color in output
Expand Down
6 changes: 6 additions & 0 deletions docs/_data/bearer_ignore_show.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ options:
- name: config-file
default_value: bearer.yml
usage: Load configuration from the specified path.
- name: debug
default_value: "false"
usage: Enable debug logs. Equivalent to --log-level=debug
- name: debug-profile
default_value: "false"
usage: Generate profiling data for debugging
Expand All @@ -26,6 +29,9 @@ options:
- name: host
default_value: my.bearer.sh
usage: Specify the Host for sending the report.
- name: log-level
default_value: info
usage: Set log level (error, info, debug, trace)
- name: no-color
default_value: "false"
usage: Disable color in output
Expand Down
2 changes: 1 addition & 1 deletion e2e/flags/.snapshots/TestInitCommand
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
disable-version-check: false
log-level: info
report:
format: ""
no-color: false
Expand All @@ -18,7 +19,6 @@ scan:
external-rule-dir: []
force: false
internal-domains: []
log-level: info
parallel: 0
quiet: false
scanner:
Expand Down
4 changes: 2 additions & 2 deletions e2e/flags/.snapshots/TestMetadataFlags-help-scan
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ Rule Flags
Scan Flags
--context string Expand context of schema classification e.g., --context=health, to include data types particular to health
--data-subject-mapping string Override default data subject mapping by providing a path to a custom mapping JSON file
--debug Enable debug logs. Equivalent to --log-level=debug
--disable-domain-resolution Do not attempt to resolve detected domains during classification (default true)
--domain-resolution-timeout duration Set timeout when attempting to resolve detected domains during classification, e.g. --domain-resolution-timeout=3s (default 3s)
--exit-code int Force a given exit code for the scan command. Set this to 0 (success) to always return a success exit code despite any findings from the scan. (default -1)
--external-rule-dir strings Specify directories paths that contain .yaml files with external rules configuration
--force Disable the cache and runs the detections again
--internal-domains strings Define regular expressions for better classification of private or unreachable domains e.g. --internal-domains=".*.my-company.com,private.sh"
--log-level string Set log level (error, info, debug, trace) (default "info")
--parallel int Specify the amount of parallelism to use during the scan
--quiet Suppress non-essential messages
--scanner strings Specify which scanner to use e.g. --scanner=secrets, --scanner=secrets,sast (default [sast])
Expand All @@ -39,7 +37,9 @@ Scan Flags
General Flags
--bearer-ignore-file string Load bearer.ignore file from the specified path. (default "bearer.ignore")
--config-file string Load configuration from the specified path. (default "bearer.yml")
--debug Enable debug logs. Equivalent to --log-level=debug
--disable-version-check Disable Bearer version checking
--log-level string Set log level (error, info, debug, trace) (default "info")
--no-color Disable color in output


Expand Down
4 changes: 2 additions & 2 deletions e2e/flags/.snapshots/TestMetadataFlags-scan-help
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ Rule Flags
Scan Flags
--context string Expand context of schema classification e.g., --context=health, to include data types particular to health
--data-subject-mapping string Override default data subject mapping by providing a path to a custom mapping JSON file
--debug Enable debug logs. Equivalent to --log-level=debug
--disable-domain-resolution Do not attempt to resolve detected domains during classification (default true)
--domain-resolution-timeout duration Set timeout when attempting to resolve detected domains during classification, e.g. --domain-resolution-timeout=3s (default 3s)
--exit-code int Force a given exit code for the scan command. Set this to 0 (success) to always return a success exit code despite any findings from the scan. (default -1)
--external-rule-dir strings Specify directories paths that contain .yaml files with external rules configuration
--force Disable the cache and runs the detections again
--internal-domains strings Define regular expressions for better classification of private or unreachable domains e.g. --internal-domains=".*.my-company.com,private.sh"
--log-level string Set log level (error, info, debug, trace) (default "info")
--parallel int Specify the amount of parallelism to use during the scan
--quiet Suppress non-essential messages
--scanner strings Specify which scanner to use e.g. --scanner=secrets, --scanner=secrets,sast (default [sast])
Expand All @@ -39,7 +37,9 @@ Scan Flags
General Flags
--bearer-ignore-file string Load bearer.ignore file from the specified path. (default "bearer.ignore")
--config-file string Load configuration from the specified path. (default "bearer.yml")
--debug Enable debug logs. Equivalent to --log-level=debug
--disable-version-check Disable Bearer version checking
--log-level string Set log level (error, info, debug, trace) (default "info")
--no-color Disable color in output


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ Rule Flags
Scan Flags
--context string Expand context of schema classification e.g., --context=health, to include data types particular to health
--data-subject-mapping string Override default data subject mapping by providing a path to a custom mapping JSON file
--debug Enable debug logs. Equivalent to --log-level=debug
--disable-domain-resolution Do not attempt to resolve detected domains during classification (default true)
--domain-resolution-timeout duration Set timeout when attempting to resolve detected domains during classification, e.g. --domain-resolution-timeout=3s (default 3s)
--exit-code int Force a given exit code for the scan command. Set this to 0 (success) to always return a success exit code despite any findings from the scan. (default -1)
--external-rule-dir strings Specify directories paths that contain .yaml files with external rules configuration
--force Disable the cache and runs the detections again
--internal-domains strings Define regular expressions for better classification of private or unreachable domains e.g. --internal-domains=".*.my-company.com,private.sh"
--log-level string Set log level (error, info, debug, trace) (default "info")
--parallel int Specify the amount of parallelism to use during the scan
--quiet Suppress non-essential messages
--scanner strings Specify which scanner to use e.g. --scanner=secrets, --scanner=secrets,sast (default [sast])
Expand All @@ -40,7 +38,9 @@ Scan Flags
General Flags
--bearer-ignore-file string Load bearer.ignore file from the specified path. (default "bearer.ignore")
--config-file string Load configuration from the specified path. (default "bearer.yml")
--debug Enable debug logs. Equivalent to --log-level=debug
--disable-version-check Disable Bearer version checking
--log-level string Set log level (error, info, debug, trace) (default "info")
--no-color Disable color in output


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ Rule Flags
Scan Flags
--context string Expand context of schema classification e.g., --context=health, to include data types particular to health
--data-subject-mapping string Override default data subject mapping by providing a path to a custom mapping JSON file
--debug Enable debug logs. Equivalent to --log-level=debug
--disable-domain-resolution Do not attempt to resolve detected domains during classification (default true)
--domain-resolution-timeout duration Set timeout when attempting to resolve detected domains during classification, e.g. --domain-resolution-timeout=3s (default 3s)
--exit-code int Force a given exit code for the scan command. Set this to 0 (success) to always return a success exit code despite any findings from the scan. (default -1)
--external-rule-dir strings Specify directories paths that contain .yaml files with external rules configuration
--force Disable the cache and runs the detections again
--internal-domains strings Define regular expressions for better classification of private or unreachable domains e.g. --internal-domains=".*.my-company.com,private.sh"
--log-level string Set log level (error, info, debug, trace) (default "info")
--parallel int Specify the amount of parallelism to use during the scan
--quiet Suppress non-essential messages
--scanner strings Specify which scanner to use e.g. --scanner=secrets, --scanner=secrets,sast (default [sast])
Expand All @@ -40,7 +38,9 @@ Scan Flags
General Flags
--bearer-ignore-file string Load bearer.ignore file from the specified path. (default "bearer.ignore")
--config-file string Load configuration from the specified path. (default "bearer.yml")
--debug Enable debug logs. Equivalent to --log-level=debug
--disable-version-check Disable Bearer version checking
--log-level string Set log level (error, info, debug, trace) (default "info")
--no-color Disable color in output


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ Rule Flags
Scan Flags
--context string Expand context of schema classification e.g., --context=health, to include data types particular to health
--data-subject-mapping string Override default data subject mapping by providing a path to a custom mapping JSON file
--debug Enable debug logs. Equivalent to --log-level=debug
--disable-domain-resolution Do not attempt to resolve detected domains during classification (default true)
--domain-resolution-timeout duration Set timeout when attempting to resolve detected domains during classification, e.g. --domain-resolution-timeout=3s (default 3s)
--exit-code int Force a given exit code for the scan command. Set this to 0 (success) to always return a success exit code despite any findings from the scan. (default -1)
--external-rule-dir strings Specify directories paths that contain .yaml files with external rules configuration
--force Disable the cache and runs the detections again
--internal-domains strings Define regular expressions for better classification of private or unreachable domains e.g. --internal-domains=".*.my-company.com,private.sh"
--log-level string Set log level (error, info, debug, trace) (default "info")
--parallel int Specify the amount of parallelism to use during the scan
--quiet Suppress non-essential messages
--scanner strings Specify which scanner to use e.g. --scanner=secrets, --scanner=secrets,sast (default [sast])
Expand All @@ -40,7 +38,9 @@ Scan Flags
General Flags
--bearer-ignore-file string Load bearer.ignore file from the specified path. (default "bearer.ignore")
--config-file string Load configuration from the specified path. (default "bearer.yml")
--debug Enable debug logs. Equivalent to --log-level=debug
--disable-version-check Disable Bearer version checking
--log-level string Set log level (error, info, debug, trace) (default "info")
--no-color Disable color in output


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ Rule Flags
Scan Flags
--context string Expand context of schema classification e.g., --context=health, to include data types particular to health
--data-subject-mapping string Override default data subject mapping by providing a path to a custom mapping JSON file
--debug Enable debug logs. Equivalent to --log-level=debug
--disable-domain-resolution Do not attempt to resolve detected domains during classification (default true)
--domain-resolution-timeout duration Set timeout when attempting to resolve detected domains during classification, e.g. --domain-resolution-timeout=3s (default 3s)
--exit-code int Force a given exit code for the scan command. Set this to 0 (success) to always return a success exit code despite any findings from the scan. (default -1)
--external-rule-dir strings Specify directories paths that contain .yaml files with external rules configuration
--force Disable the cache and runs the detections again
--internal-domains strings Define regular expressions for better classification of private or unreachable domains e.g. --internal-domains=".*.my-company.com,private.sh"
--log-level string Set log level (error, info, debug, trace) (default "info")
--parallel int Specify the amount of parallelism to use during the scan
--quiet Suppress non-essential messages
--scanner strings Specify which scanner to use e.g. --scanner=secrets, --scanner=secrets,sast (default [sast])
Expand All @@ -40,7 +38,9 @@ Scan Flags
General Flags
--bearer-ignore-file string Load bearer.ignore file from the specified path. (default "bearer.ignore")
--config-file string Load configuration from the specified path. (default "bearer.yml")
--debug Enable debug logs. Equivalent to --log-level=debug
--disable-version-check Disable Bearer version checking
--log-level string Set log level (error, info, debug, trace) (default "info")
--no-color Disable color in output


Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/artifact/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func Run(ctx context.Context, opts flag.Options) (err error) {
}()

var stats *evalstats.Stats
if scanSettings.Scan.Debug {
if scanSettings.Debug {
stats = evalstats.New()
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/process/orchestrator/pool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func New(config settings.Config, stats *stats.Stats) *Pool {
output.Fatal(fmt.Sprintf("failed to get current command executable %s", err))
}

baseArguments := []string{"processing-worker", "--log-level", config.Scan.LogLevel}
baseArguments := []string{"processing-worker", "--log-level", config.LogLevel}
if config.DebugProfile {
baseArguments = append(baseArguments, "--debug-profile")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/process/orchestrator/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type Worker struct {
}

func (worker *Worker) Setup(config config.Config) error {
worker.debug = config.Scan.Debug
worker.debug = config.Debug
worker.scanners = config.Scan.Scanner

if slices.Contains(worker.scanners, "sast") {
Expand Down
4 changes: 4 additions & 0 deletions pkg/commands/process/settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ type Config struct {
CacheUsed bool `mapstructure:"cache_used" json:"cache_used" yaml:"cache_used"`
BearerRulesVersion string `mapstructure:"bearer_rules_version" json:"bearer_rules_version" yaml:"bearer_rules_version"`
NoColor bool `mapstructure:"no_color" json:"no_color" yaml:"no_color"`
Debug bool `mapstructure:"debug" json:"debug" yaml:"debug"`
LogLevel string `mapstructure:"string" json:"string" yaml:"string"`
DebugProfile bool `mapstructure:"debug_profile" json:"debug_profile" yaml:"debug_profile"`
}

Expand Down Expand Up @@ -334,6 +336,8 @@ func FromOptions(opts flag.Options, foundLanguages []string) (Config, error) {
IgnoredFingerprints: ignoredFingerprints,
NoColor: opts.GeneralOptions.NoColor || opts.ReportOptions.Output != "",
DebugProfile: opts.GeneralOptions.DebugProfile,
Debug: opts.GeneralOptions.Debug,
LogLevel: opts.GeneralOptions.LogLevel,
Policies: policies,
Rules: result.Rules,
BuiltInRules: result.BuiltInRules,
Expand Down
3 changes: 2 additions & 1 deletion pkg/commands/processing_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
func NewProcessingWorkerCommand() *cobra.Command {
flags := &flag.Flags{
ProcessFlagGroup: flag.NewProcessGroup(),
GeneralFlagGroup: flag.NewGeneralFlagGroup(),
ScanFlagGroup: flag.NewScanFlagGroup(),
}

Expand All @@ -32,7 +33,7 @@ func NewProcessingWorkerCommand() *cobra.Command {
ProcessID: viper.GetString(flag.WorkerIDFlag.ConfigName),
})

if viper.GetBool(flag.WorkerDebugProfileFlag.ConfigName) {
if viper.GetBool(flag.DebugProfileFlag.ConfigName) {
debugprofile.Start()
}

Expand Down
Loading
Loading