Skip to content

Commit 7e20f8c

Browse files
committed
Merge pull request #11 from codeclimate/gd-severity
Add severity to issue output
2 parents 100082d + 2ef7813 commit 7e20f8c

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

lib/cc/engine/bundler_audit.rb

+14-8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ module CC
55
module Engine
66
class BundlerAudit
77
GemfileLockNotFound = Class.new(StandardError)
8+
SEVERITIES = {
9+
"High" => "critical",
10+
"Low" => "info",
11+
"Medium" => "normal",
12+
}
813

914
def initialize(directory: , io: , engine_config: )
1015
@directory = directory
@@ -50,23 +55,24 @@ def issue_from_raw(raw_issue)
5055
end
5156
end
5257
{
53-
type: 'Issue',
58+
categories: ['Security'],
5459
check_name: "Insecure Dependency",
60+
content: {
61+
body: content_body(raw_issue_hash)
62+
},
5563
description: raw_issue_hash['Title'],
56-
categories: ['Security'],
57-
remediation_points: remediation_points(
58-
raw_issue_hash['Version'], raw_issue_hash['Solution']
59-
),
6064
location: {
6165
path: 'Gemfile.lock',
6266
lines: {
6367
begin: line_number,
6468
end: line_number
6569
}
6670
},
67-
content: {
68-
body: content_body(raw_issue_hash)
69-
}
71+
remediation_points: remediation_points(
72+
raw_issue_hash['Version'], raw_issue_hash['Solution']
73+
),
74+
severity: SEVERITIES[raw_issue_hash["Criticality"]],
75+
type: 'Issue',
7076
}
7177
end
7278

spec/cc/engine/bundler_audit_spec.rb

+8-7
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,19 @@ module CC::Engine
2626
Solution: upgrade to ~> 2.3.18, ~> 3.1.12, >= 3.2.13
2727
EOF
2828
result = {
29-
type: "Issue",
29+
categories: ["Security"],
3030
check_name: "Insecure Dependency",
31+
content: {
32+
body: "**Advisory**: OSVDB-91452\n\n**Criticality**: Medium\n\n**URL**: http://www.osvdb.org/show/osvdb/91452\n\n**Solution**: upgrade to ~> 2.3.18, ~> 3.1.12, >= 3.2.13"
33+
},
3134
description: "XSS vulnerability in sanitize_css in Action Pack",
32-
categories: ["Security"],
33-
remediation_points: 500_000,
3435
location: {
3536
path: "Gemfile.lock",
3637
lines: { begin: nil, end: nil }
3738
},
38-
content: {
39-
body: "**Advisory**: OSVDB-91452\n\n**Criticality**: Medium\n\n**URL**: http://www.osvdb.org/show/osvdb/91452\n\n**Solution**: upgrade to ~> 2.3.18, ~> 3.1.12, >= 3.2.13"
40-
},
39+
remediation_points: 500_000,
40+
severity: "normal",
41+
type: "Issue",
4142
}.to_json
4243
io = StringIO.new
4344
directory = "/c"
@@ -54,7 +55,7 @@ module CC::Engine
5455
audit.run
5556
end
5657

57-
expect(io.string).to match("#{result}\0")
58+
expect(io.string).to eq("#{result}\0")
5859
end
5960
end
6061
end

0 commit comments

Comments
 (0)