@@ -38,8 +38,8 @@ def initialize(custom_mapping, endpoint = nil, verbose = false)
3838 def to_hdf
3939 controls = @issues . map do |issue |
4040 @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] } "
4343 @item [ 'desc' ] = issue [ :description ]
4444 @item [ 'impact' ] = 0.5
4545 @item [ 'tags' ] = hdf_tags ( issue )
@@ -55,6 +55,7 @@ def to_hdf
5555 @item
5656 end
5757 end
58+
5859 results = HeimdallDataFormat . new (
5960 profile_name : 'AWS Config' ,
6061 title : 'AWS Config' ,
@@ -67,6 +68,20 @@ def to_hdf
6768
6869 private
6970
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+
7085 ##
7186 # Read in a config rule -> 800-53 control mapping CSV.
7287 #
@@ -263,7 +278,8 @@ def check_text(config_rule)
263278 # If no input parameters, then provide an empty JSON array to the JSON
264279 # parser because passing nil to JSON.parse throws an exception.
265280 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' } "
267283 check_text += "<br/>#{ params } " unless params . empty?
268284 check_text
269285 end
0 commit comments