-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(aws/cis): fix config query #325
feat(aws/cis): fix config query #325
Conversation
@ecktom appreciate the PR, we are checking to get it in. Thank you |
@ecktom thanks for the updated query, help me in understanding this. As per CIS v 1.4.0 (3.5)
Along with the above point, below must be also satisfying
Our interpretation was, whichever (at least one) region See the image as attached (executed by the modified query in this PR), ap-south-1 is enabled with IncludeGlobalResourceTypes but the Recording is disabled
|
Hi @rajlearner17, Thanks for looking into this! So this again is something which is not very well defined within the CIS Benchmark. Based on the Audit/Remediation I think it would be fine if you have a single region fulfilling:
Thus we could put this control on an OK state, if we only found a single region on which this combination applies, even though all other regions might be fully misconfigured. However, the Control also clearly states "It is recommended AWS Config be enabled in all regions". From my point of view, logically, this implies that we should also check for at leat I agree that we might want to make So more like
What do you think? |
@ecktom I think the suggestion is appropriate to freeze our interpretation for the time being, not sure if any other edge cases can come up to check further, pls take a look below query and share us your feedback -- pgFormatter-ignore
-- Get count for any region with all matching criteria
with global_recorders as (
select
count(*) as global_config_recorders
from
aws_config_configuration_recorder
where
recording_group -> 'IncludeGlobalResourceTypes' = 'true'
and recording_group -> 'AllSupported' = 'true'
and status ->> 'Recording' = 'true'
and status ->> 'LastStatus' = 'SUCCESS'
)
select
-- Required columns
'arn:aws::' || a.region || ':' || a.account_id as resource,
case
-- When any of the region satisfies with above CTE
-- In left join of <aws_config_configuration_recorder> table, regions now having
-- 'Recording' and 'LastStatus' matching criteria can be considered as OK
when
g.global_config_recorders >= 1
and status ->> 'Recording' = 'true'
and status ->> 'LastStatus' = 'SUCCESS'
then 'ok'
else 'alarm'
end as status,
-- Below cases are for citing respective reasons for control state
case
when recording_group -> 'IncludeGlobalResourceTypes' = 'true' then a.region || ' IncludeGlobalResourceTypes enabled,'
else a.region || ' IncludeGlobalResourceTypes disabled,'
end ||
case
when recording_group -> 'AllSupported' = 'true' then ' AllSupported enabled,'
else ' AllSupported disabled,'
end ||
case
when status ->> 'Recording' = 'true' then ' Recording enabled'
else ' Recording disabled'
end ||
case
when status ->> 'LastStatus' = 'SUCCESS' then ' and LastStatus is SUCCESS.'
else ' and LastStatus is not SUCCESS.'
end as reason,
-- Additional columns
a.region,
a.account_id
from
global_recorders as g,
aws_region as a
left join aws_config_configuration_recorder as r
on r.account_id = a.account_id and r.region = a.name; |
@rajlearner17 your query looks good and should do the trick. I also checked it in our environment and it worked as expected 👍 |
Output:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to release
This is a follow-up of #279 and also fixes #26.