@@ -38,8 +38,8 @@ def initialize(custom_mapping, endpoint = nil, verbose = false)
38
38
def to_hdf
39
39
controls = @issues . map do |issue |
40
40
@item = { }
41
- @item [ 'id' ] = issue [ :config_rule_name ]
42
- @item [ 'title' ] = issue [ :config_rule_name ]
41
+ @item [ 'id' ] = issue [ :config_rule_id ]
42
+ @item [ 'title' ] = " #{ get_account_id ( issue [ :config_rule_arn ] ) } - #{ issue [ : config_rule_name] } "
43
43
@item [ 'desc' ] = issue [ :description ]
44
44
@item [ 'impact' ] = 0.5
45
45
@item [ 'tags' ] = hdf_tags ( issue )
@@ -55,6 +55,7 @@ def to_hdf
55
55
@item
56
56
end
57
57
end
58
+
58
59
results = HeimdallDataFormat . new (
59
60
profile_name : 'AWS Config' ,
60
61
title : 'AWS Config' ,
@@ -67,6 +68,20 @@ def to_hdf
67
68
68
69
private
69
70
71
+ ##
72
+ # Gets the account ID from a config rule ARN
73
+ #
74
+ # https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html
75
+ # https://docs.aws.amazon.com/general/latest/gr/acct-identifiers.html
76
+ #
77
+ # Params:
78
+ # - arn: The ARN of the config rule
79
+ #
80
+ # Returns: The account ID portion of the ARN
81
+ def get_account_id ( arn )
82
+ /:(\d {12}):config-rule/ . match ( arn ) &.captures &.first || 'no-account-id'
83
+ end
84
+
70
85
##
71
86
# Read in a config rule -> 800-53 control mapping CSV.
72
87
#
@@ -263,7 +278,8 @@ def check_text(config_rule)
263
278
# If no input parameters, then provide an empty JSON array to the JSON
264
279
# parser because passing nil to JSON.parse throws an exception.
265
280
params = ( JSON . parse ( config_rule [ :input_parameters ] || '[]' ) . map { |key , value | "#{ key } : #{ value } " } ) . join ( '<br/>' )
266
- check_text = config_rule [ :config_rule_arn ] || ''
281
+ check_text = "ARN: #{ config_rule [ :config_rule_arn ] || 'N/A' } "
282
+ check_text += "<br/>Source Identifier: #{ config_rule . dig ( :source , :source_identifier ) || 'N/A' } "
267
283
check_text += "<br/>#{ params } " unless params . empty?
268
284
check_text
269
285
end
0 commit comments