Skip to content
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

Add common dimensions and tag dimensions to AWS Compliance Mod #574

Merged
merged 36 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
991e258
initial commit
khushboo9024 Mar 6, 2023
d0f5b76
update dimensions for wafv2, vpc, ssm, sqs, sns, securityhub, secrets…
madhushreeray30 Mar 6, 2023
15a8368
added common dimensio for apigateway, autoscaling and backup
khushboo9024 Mar 6, 2023
22bdc66
update dimensions for sagemaker, s3, route53, redshift
madhushreeray30 Mar 6, 2023
18aee3d
Merge branch 'staging/v0.58' of https://github.com/turbot/steampipe-m…
madhushreeray30 Mar 6, 2023
a1e9faa
update dimensions for rds, lambda, kms, kinesis, iam
madhushreeray30 Mar 6, 2023
e260112
change query name
madhushreeray30 Mar 6, 2023
5522573
update dimension for guardduty, glue, fsx, es, emr, elb, elasticbeans…
madhushreeray30 Mar 6, 2023
6741fa1
delete query
madhushreeray30 Mar 6, 2023
a4ea565
update
khushboo9024 Mar 6, 2023
bf90ab3
update dimension for kms, iam, ebs, dynamodb, cloudwatch
madhushreeray30 Mar 8, 2023
557dbca
update queries
madhushreeray30 Mar 8, 2023
3de5628
correct syntax error
madhushreeray30 Mar 8, 2023
23ecb7a
Remove manual control query
madhushreeray30 Mar 9, 2023
0f6104e
add manual query
madhushreeray30 Mar 9, 2023
c83e897
update as per review comments
madhushreeray30 Mar 10, 2023
864d718
Merge branch 'release/v0.58' of https://github.com/turbot/steampipe-m…
madhushreeray30 Mar 10, 2023
71d1b01
Adjust extra check queries
madhushreeray30 Mar 10, 2023
2c0ec4b
Migrate autoscaling & apigateway queries to conformance pack
rajlearner17 Mar 14, 2023
a68dc8b
update tags
madhushreeray30 Mar 14, 2023
7d9d130
update tags and common dimensions
madhushreeray30 Mar 14, 2023
e042597
shift query into service.sp files
madhushreeray30 Mar 14, 2023
c1e4108
move query from query file to service.sp files
madhushreeray30 Mar 15, 2023
1707fd8
update
madhushreeray30 Mar 15, 2023
e7957cd
Tidy up comments
rajlearner17 Mar 15, 2023
3917240
Remove unwanted required column
rajlearner17 Mar 15, 2023
b55e502
update tags
madhushreeray30 Mar 16, 2023
2ccdf98
update tags
madhushreeray30 Mar 16, 2023
6a08500
update tags
madhushreeray30 Mar 16, 2023
220e07b
update tags changes
madhushreeray30 Mar 16, 2023
01f541c
update docs
madhushreeray30 Mar 17, 2023
5923988
update query
khushboo9024 Mar 17, 2023
dc319de
Remove -- Additional Dimensions comment
rajlearner17 Mar 20, 2023
8c2621b
remove Required Columns and additional domensions comments from query
khushboo9024 Mar 21, 2023
8a80a64
update
khushboo9024 Mar 22, 2023
a635ff4
update index.md file
khushboo9024 Mar 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@

# Swap files
*.swp

# Steampipe variable files
*.spvars
*.auto.spvars
33 changes: 33 additions & 0 deletions conformance_pack/account.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Non-Config rule query
query "account_alternate_contact_security_registered" {
sql = <<-EOQ
with alternate_security_contact as (
select
name,
account_id
from
aws_account_alternate_contact
where
contact_type = 'SECURITY'
)
select
-- Required Columns
arn as resource,
case
when a.partition = 'aws-us-gov' then 'info'
-- Name is a required field if setting a security contact
when c.name is not null then 'ok'
else 'alarm'
end as status,
case
when a.partition = 'aws-us-gov' then a.title || ' in GovCloud, manual verification required.'
when c.name is not null then a.title || ' has security contact ' || c.name || ' registered.'
else a.title || ' security contact not registered.'
end as reason
-- Additional Dimensions
${replace(local.common_dimensions_qualifier_global_sql, "__QUALIFIER__", "a.")}
from
aws_account as a
left join alternate_security_contact as c on c.account_id = a.account_id;
EOQ
}
67 changes: 67 additions & 0 deletions conformance_pack/acm.sp
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,70 @@ control "acm_certificate_no_wildcard_domain_name" {
other_checks = "true"
})
}

query "acm_certificate_expires_30_days" {
sql = <<-EOQ
select
-- Required Columns
certificate_arn as resource,
case
when renewal_eligibility = 'INELIGIBLE' then 'skip'
when date(not_after) - date(current_date) >= 30 then 'ok'
else 'alarm'
end as status,
case
when renewal_eligibility = 'INELIGIBLE' then title || ' not eligible for renewal.'
else title || ' expires ' || to_char(not_after, 'DD-Mon-YYYY') ||
' (' || extract(day from not_after - current_date) || ' days).'
end as reason
-- Additional Dimensions
${local.tag_dimensions_sql}
${local.common_dimensions_sql}
from
aws_acm_certificate;
EOQ
}

query "acm_certificate_no_wildcard_domain_name" {
sql = <<-EOQ
select
-- Required Columns
certificate_arn as resource,
case
when domain_name like '*%' then 'alarm'
else 'ok'
end as status,
case
when domain_name like '*%' then title || ' uses wildcard domain name.'
else title || ' does not use wildcard domain name.'
end as reason
-- Additional Dimensions
${local.tag_dimensions_sql}
${local.common_dimensions_sql}
from
aws_acm_certificate;
EOQ
}

query "acm_certificate_transparency_logging_enabled" {
sql = <<-EOQ
select
-- Required Columns
certificate_arn as resource,
case
when type = 'IMPORTED' then 'skip'
when certificate_transparency_logging_preference = 'ENABLED' then 'ok'
else 'alarm'
end as status,
case
when type = 'IMPORTED' then title || ' is imported.'
when certificate_transparency_logging_preference = 'ENABLED' then title || ' transparency logging enabled.'
else title || ' transparency logging disabled.'
end as reason
-- Additional Dimensions
${local.tag_dimensions_sql}
${local.common_dimensions_sql}
from
aws_acm_certificate;
EOQ
}
194 changes: 194 additions & 0 deletions conformance_pack/apigateway.sp
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,197 @@ control "apigateway_rest_api_authorizers_configured" {
other_checks = "true"
})
}

query "apigateway_stage_cache_encryption_at_rest_enabled" {
sql = <<-EOQ
select
-- Required Columns
'arn:' || partition || ':apigateway:' || region || '::/apis/' || rest_api_id || '/stages/' || name as resource,
case
when method_settings -> '*/*' ->> 'CachingEnabled' = 'true'
and method_settings -> '*/*' ->> 'CacheDataEncrypted' = 'true' then 'ok'
else 'alarm'
end as status,
case
when method_settings -> '*/*' ->> 'CachingEnabled' = 'true'
and method_settings -> '*/*' ->> 'CacheDataEncrypted' = 'true'
then title || ' API cache and encryption enabled.'
else title || ' API cache and encryption not enabled.'
end as reason
-- Additional Dimensions
${local.tag_dimensions_sql}
${local.common_dimensions_sql}
from
aws_api_gateway_stage;
EOQ
}

query "apigateway_stage_logging_enabled" {
sql = <<-EOQ
with all_stages as (
select
name as stage_name,
'arn:' || partition || ':apigateway:' || region || '::/apis/' || rest_api_id || '/stages/' || name as arn,
method_settings -> '*/*' ->> 'LoggingLevel' as log_level,
title,
region,
account_id
from
aws_api_gateway_stage
union
select
stage_name,
'arn:' || partition || ':apigateway:' || region || '::/apis/' || api_id || '/stages/' || stage_name as arn,
default_route_logging_level as log_level,
title,
region,
account_id
from
aws_api_gatewayv2_stage
)
select
-- Required Columns
arn as resource,
case
when log_level is null or log_level = '' or log_level = 'OFF' then 'alarm'
else 'ok'
end as status,
case
when log_level is null or log_level = '' or log_level = 'OFF' then title || ' logging not enabled.'
else title || ' logging enabled.'
end as reason
-- Additional Dimensions
${local.tag_dimensions_sql}
${local.common_dimensions_sql}
from
all_stages;
EOQ
}

query "apigateway_rest_api_stage_use_ssl_certificate" {
sql = <<-EOQ
select
-- Required Columns
arn as resource,
case
when client_certificate_id is null then 'alarm'
else 'ok'
end as status,
case
when client_certificate_id is null then title || ' does not use SSL certificate.'
else title || ' uses SSL certificate.'
end as reason
-- Additional Dimensions
${local.tag_dimensions_sql}
${local.common_dimensions_sql}
from
aws_api_gateway_stage;
EOQ
}

query "apigateway_stage_use_waf_web_acl" {
sql = <<-EOQ
select
-- Required Columns
arn as resource,
case
when web_acl_arn is not null then 'ok'
else 'alarm'
end as status,
case
when web_acl_arn is not null then title || ' associated with WAF web ACL.'
else title || ' not associated with WAF web ACL.'
end as reason
-- Additional Dimensions
${local.tag_dimensions_sql}
${local.common_dimensions_sql}
from
aws_api_gateway_stage;
EOQ
}

query "apigateway_rest_api_authorizers_configured" {
sql = <<-EOQ
select
-- Required Columns
p.name as resource,
case
when jsonb_array_length(a.provider_arns) > 0 then 'ok'
else 'alarm'
end as status,
case
when jsonb_array_length(a.provider_arns) > 0 then p.name || ' authorizers configured.'
else p.name || ' authorizers not configured.'
end as reason
-- Additional Dimensions
${local.tag_dimensions_sql}
${replace(local.common_dimensions_qualifier_sql, "__QUALIFIER__", "p.")}
from
aws_api_gateway_rest_api as p
left join aws_api_gateway_authorizer as a on p.api_id = a.rest_api_id;
EOQ
}

# Non-Config rule query

query "api_gatewayv2_route_authorization_type_configured" {
sql = <<-EOQ
select
-- Required Columns
'arn:' || partition || ':apigateway:' || region || '::/apis/' || api_id || '/routes/' || route_id as resource,
case
when authorization_type is null then 'alarm'
else 'ok'
end as status,
case
when authorization_type is null then route_id || ' authorization type not configured.'
else route_id || ' authorization type ' || authorization_type || ' configured.'
end as reason
-- Additional Dimensions
${local.common_dimensions_sql}
from
aws_api_gatewayv2_route;
EOQ
}

query "apigateway_rest_api_stage_xray_tracing_enabled" {
sql = <<-EOQ
select
-- Required Columns
arn as resource,
case
when tracing_enabled then 'ok'
else 'alarm'
end as status,
case
when tracing_enabled then title || ' X-Ray tracing enabled.'
else title || ' X-Ray tracing disabled.'
end as reason
-- Additional Dimensions
${local.tag_dimensions_sql}
${local.common_dimensions_sql}
from
aws_api_gateway_stage;
EOQ
}

query "gatewayv2_stage_access_logging_enabled" {
sql = <<-EOQ
select
-- Required Columns
'arn:' || partition || ':apigateway:' || region || '::/apis/' || api_id || '/stages/' || stage_name as resource,
case
when access_log_settings is null then 'alarm'
else 'ok'
end as status,
case
when access_log_settings is null then title || ' access logging disabled.'
else title || ' access logging enabled.'
end as reason
-- Additional Dimensions
${local.tag_dimensions_sql}
${local.common_dimensions_sql}
from
aws_api_gatewayv2_stage;
EOQ
}
Loading