heimdall_tools 1.3.34 → 1.3.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +16 -0
- data/lib/data/cwe-nist-mapping.csv +5 -1
- data/lib/heimdall_tools.rb +1 -0
- data/lib/heimdall_tools/cli.rb +12 -0
- data/lib/heimdall_tools/fortify_mapper.rb +2 -1
- data/lib/heimdall_tools/help/jfrog_xray_mapper.md +5 -0
- data/lib/heimdall_tools/jfrog_xray_mapper.rb +142 -0
- data/lib/heimdall_tools/sonarqube_mapper.rb +3 -1
- data/lib/heimdall_tools/zap_mapper.rb +2 -1
- metadata +5 -31
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 30a8aa48d76c322433d3b7233585d2f7265c5d9906147f904a56d7c37468943d
|
|
4
|
+
data.tar.gz: de9c85b3ec842451ba8ccd52ef66b516390677c1d9971e602c434cc21725d619
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 735203a3dedc20625a366530d50c5f0e11a5a654a13f1264b53dd239b6902a851b35ea49ae1b783714399d6c2215ebf137a2c54e4edb6a2c7e40e3a17ef1d8db
|
|
7
|
+
data.tar.gz: 19b63fc27d52ede491025d7880771e31ffeaf090707b73885970b9455e4c81bda1c15b428621436e8086f9e6d5521d6810fd1000df4f2900fe8b57911fc44488
|
data/README.md
CHANGED
|
@@ -12,6 +12,7 @@ HeimdallTools supplies several methods to convert output from various tools to "
|
|
|
12
12
|
- **nessus_mapper** - commercial vulnerability scanner
|
|
13
13
|
- **snyk_mapper** - commercial package vulnerability scanner
|
|
14
14
|
- **nikto_mapper** - open-source web server scanner
|
|
15
|
+
- **jfrog_xray_mapper** - package vulnerability scanner
|
|
15
16
|
|
|
16
17
|
Ruby 2.4 or higher (check using "ruby -v")
|
|
17
18
|
|
|
@@ -181,6 +182,21 @@ FLAGS:
|
|
|
181
182
|
example: heimdall_tools nikto_mapper -j nikto_results.json -o nikto_results.json
|
|
182
183
|
```
|
|
183
184
|
|
|
185
|
+
## jfrog_xray_mapper
|
|
186
|
+
|
|
187
|
+
jfrog_xray_mapper translates an JFrog Xray results JSON file into HDF format JSON to be viewable in Heimdall
|
|
188
|
+
|
|
189
|
+
```
|
|
190
|
+
USAGE: heimdall_tools jfrog_xray_mapper [OPTIONS] -j <xray-results-json> -o <hdf-scan-results.json>
|
|
191
|
+
|
|
192
|
+
FLAGS:
|
|
193
|
+
-j <xray_results_json> : path to xray results JSON file.
|
|
194
|
+
-o --output <scan-results> : path to output scan-results json.
|
|
195
|
+
-V --verbose : verbose run [optional].
|
|
196
|
+
|
|
197
|
+
example: heimdall_tools jfrog_xray_mapper -j xray_results.json -o xray_results_hdf.json
|
|
198
|
+
```
|
|
199
|
+
|
|
184
200
|
## version
|
|
185
201
|
|
|
186
202
|
Prints out the gem version
|
|
@@ -64,10 +64,13 @@
|
|
|
64
64
|
251, Often Misused: String Management,,4,
|
|
65
65
|
252, Unchecked Return Value,,4,
|
|
66
66
|
256, Plaintext Storage of a Password,SC-28,4,Protection of Information at Rest
|
|
67
|
+
257, Storing Passwords in a Recoverable Format,IA-5,4,Authenticator Management
|
|
67
68
|
258, Empty Password in Configuration File,SC-28,4,Protection of Information at Rest
|
|
68
69
|
259, Use of Hard-coded Password,,4,
|
|
69
70
|
260, Password in Configuration File,SC-28,4,Protection of Information at Rest
|
|
70
71
|
261, Weak Cryptography for Passwords,SC-13,4,Cryptographic Protection
|
|
72
|
+
262, Not Using Password Aging,IA-5,4,Authenticator Management
|
|
73
|
+
263, Password Aging with Long Expiration,IA-5,4,Authenticator Management
|
|
71
74
|
265, Privilege / Sandbox Issues,AC-6,4,Least Privilege
|
|
72
75
|
269, Improper Privilege Management,AC-4,4,Information Flow Enforcement
|
|
73
76
|
272, Least Privilege Violation,AC-6,4,Least Privilege: Privilege Levels for Code Execution -8
|
|
@@ -175,8 +178,9 @@
|
|
|
175
178
|
662, Improper Synchonization,,4,
|
|
176
179
|
667, Improper Locking,,4,
|
|
177
180
|
676, Use of Potentially Dangerous Function,,4,
|
|
178
|
-
690
|
|
181
|
+
690, Unchecked Return Value to NULL Pointer Dereference,,4,
|
|
179
182
|
691, Insufficient Control Flow Management,SI-11,4,Error Handling
|
|
183
|
+
693, Protection Mechanism Failure,IA-5,4,Authenticator Management
|
|
180
184
|
694, Use of Multiple Resources with Duplicate Identifier,,4,
|
|
181
185
|
732, Incorrect Permission Assignment for Critical Resource,AC-3,4,Access Enforcement
|
|
182
186
|
733, Compiler Optimization Removal or Modification of Security-critical Code,,4,
|
data/lib/heimdall_tools.rb
CHANGED
data/lib/heimdall_tools/cli.rb
CHANGED
|
@@ -87,6 +87,18 @@ module HeimdallTools
|
|
|
87
87
|
puts "#{options[:output]}"
|
|
88
88
|
end
|
|
89
89
|
|
|
90
|
+
desc 'jfrog_xray_mapper', 'jfrog_xray_mapper translates Jfrog Xray results Json to HDF format Json be viewed on Heimdall'
|
|
91
|
+
long_desc Help.text(:jfrog_xray_mapper)
|
|
92
|
+
option :json, required: true, aliases: '-j'
|
|
93
|
+
option :output, required: true, aliases: '-o'
|
|
94
|
+
option :verbose, type: :boolean, aliases: '-V'
|
|
95
|
+
def jfrog_xray_mapper
|
|
96
|
+
hdf = HeimdallTools::JfrogXrayMapper.new(File.read(options[:json])).to_hdf
|
|
97
|
+
File.write(options[:output], hdf)
|
|
98
|
+
puts "\r\HDF Generated:\n"
|
|
99
|
+
puts "#{options[:output]}"
|
|
100
|
+
end
|
|
101
|
+
|
|
90
102
|
desc 'version', 'prints version'
|
|
91
103
|
def version
|
|
92
104
|
puts VERSION
|
|
@@ -3,6 +3,7 @@ require 'heimdall_tools/hdf'
|
|
|
3
3
|
require 'utilities/xml_to_hash'
|
|
4
4
|
|
|
5
5
|
NIST_REFERENCE_NAME = 'Standards Mapping - NIST Special Publication 800-53 Revision 4'.freeze
|
|
6
|
+
DEFAULT_NIST_TAG = ["SA-11", "RA-5"].freeze
|
|
6
7
|
|
|
7
8
|
module HeimdallTools
|
|
8
9
|
class FortifyMapper
|
|
@@ -68,7 +69,7 @@ module HeimdallTools
|
|
|
68
69
|
references = rule['References']['Reference']
|
|
69
70
|
references = [references] unless references.is_a?(Array)
|
|
70
71
|
tag = references.detect { |x| x['Author'].eql?(NIST_REFERENCE_NAME) }
|
|
71
|
-
tag.nil? ?
|
|
72
|
+
tag.nil? ? DEFAULT_NIST_TAG : tag['Title'].match(/[a-zA-Z][a-zA-Z]-\d{1,2}/)
|
|
72
73
|
end
|
|
73
74
|
|
|
74
75
|
def impact(classid)
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
require 'csv'
|
|
3
|
+
require 'heimdall_tools/hdf'
|
|
4
|
+
require 'utilities/xml_to_hash'
|
|
5
|
+
|
|
6
|
+
RESOURCE_DIR = Pathname.new(__FILE__).join('../../data')
|
|
7
|
+
|
|
8
|
+
CWE_NIST_MAPPING_FILE = File.join(RESOURCE_DIR, 'cwe-nist-mapping.csv')
|
|
9
|
+
|
|
10
|
+
IMPACT_MAPPING = {
|
|
11
|
+
high: 0.7,
|
|
12
|
+
medium: 0.5,
|
|
13
|
+
low: 0.3,
|
|
14
|
+
}.freeze
|
|
15
|
+
|
|
16
|
+
DEFAULT_NIST_TAG = ["SA-11", "RA-5"].freeze
|
|
17
|
+
|
|
18
|
+
# Loading spinner sign
|
|
19
|
+
$spinner = Enumerator.new do |e|
|
|
20
|
+
loop do
|
|
21
|
+
e.yield '|'
|
|
22
|
+
e.yield '/'
|
|
23
|
+
e.yield '-'
|
|
24
|
+
e.yield '\\'
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
module HeimdallTools
|
|
29
|
+
class JfrogXrayMapper
|
|
30
|
+
def initialize(xray_json, name=nil, verbose = false)
|
|
31
|
+
@xray_json = xray_json
|
|
32
|
+
@verbose = verbose
|
|
33
|
+
|
|
34
|
+
begin
|
|
35
|
+
@cwe_nist_mapping = parse_mapper
|
|
36
|
+
@project = JSON.parse(xray_json)
|
|
37
|
+
|
|
38
|
+
rescue StandardError => e
|
|
39
|
+
raise "Invalid JFrog Xray JSON file provided Exception: #{e}"
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def finding(vulnerability)
|
|
44
|
+
finding = {}
|
|
45
|
+
finding['status'] = 'failed'
|
|
46
|
+
finding['code_desc'] = []
|
|
47
|
+
finding['code_desc'] << "source_comp_id : #{vulnerability['source_comp_id'].to_s }"
|
|
48
|
+
finding['code_desc'] << "vulnerable_versions : #{vulnerability['component_versions']['vulnerable_versions'].to_s }"
|
|
49
|
+
finding['code_desc'] << "fixed_versions : #{vulnerability['component_versions']['fixed_versions'].to_s }"
|
|
50
|
+
finding['code_desc'] << "issue_type : #{vulnerability['issue_type'].to_s }"
|
|
51
|
+
finding['code_desc'] << "provider : #{vulnerability['provider'].to_s }"
|
|
52
|
+
finding['code_desc'] = finding['code_desc'].join("\n")
|
|
53
|
+
finding['run_time'] = NA_FLOAT
|
|
54
|
+
|
|
55
|
+
# Xray results does not profile scan timestamp; using current time to satisfy HDF format
|
|
56
|
+
finding['start_time'] = NA_STRING
|
|
57
|
+
[finding]
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def nist_tag(cweid)
|
|
61
|
+
entries = @cwe_nist_mapping.select { |x| cweid.include? x[:cweid].to_s }
|
|
62
|
+
tags = entries.map { |x| x[:nistid] }
|
|
63
|
+
tags.empty? ? DEFAULT_NIST_TAG : tags.flatten.uniq
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def parse_identifiers(vulnerability, ref)
|
|
67
|
+
# Extracting id number from reference style CWE-297
|
|
68
|
+
vulnerability['component_versions']['more_details']['cves'][0][ref.downcase].map { |e| e.split("#{ref}-")[1] }
|
|
69
|
+
rescue
|
|
70
|
+
return []
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def impact(severity)
|
|
74
|
+
IMPACT_MAPPING[severity.downcase.to_sym]
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def parse_mapper
|
|
78
|
+
csv_data = CSV.read(CWE_NIST_MAPPING_FILE, **{ encoding: 'UTF-8',
|
|
79
|
+
headers: true,
|
|
80
|
+
header_converters: :symbol,
|
|
81
|
+
converters: :all })
|
|
82
|
+
csv_data.map(&:to_hash)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def desc_tags(data, label)
|
|
86
|
+
{ "data": data || NA_STRING, "label": label || NA_STRING }
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Xray report could have multiple vulnerability entries for multiple findings of same issue type.
|
|
90
|
+
# The meta data is identical across entries
|
|
91
|
+
# method collapse_duplicates return unique controls with applicable findings collapsed into it.
|
|
92
|
+
def collapse_duplicates(controls)
|
|
93
|
+
unique_controls = []
|
|
94
|
+
|
|
95
|
+
controls.map { |x| x['id'] }.uniq.each do |id|
|
|
96
|
+
collapsed_results = controls.select { |x| x['id'].eql?(id) }.map {|x| x['results']}
|
|
97
|
+
unique_control = controls.find { |x| x['id'].eql?(id) }
|
|
98
|
+
unique_control['results'] = collapsed_results.flatten
|
|
99
|
+
unique_controls << unique_control
|
|
100
|
+
end
|
|
101
|
+
unique_controls
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def to_hdf
|
|
105
|
+
controls = []
|
|
106
|
+
vulnerability_count = 0
|
|
107
|
+
@project['data'].uniq.each do | vulnerability |
|
|
108
|
+
printf("\rProcessing: %s", $spinner.next)
|
|
109
|
+
|
|
110
|
+
vulnerability_count +=1
|
|
111
|
+
item = {}
|
|
112
|
+
item['tags'] = {}
|
|
113
|
+
item['descriptions'] = []
|
|
114
|
+
item['refs'] = NA_ARRAY
|
|
115
|
+
item['source_location'] = NA_HASH
|
|
116
|
+
item['descriptions'] = NA_ARRAY
|
|
117
|
+
|
|
118
|
+
# Xray JSONs might note have `id` fields populated.
|
|
119
|
+
# If thats a case MD5 hash is used to collapse vulnerability findings of the same type.
|
|
120
|
+
item['id'] = vulnerability['id'].empty? ? OpenSSL::Digest::MD5.digest(vulnerability['summary'].to_s).unpack("H*")[0].to_s : vulnerability['id']
|
|
121
|
+
item['title'] = vulnerability['summary'].to_s
|
|
122
|
+
item['desc'] = vulnerability['component_versions']['more_details']['description'].to_s
|
|
123
|
+
item['impact'] = impact(vulnerability['severity'].to_s)
|
|
124
|
+
item['code'] = NA_STRING
|
|
125
|
+
item['results'] = finding(vulnerability)
|
|
126
|
+
|
|
127
|
+
item['tags']['nist'] = nist_tag( parse_identifiers( vulnerability, 'CWE') )
|
|
128
|
+
item['tags']['cweid'] = parse_identifiers( vulnerability, 'CWE')
|
|
129
|
+
|
|
130
|
+
controls << item
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
controls = collapse_duplicates(controls)
|
|
134
|
+
results = HeimdallDataFormat.new(profile_name: "JFrog Xray Scan",
|
|
135
|
+
version: NA_STRING,
|
|
136
|
+
title: "JFrog Xray Scan",
|
|
137
|
+
summary: "Continuous Security and Universal Artifact Analysis",
|
|
138
|
+
controls: controls)
|
|
139
|
+
results.to_hdf
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
end
|
|
@@ -5,6 +5,8 @@ require 'heimdall_tools/hdf'
|
|
|
5
5
|
|
|
6
6
|
RESOURCE_DIR = Pathname.new(__FILE__).join('../../data')
|
|
7
7
|
|
|
8
|
+
DEFAULT_NIST_TAG = ["SA-11", "RA-5"].freeze
|
|
9
|
+
|
|
8
10
|
MAPPING_FILES = {
|
|
9
11
|
cwe: File.join(RESOURCE_DIR, 'cwe-nist-mapping.csv'),
|
|
10
12
|
owasp: File.join(RESOURCE_DIR, 'owasp-nist-mapping.csv')
|
|
@@ -237,7 +239,7 @@ class Control
|
|
|
237
239
|
return [@mappings[tag_type][parsed_tag]].flatten.uniq
|
|
238
240
|
end
|
|
239
241
|
|
|
240
|
-
|
|
242
|
+
DEFAULT_NIST_TAG # Entries with unmapped NIST tags are defaulted to NIST tags ‘SA-11, RA-5 Rev_4’
|
|
241
243
|
end
|
|
242
244
|
|
|
243
245
|
def hdf
|
|
@@ -7,6 +7,7 @@ require 'heimdall_tools/hdf'
|
|
|
7
7
|
RESOURCE_DIR = Pathname.new(__FILE__).join('../../data')
|
|
8
8
|
|
|
9
9
|
CWE_NIST_MAPPING_FILE = File.join(RESOURCE_DIR, 'cwe-nist-mapping.csv')
|
|
10
|
+
DEFAULT_NIST_TAG = ["SA-11", "RA-5"].freeze
|
|
10
11
|
|
|
11
12
|
# rubocop:disable Metrics/AbcSize
|
|
12
13
|
|
|
@@ -66,7 +67,7 @@ module HeimdallTools
|
|
|
66
67
|
def nist_tag(cweid)
|
|
67
68
|
entries = @cwe_nist_mapping.select { |x| x[:cweid].to_s.eql?(cweid.to_s) }
|
|
68
69
|
tags = entries.map { |x| [x[:nistid], "Rev_#{x[:rev]}"] }
|
|
69
|
-
tags.empty? ?
|
|
70
|
+
tags.empty? ? DEFAULT_NIST_TAG : tags.flatten.uniq
|
|
70
71
|
end
|
|
71
72
|
|
|
72
73
|
def impact(riskcode)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: heimdall_tools
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.
|
|
4
|
+
version: 1.3.35
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Robert Thew
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: exe
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date:
|
|
13
|
+
date: 2021-02-17 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: nokogiri
|
|
@@ -96,20 +96,6 @@ dependencies:
|
|
|
96
96
|
- - "~>"
|
|
97
97
|
- !ruby/object:Gem::Version
|
|
98
98
|
version: '2.1'
|
|
99
|
-
- !ruby/object:Gem::Dependency
|
|
100
|
-
name: nori
|
|
101
|
-
requirement: !ruby/object:Gem::Requirement
|
|
102
|
-
requirements:
|
|
103
|
-
- - "~>"
|
|
104
|
-
- !ruby/object:Gem::Version
|
|
105
|
-
version: '2.6'
|
|
106
|
-
type: :runtime
|
|
107
|
-
prerelease: false
|
|
108
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
109
|
-
requirements:
|
|
110
|
-
- - "~>"
|
|
111
|
-
- !ruby/object:Gem::Version
|
|
112
|
-
version: '2.6'
|
|
113
99
|
- !ruby/object:Gem::Dependency
|
|
114
100
|
name: git-lite-version-bump
|
|
115
101
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -166,20 +152,6 @@ dependencies:
|
|
|
166
152
|
- - ">="
|
|
167
153
|
- !ruby/object:Gem::Version
|
|
168
154
|
version: '0'
|
|
169
|
-
- !ruby/object:Gem::Dependency
|
|
170
|
-
name: codeclimate-test-reporter
|
|
171
|
-
requirement: !ruby/object:Gem::Requirement
|
|
172
|
-
requirements:
|
|
173
|
-
- - ">="
|
|
174
|
-
- !ruby/object:Gem::Version
|
|
175
|
-
version: '0'
|
|
176
|
-
type: :development
|
|
177
|
-
prerelease: false
|
|
178
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
179
|
-
requirements:
|
|
180
|
-
- - ">="
|
|
181
|
-
- !ruby/object:Gem::Version
|
|
182
|
-
version: '0'
|
|
183
155
|
- !ruby/object:Gem::Dependency
|
|
184
156
|
name: rake
|
|
185
157
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -222,11 +194,13 @@ files:
|
|
|
222
194
|
- lib/heimdall_tools/help.rb
|
|
223
195
|
- lib/heimdall_tools/help/burpsuite_mapper.md
|
|
224
196
|
- lib/heimdall_tools/help/fortify_mapper.md
|
|
197
|
+
- lib/heimdall_tools/help/jfrog_xray_mapper.md
|
|
225
198
|
- lib/heimdall_tools/help/nessus_mapper.md
|
|
226
199
|
- lib/heimdall_tools/help/nikto_mapper.md
|
|
227
200
|
- lib/heimdall_tools/help/snyk_mapper.md
|
|
228
201
|
- lib/heimdall_tools/help/sonarqube_mapper.md
|
|
229
202
|
- lib/heimdall_tools/help/zap_mapper.md
|
|
203
|
+
- lib/heimdall_tools/jfrog_xray_mapper.rb
|
|
230
204
|
- lib/heimdall_tools/nessus_mapper.rb
|
|
231
205
|
- lib/heimdall_tools/nikto_mapper.rb
|
|
232
206
|
- lib/heimdall_tools/snyk_mapper.rb
|
|
@@ -253,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
253
227
|
- !ruby/object:Gem::Version
|
|
254
228
|
version: '0'
|
|
255
229
|
requirements: []
|
|
256
|
-
rubygems_version: 3.
|
|
230
|
+
rubygems_version: 3.2.3
|
|
257
231
|
signing_key:
|
|
258
232
|
specification_version: 4
|
|
259
233
|
summary: Convert Forify, Openzap and Sonarqube results to HDF
|