Skip to content

Commit 9322a41

Browse files
authored
feat(security-toolbox): allow scanners to be configured (#421)
This PR enables passing a list of scanners to be used for policy checks.
1 parent 2ed4900 commit 9322a41

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

security-toolbox/docker

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ require_relative "policies/policy"
66

77
Dir["#{__dir__}/policies/docker/*.rb"].each { |f| require_relative f }
88

9-
args = {}
9+
args = {
10+
scanners: "vuln,misconfig,secret,license"
11+
}
1012
OptionParser.new do |parser|
1113
parser.on("-i", "--image IMAGE", "Docker image to scan") do |image|
1214
args[:image] = image
@@ -35,6 +37,10 @@ OptionParser.new do |parser|
3537
parser.on("-d", "--dependencies", "Install dependencies") do
3638
args[:install_dependencies] = true
3739
end
40+
41+
parser.on("", "--scanners SCANNERS", "Which scanners to use") do |scanners|
42+
args[:scanners] = scanners
43+
end
3844
end.parse!
3945

4046
policy_file = "docker-ignore-policy.rego"

security-toolbox/policies/docker/trivy_image.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def initialize(args)
1515

1616
@skip_files = args[:skip_files].to_s.split(",") || []
1717
@skip_dirs = args[:skip_dirs].to_s.split(",") || []
18+
@scanners = args[:scanners]
1819
end
1920

2021
def test

security-toolbox/policies/docker/trivy_table_output.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
class Policy::TrivyTableOutput < Policy
44
def initialize(args)
55
super(args)
6+
7+
@scanners = args[:scanners]
68
end
79

810
def test
@@ -11,7 +13,7 @@ def test
1113
"convert",
1214
"--format table",
1315
"--output table.txt",
14-
"--scanners vuln,secret,misconfig,license",
16+
"--scanners #{@scanners}",
1517
"out/docker-scan-trivy.json"
1618
]
1719

0 commit comments

Comments
 (0)