Skip to content

Commit

Permalink
Merge pull request #50 from mitre/sonarqube_mapping
Browse files Browse the repository at this point in the history
Added default NIST_ID tags of SA-11 and RA-5 to sonarqube_mapper
  • Loading branch information
Bialogs authored Feb 16, 2021
2 parents d0fc79c + a12435b commit 2b63d63
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/heimdall_tools/fortify_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'utilities/xml_to_hash'

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

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

def impact(classid)
Expand Down
4 changes: 3 additions & 1 deletion lib/heimdall_tools/sonarqube_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

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

DEFAULT_NIST_TAG = ["SA-11", "RA-5"].freeze

MAPPING_FILES = {
cwe: File.join(RESOURCE_DIR, 'cwe-nist-mapping.csv'),
owasp: File.join(RESOURCE_DIR, 'owasp-nist-mapping.csv')
Expand Down Expand Up @@ -237,7 +239,7 @@ def get_nist_tags
return [@mappings[tag_type][parsed_tag]].flatten.uniq
end

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

def hdf
Expand Down
3 changes: 2 additions & 1 deletion lib/heimdall_tools/zap_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
RESOURCE_DIR = Pathname.new(__FILE__).join('../../data')

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

# rubocop:disable Metrics/AbcSize

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

def impact(riskcode)
Expand Down

0 comments on commit 2b63d63

Please sign in to comment.