Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

Commit

Permalink
feat(scanner): extend scanner configs with json tag (#1931)
Browse files Browse the repository at this point in the history
* feat(scanner): extend scanner configs with json

* fix: update config test
  • Loading branch information
paralta authored Jul 18, 2024
1 parent a5cbdda commit c2117e7
Show file tree
Hide file tree
Showing 24 changed files with 237 additions and 237 deletions.
226 changes: 113 additions & 113 deletions cli/state/testdata/effective-config.json
Original file line number Diff line number Diff line change
@@ -1,165 +1,165 @@
{
"sbom": {
"Enabled": true,
"AnalyzersList": [
"enabled": true,
"analyzers_list": [
"syft"
],
"Inputs": [
"inputs": [
{
"strip_path_from_result": null,
"input": "test",
"input_type": "dir"
}
],
"MergeWith": null,
"Registry": null,
"LocalImageScan": false,
"OutputFormat": "",
"AnalyzersConfig": {
"Syft": {
"Scope": "",
"ExcludePaths": null,
"Registry": null,
"LocalImageScan": false
"merge_with": null,
"registry": null,
"local_image_scan": false,
"output_format": "",
"analyzers_config": {
"syft": {
"scope": "",
"exclude_paths": null,
"registry": null,
"local_image_scan": false
},
"Trivy": {
"Timeout": 0,
"CacheDir": "",
"TempDir": "",
"Registry": null,
"LocalImageScan": false
"trivy": {
"timeout": 0,
"cache_dir": "",
"temp_dir": "",
"registry": null,
"local_image_scan": false
}
}
},
"vulnerabilities": {
"Enabled": false,
"ScannersList": null,
"Inputs": null,
"InputFromSbom": false,
"Registry": null,
"LocalImageScan": false,
"ScannersConfig": {
"Grype": {
"Mode": "",
"Local": {
"UpdateDB": false,
"DBRootDir": "",
"ListingURL": "",
"MaxAllowedBuiltAge": 0,
"ListingFileTimeout": 0,
"UpdateTimeout": 0,
"Scope": "",
"Registry": null,
"LocalImageScan": false
"enabled": false,
"scanners_list": null,
"inputs": null,
"input_from_sbom": false,
"registry": null,
"local_image_scan": false,
"scanners_config": {
"grype": {
"mode": "",
"local_grype_config": {
"update_db": false,
"db_root_dir": "",
"listing_url": "",
"max_allowed_built_age": 0,
"listing_file_timeout": 0,
"update_timeout": 0,
"scope": "",
"registry": null,
"local_image_scan": false
},
"Remote": {
"GrypeServerAddress": "",
"GrypeServerSchemes": null,
"GrypeServerTimeout": 0
"remote_grype_config": {
"grype_server_address": "",
"grype_server_schemes": null,
"grype_server_timeout": 0
}
},
"Trivy": {
"Timeout": 0,
"ServerAddr": "",
"ServerToken": "",
"CacheDir": "",
"TempDir": "",
"Registry": null
"trivy": {
"timeout": 0,
"server_addr": "",
"server_token": "",
"cache_dir": "",
"temp_dir": "",
"registry": null
}
}
},
"secrets": {
"Enabled": false,
"ScannersList": null,
"StripInputPaths": false,
"Inputs": null,
"ScannersConfig": {
"Gitleaks": {
"BinaryPath": ""
"enabled": false,
"scanners_list": null,
"strip_input_paths": false,
"inputs": null,
"scanners_config": {
"gitleaks": {
"binary_path": ""
}
}
},
"rootkits": {
"Enabled": false,
"ScannersList": null,
"StripInputPaths": false,
"Inputs": null,
"ScannersConfig": {
"Chkrootkit": {
"BinaryPath": ""
"enabled": false,
"scanners_list": null,
"strip_input_paths": false,
"inputs": null,
"scanners_config": {
"chkrootkit": {
"binary_path": ""
}
}
},
"malware": {
"Enabled": false,
"ScannersList": null,
"StripInputPaths": false,
"Inputs": null,
"ScannersConfig": {
"Clam": {
"UseClamDaemon": false,
"ClamScanBinaryPath": "",
"ClamScanExcludeFiles": null,
"ClamScanExcludeDirs": null,
"ClamDaemonClientBinaryPath": "",
"ClamDaemonBinaryPath": "",
"ClamDaemonConfigPath": "",
"FreshclamBinaryPath": "",
"FreshclamConfigPath": "",
"AlternativeFreshclamMirrorURL": ""
"enabled": false,
"scanners_list": null,
"strip_input_paths": false,
"inputs": null,
"scanners_config": {
"clam": {
"use_clam_daemon": false,
"clamscan_binary_path": "",
"clamscan_exclude_files": null,
"clamscan_exclude_dirs": null,
"clam_daemon_client_binary_path": "",
"clam_daemon_binary_path": "",
"clam_daemon_config_path": "",
"freshclam_binary_path": "",
"freshclam_config_path": "",
"alternative_freshclam_mirror_url": ""
},
"Yara": {
"YaraBinaryPath": "",
"CompiledRuleURL": "",
"RuleSources": null,
"YaracBinaryPath": "",
"CacheDir": "",
"DirectoriesToScan": null
"yara": {
"yara_binary_path": "",
"compiled_rule_url": "",
"rule_sources": null,
"yarac_binary_path": "",
"cache_dir": "",
"directories_to_scan": null
}
}
},
"misconfiguration": {
"enabled": false,
"ScannersList": null,
"StripInputPaths": false,
"Inputs": null,
"ScannersConfig": {
"Lynis": {
"BinaryPath": ""
"scanners_list": null,
"strip_input_paths": false,
"inputs": null,
"scanners_config": {
"lynis": {
"binary_path": ""
},
"CISDocker": {
"Timeout": 0,
"Registry": null
"cisdocker": {
"timeout": 0,
"registry": null
}
}
},
"infofinder": {
"enabled": false,
"ScannersList": null,
"StripInputPaths": false,
"Inputs": null,
"ScannersConfig": {
"SSHTopology": {}
"scanners_list": null,
"strip_input_paths": false,
"inputs": null,
"scanners_config": {
"ssh_topology": {}
}
},
"exploits": {
"enabled": false,
"ScannersList": null,
"Inputs": null,
"InputFromVuln": false,
"ScannersConfig": {
"ExploitDB": {
"BaseURL": ""
"scanners_list": null,
"inputs": null,
"input_from_vuln": false,
"scanners_config": {
"exploit_db": {
"base_url": ""
}
}
},
"plugins": {
"Enabled": false,
"ScannersList": null,
"Inputs": null,
"ScannersConfig": null,
"BinaryMode": false,
"BinaryArtifactsPath": "",
"BinaryArtifactsClean": false
"enabled": false,
"scanners_list": null,
"inputs": null,
"scanners_config": null,
"binary_mode": false,
"binary_artifacts_path": "",
"binary_artifacts_clean": false
}
}
2 changes: 1 addition & 1 deletion scanner/families/exploits/exploitdb/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ package config

type Config struct {
// URL of the exploit db server
BaseURL string `yaml:"base_url" mapstructure:"base_url"`
BaseURL string `yaml:"base_url" mapstructure:"base_url" json:"base_url"`
}
12 changes: 6 additions & 6 deletions scanner/families/exploits/types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ import (
)

type Config struct {
Enabled bool `json:"enabled" yaml:"enabled"`
ScannersList []string `yaml:"scanners_list" mapstructure:"scanners_list"`
Inputs []common.ScanInput `yaml:"inputs" mapstructure:"inputs"`
InputFromVuln bool `yaml:"input_from_vuln" mapstructure:"input_from_vuln"`
ScannersConfig ScannersConfig `yaml:"scanners_config" mapstructure:"scanners_config"`
Enabled bool `yaml:"enabled" mapstructure:"enabled" json:"enabled"`
ScannersList []string `yaml:"scanners_list" mapstructure:"scanners_list" json:"scanners_list"`
Inputs []common.ScanInput `yaml:"inputs" mapstructure:"inputs" json:"inputs"`
InputFromVuln bool `yaml:"input_from_vuln" mapstructure:"input_from_vuln" json:"input_from_vuln"`
ScannersConfig ScannersConfig `yaml:"scanners_config" mapstructure:"scanners_config" json:"scanners_config"`
}

type ScannersConfig struct {
ExploitDB exploitdbconfig.Config `yaml:"exploit_db" mapstructure:"exploit_db"`
ExploitDB exploitdbconfig.Config `yaml:"exploit_db" mapstructure:"exploit_db" json:"exploit_db"`
}
12 changes: 6 additions & 6 deletions scanner/families/infofinder/types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ import (
)

type Config struct {
Enabled bool `json:"enabled" yaml:"enabled" mapstructure:"enabled"`
ScannersList []string `yaml:"scanners_list" mapstructure:"scanners_list"`
StripInputPaths bool `yaml:"strip_input_paths" mapstructure:"strip_input_paths"`
Inputs []common.ScanInput `yaml:"inputs" mapstructure:"inputs"`
ScannersConfig ScannersConfig `yaml:"scanners_config" mapstructure:"scanners_config"`
Enabled bool `yaml:"enabled" mapstructure:"enabled" json:"enabled"`
ScannersList []string `yaml:"scanners_list" mapstructure:"scanners_list" json:"scanners_list"`
StripInputPaths bool `yaml:"strip_input_paths" mapstructure:"strip_input_paths" json:"strip_input_paths"`
Inputs []common.ScanInput `yaml:"inputs" mapstructure:"inputs" json:"inputs"`
ScannersConfig ScannersConfig `yaml:"scanners_config" mapstructure:"scanners_config" json:"scanners_config"`
}

type ScannersConfig struct {
SSHTopology sshtopologyconfig.Config `yaml:"ssh_topology" mapstructure:"ssh_topology"`
SSHTopology sshtopologyconfig.Config `yaml:"ssh_topology" mapstructure:"ssh_topology" json:"ssh_topology"`
}
20 changes: 10 additions & 10 deletions scanner/families/malware/clam/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ const (
type Config struct {
// UseClamDaemon indicates that scanning should use daemon (clamdscan) command
// instead of native (clamscan) command.
UseClamDaemon bool `yaml:"use_clam_daemon" mapstructure:"use_clam_daemon"`
ClamScanBinaryPath string `yaml:"clamscan_binary_path" mapstructure:"clamscan_binary_path"`
ClamScanExcludeFiles []string `yaml:"clamscan_exclude_files" mapstructure:"clamscan_exclude_files"`
ClamScanExcludeDirs []string `yaml:"clamscan_exclude_dirs" mapstructure:"clamscan_exclude_dirs"`
ClamDaemonClientBinaryPath string `yaml:"clam_daemon_client_binary_path" mapstructure:"clam_daemon_client_binary_path"`
ClamDaemonBinaryPath string `yaml:"clam_daemon_binary_path" mapstructure:"clam_daemon_binary_path"`
ClamDaemonConfigPath string `yaml:"clam_daemon_config_path" mapstructure:"clam_daemon_config_path"`
FreshclamBinaryPath string `yaml:"freshclam_binary_path" mapstructure:"freshclam_binary_path"`
FreshclamConfigPath string `yaml:"freshclam_config_path" mapstructure:"freshclam_config_path"`
AlternativeFreshclamMirrorURL string `yaml:"alternative_freshclam_mirror_url" mapstructure:"alternative_freshclam_mirror_url"`
UseClamDaemon bool `yaml:"use_clam_daemon" mapstructure:"use_clam_daemon" json:"use_clam_daemon"`
ClamScanBinaryPath string `yaml:"clamscan_binary_path" mapstructure:"clamscan_binary_path" json:"clamscan_binary_path"`
ClamScanExcludeFiles []string `yaml:"clamscan_exclude_files" mapstructure:"clamscan_exclude_files" json:"clamscan_exclude_files"`
ClamScanExcludeDirs []string `yaml:"clamscan_exclude_dirs" mapstructure:"clamscan_exclude_dirs" json:"clamscan_exclude_dirs"`
ClamDaemonClientBinaryPath string `yaml:"clam_daemon_client_binary_path" mapstructure:"clam_daemon_client_binary_path" json:"clam_daemon_client_binary_path"`
ClamDaemonBinaryPath string `yaml:"clam_daemon_binary_path" mapstructure:"clam_daemon_binary_path" json:"clam_daemon_binary_path"`
ClamDaemonConfigPath string `yaml:"clam_daemon_config_path" mapstructure:"clam_daemon_config_path" json:"clam_daemon_config_path"`
FreshclamBinaryPath string `yaml:"freshclam_binary_path" mapstructure:"freshclam_binary_path" json:"freshclam_binary_path"`
FreshclamConfigPath string `yaml:"freshclam_config_path" mapstructure:"freshclam_config_path" json:"freshclam_config_path"`
AlternativeFreshclamMirrorURL string `yaml:"alternative_freshclam_mirror_url" mapstructure:"alternative_freshclam_mirror_url" json:"alternative_freshclam_mirror_url"`
}

func (c *Config) GetFreshclamConfigPath() string {
Expand Down
14 changes: 7 additions & 7 deletions scanner/families/malware/types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ import (
)

type Config struct {
Enabled bool `yaml:"enabled" mapstructure:"enabled"`
ScannersList []string `yaml:"scanners_list" mapstructure:"scanners_list"`
StripInputPaths bool `yaml:"strip_input_paths" mapstructure:"strip_input_paths"`
Inputs []common.ScanInput `yaml:"inputs" mapstructure:"inputs"`
ScannersConfig ScannersConfig `yaml:"scanners_config" mapstructure:"scanners_config"`
Enabled bool `yaml:"enabled" mapstructure:"enabled" json:"enabled"`
ScannersList []string `yaml:"scanners_list" mapstructure:"scanners_list" json:"scanners_list"`
StripInputPaths bool `yaml:"strip_input_paths" mapstructure:"strip_input_paths" json:"strip_input_paths"`
Inputs []common.ScanInput `yaml:"inputs" mapstructure:"inputs" json:"inputs"`
ScannersConfig ScannersConfig `yaml:"scanners_config" mapstructure:"scanners_config" json:"scanners_config"`
}

type ScannersConfig struct {
Clam clamconfig.Config `yaml:"clam" mapstructure:"clam"`
Yara yaraconfig.Config `yaml:"yara" mapstructure:"yara"`
Clam clamconfig.Config `yaml:"clam" mapstructure:"clam" json:"clam"`
Yara yaraconfig.Config `yaml:"yara" mapstructure:"yara" json:"yara"`
}
12 changes: 6 additions & 6 deletions scanner/families/malware/yara/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ const (
)

type Config struct {
YaraBinaryPath string `yaml:"yara_binary_path" mapstructure:"yara_binary_path"`
CompiledRuleURL string `yaml:"compiled_rule_url" mapstructure:"compiled_rule_url"`
RuleSources []config.RuleSource `yaml:"rule_sources" mapstructure:"rule_sources"`
YaracBinaryPath string `yaml:"yarac_binary_path" mapstructure:"yarac_binary_path"`
CacheDir string `yaml:"cache_dir" mapstructure:"cache_dir"`
DirectoriesToScan []string `yaml:"directories_to_scan" mapstructure:"directories_to_scan"`
YaraBinaryPath string `yaml:"yara_binary_path" mapstructure:"yara_binary_path" json:"yara_binary_path"`
CompiledRuleURL string `yaml:"compiled_rule_url" mapstructure:"compiled_rule_url" json:"compiled_rule_url"`
RuleSources []config.RuleSource `yaml:"rule_sources" mapstructure:"rule_sources" json:"rule_sources"`
YaracBinaryPath string `yaml:"yarac_binary_path" mapstructure:"yarac_binary_path" json:"yarac_binary_path"`
CacheDir string `yaml:"cache_dir" mapstructure:"cache_dir" json:"cache_dir"`
DirectoriesToScan []string `yaml:"directories_to_scan" mapstructure:"directories_to_scan" json:"directories_to_scan"`
}

func (c *Config) GetYaraBinaryPath() string {
Expand Down
Loading

0 comments on commit c2117e7

Please sign in to comment.