Skip to content

Commit c2c51ed

Browse files
committed
Add content for issues
1 parent 5e2fa78 commit c2c51ed

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

lib/cc/engine/bundler_audit.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ def issue_from_raw(raw_issue)
6565
begin: line_number,
6666
end: line_number
6767
}
68+
},
69+
content: {
70+
body: content_body(raw_issue_hash)
6871
}
6972
}
7073
end
@@ -95,6 +98,12 @@ def remediation_points(current_version, raw_solution)
9598
500_000_000 # No upgrade of gem possible
9699
end
97100
end
101+
102+
def content_body(raw_issue_hash)
103+
%w[Advisory Criticality URL Solution].map do |key|
104+
"#{key}: #{raw_issue_hash[key]}"
105+
end.join("\n\n")
106+
end
98107
end
99108
end
100109
end

spec/cc/engine/bundler_audit_spec.rb

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,48 @@ module CC::Engine
1515
expect(io.string).to match(%{{"type":"warning","description":"No Gemfile.lock file found"}})
1616
end
1717
end
18+
19+
it "emits issues for Gemfile.lock problems" do
20+
bundle_audit_output = <<-EOF
21+
Name: actionpack
22+
Version: 3.2.10
23+
Advisory: OSVDB-91452
24+
Criticality: Medium
25+
URL: http://www.osvdb.org/show/osvdb/91452
26+
Title: XSS vulnerability in sanitize_css in Action Pack
27+
Solution: upgrade to ~> 2.3.18, ~> 3.1.12, >= 3.2.13
28+
EOF
29+
result = {
30+
type: "Issue",
31+
check_name: "Insecure Dependency",
32+
description: "XSS vulnerability in sanitize_css in Action Pack",
33+
categories: ["Security"],
34+
remediation_points: 500000,
35+
location: {
36+
path: "Gemfile.lock",
37+
lines: { begin: nil, end: nil }
38+
},
39+
content: {
40+
body: "Advisory: OSVDB-91452\n\nCriticality: Medium\n\nURL: http://www.osvdb.org/show/osvdb/91452\n\nSolution: upgrade to ~> 2.3.18, ~> 3.1.12, >= 3.2.13"
41+
},
42+
}.to_json
43+
io = StringIO.new
44+
directory = "/c"
45+
config = {}
46+
47+
FakeFS do
48+
FileUtils.mkdir_p(directory)
49+
FileUtils.touch("/c/Gemfile.lock")
50+
51+
audit = BundlerAudit.new(directory: directory, io: io, engine_config: config)
52+
53+
allow(audit).to receive(:`).and_return(bundle_audit_output)
54+
55+
audit.run
56+
end
57+
58+
expect(io.string).to match("#{result}\0")
59+
end
1860
end
1961
end
2062
end

0 commit comments

Comments
 (0)