Skip to content

Commit 2b63d63

Browse files
authored
Merge pull request #50 from mitre/sonarqube_mapping
Added default NIST_ID tags of SA-11 and RA-5 to sonarqube_mapper
2 parents d0fc79c + a12435b commit 2b63d63

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

lib/heimdall_tools/fortify_mapper.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
require 'utilities/xml_to_hash'
44

55
NIST_REFERENCE_NAME = 'Standards Mapping - NIST Special Publication 800-53 Revision 4'.freeze
6+
DEFAULT_NIST_TAG = ["SA-11", "RA-5"].freeze
67

78
module HeimdallTools
89
class FortifyMapper
@@ -68,7 +69,7 @@ def nist_tag(rule)
6869
references = rule['References']['Reference']
6970
references = [references] unless references.is_a?(Array)
7071
tag = references.detect { |x| x['Author'].eql?(NIST_REFERENCE_NAME) }
71-
tag.nil? ? 'unmapped' : tag['Title'].match(/[a-zA-Z][a-zA-Z]-\d{1,2}/)
72+
tag.nil? ? DEFAULT_NIST_TAG : tag['Title'].match(/[a-zA-Z][a-zA-Z]-\d{1,2}/)
7273
end
7374

7475
def impact(classid)

lib/heimdall_tools/sonarqube_mapper.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
RESOURCE_DIR = Pathname.new(__FILE__).join('../../data')
77

8+
DEFAULT_NIST_TAG = ["SA-11", "RA-5"].freeze
9+
810
MAPPING_FILES = {
911
cwe: File.join(RESOURCE_DIR, 'cwe-nist-mapping.csv'),
1012
owasp: File.join(RESOURCE_DIR, 'owasp-nist-mapping.csv')
@@ -237,7 +239,7 @@ def get_nist_tags
237239
return [@mappings[tag_type][parsed_tag]].flatten.uniq
238240
end
239241

240-
['unmapped'] # HDF expects this to be a list, but not an empty list even if there aren't results
242+
DEFAULT_NIST_TAG # Entries with unmapped NIST tags are defaulted to NIST tags ‘SA-11, RA-5 Rev_4’
241243
end
242244

243245
def hdf

lib/heimdall_tools/zap_mapper.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
RESOURCE_DIR = Pathname.new(__FILE__).join('../../data')
88

99
CWE_NIST_MAPPING_FILE = File.join(RESOURCE_DIR, 'cwe-nist-mapping.csv')
10+
DEFAULT_NIST_TAG = ["SA-11", "RA-5"].freeze
1011

1112
# rubocop:disable Metrics/AbcSize
1213

@@ -66,7 +67,7 @@ def format_code_desc(code_desc)
6667
def nist_tag(cweid)
6768
entries = @cwe_nist_mapping.select { |x| x[:cweid].to_s.eql?(cweid.to_s) }
6869
tags = entries.map { |x| [x[:nistid], "Rev_#{x[:rev]}"] }
69-
tags.empty? ? ['unmapped'] : tags.flatten.uniq
70+
tags.empty? ? DEFAULT_NIST_TAG : tags.flatten.uniq
7071
end
7172

7273
def impact(riskcode)

0 commit comments

Comments
 (0)