Skip to content

Commit 9bd66bd

Browse files
committed
fixed nist tags to properly be in the compatible product
Signed-off-by: Amndeep Singh Mann <[email protected]>
1 parent 0aad3b5 commit 9bd66bd

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

lib/heimdall_tools/asff_compatible_products/securityhub.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,17 @@ def self.finding_impact(finding, *, controls: nil, **)
5353
def self.finding_nist_tag(finding, *, aws_config_mapping:, **)
5454
return {} unless finding['ProductFields']['RelatedAWSResources:0/type'] == 'AWS::Config::ConfigRule'
5555

56-
aws_config_mapping.select { |rule| finding['ProductFields']['RelatedAWSResources:0/name'].include? rule[:awsconfigrulename] }
56+
entries = aws_config_mapping.select { |rule| finding['ProductFields']['RelatedAWSResources:0/name'].include? rule[:awsconfigrulename] }
57+
entries.map do |rule|
58+
tags_joined = rule[:nistid].split('|') # subheadings are joined together in the csv file
59+
tags_joined.map do |tag|
60+
if (i = tag.index('(')).nil?
61+
tag
62+
else
63+
tag[i..].scan(/\(.+?\)/).map { |subheading| "#{tag[0..i-1]}#{subheading}" }
64+
end
65+
end
66+
end.flatten.uniq
5767
end
5868

5969
def self.finding_title(finding, *, encode:, controls: nil, **)

lib/heimdall_tools/asff_mapper.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,8 @@ def external_product_handler(product, data, func, default)
8989
end
9090

9191
def nist_tag(finding)
92-
entries = external_product_handler(finding['ProductArn'], finding, :finding_nist_tag, {})
93-
tags = entries.map { |rule| rule[:nistid].split('|') }
94-
tags.empty? ? DEFAULT_NIST_TAG : tags.flatten.uniq
92+
tags = external_product_handler(finding['ProductArn'], finding, :finding_nist_tag, {})
93+
tags.empty? ? DEFAULT_NIST_TAG : tags
9594
end
9695

9796
def impact(finding)

sample_jsons/asff_mapper/asff_hdf.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)