Skip to content

Commit 0540a85

Browse files
authored
Merge pull request #54 from kaytu-io/fix-controls
fix: add include_potential to GetBenchmarkAssignments
2 parents 16c4436 + 3ca928f commit 0540a85

15 files changed

+103
-32
lines changed

policies/controls/aws/aws_cis_v130_1_17.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ Query:
2828
)
2929
select
3030
resource,
31-
a.kaytu_account_id as kaytu_account_id,
32-
a.kaytu_resource_id as kaytu_resource_id,
31+
account_id as kaytu_account_id,
32+
resource as kaytu_resource_id,
3333
case
3434
when count > 0 then 'ok'
3535
else 'alarm'

policies/controls/aws/aws_cloudformation_stack_output_no_secrets.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ Query:
1616
tags,
1717
_ctx,
1818
outputs,
19-
title
19+
title,
20+
kaytu_account_id as kaytu_account_id,
21+
kaytu_resource_id as kaytu_resource_id
2022
from
2123
aws_cloudformation_stack
2224
),

policies/controls/aws/aws_codebuild_project_build_greater_then_90_days.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ Query:
2727
account_id,
2828
title,
2929
tags,
30-
_ctx
30+
_ctx,
31+
kaytu_account_id as kaytu_account_id,
32+
kaytu_resource_id as kaytu_resource_id
3133
from
3234
aws_codebuild_project
3335
group by
@@ -37,7 +39,9 @@ Query:
3739
title,
3840
region,
3941
account_id,
40-
_ctx
42+
_ctx,
43+
kaytu_account_id,
44+
kaytu_resource_id
4145
)
4246
select
4347
p.arn as resource,

policies/controls/aws/aws_dlm_ebs_snapshot_lifecycle_policy_enabled.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ Query:
1111
distinct region,
1212
partition,
1313
account_id,
14-
_ctx
14+
_ctx,
15+
kaytu_account_id as kaytu_account_id,
16+
kaytu_resource_id as kaytu_resource_id
1517
from
1618
aws_ebs_snapshot
1719
), dlm_ebs_lifecycle_policy as (

policies/controls/aws/aws_ec2_ami_ebs_encryption_enabled.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Query:
2727
select
2828
resource,
2929
e.account_id as kaytu_account_id,
30-
e.image_id as kaytu_resource_id,
30+
resource as kaytu_resource_id,
3131
case
3232
when all_encrypted then 'ok'
3333
else 'alarm'

policies/controls/aws/aws_ec2_instance_no_iam_role_with_cloud_log_tampering_access.yaml

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,55 @@ Connector:
66
Query:
77
Engine: odysseus-v0.0.1
88
QueryToExecute: |-
9+
with iam_roles as (
10+
select
11+
r.arn as role_arn,
12+
i.arn as intance_arn,
13+
i.kaytu_account_id as kaytu_account_id,
14+
i.kaytu_account_id as kaytu_account_id
15+
from
16+
aws_iam_role as r,
17+
jsonb_array_elements_text(instance_profile_arns) as p
18+
left join aws_ec2_instance as i on p = i.iam_instance_profile_arn
19+
where
20+
i.arn is not null
21+
),
22+
iam_role_with_permission as (
23+
select
24+
arn
25+
from
26+
aws_iam_role,
27+
jsonb_array_elements(assume_role_policy_std -> 'Statement') as s,
28+
jsonb_array_elements_text(s -> 'Principal' -> 'Service') as service,
29+
jsonb_array_elements_text(s -> 'Action') as action
30+
where
31+
arn in (
32+
select
33+
role_arn
34+
from
35+
iam_roles
36+
)
37+
and s ->> 'Effect' = 'Allow'
38+
and service = 'ec2.amazonaws.com'
39+
and action in (
40+
'srds-data:ExecuteStatement',
41+
'rds-data:BatchExecuteStatement',
42+
'*:*'
43+
)
44+
)
945
select
1046
i.arn as resource,
1147
i.kaytu_account_id as kaytu_account_id,
12-
i.kaytu_resource_id as kaytu_resource_id,
48+
i.kaytu_account_id as kaytu_account_id,
1349
case
1450
when p.arn is null then 'ok'
1551
else 'alarm'
1652
end status,
1753
case
18-
when p.arn is null then title || ' has no IAM role with cloud log tampering access.'
19-
else title || ' has IAM role with cloud log tampering access.'
20-
end as reason
54+
when p.arn is null then title || ' has no IAM role with destruction RDS permission.'
55+
else title || ' has IAM role with destruction RDS permission.'
56+
end as reason,
57+
i.account_id
2158
from
2259
aws_ec2_instance as i
2360
left join iam_roles as r on r.intance_arn = i.arn

policies/controls/aws/aws_ecr_repository_prohibit_public_access.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Query:
3737
aws_ecr_repository as r
3838
left join open_access_ecr_repo as o on r.arn = o.arn
3939
group by
40-
resource, status, reason, r.region, r.account_id, r.tags, r._ctx;
40+
resource, status, reason, r.region, r.account_id, r.tags, r._ctx, r.kaytu_account_id, r.kaytu_resource_id
4141
PrimaryTable: aws_ecr_repository
4242
ListOfTables:
4343
- aws_ecr_repository

policies/controls/aws/aws_elasticache_replication_group_encryption_at_rest_enabled_with_kms_cmk.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ Query:
1414
kms_key_id,
1515
region,
1616
account_id,
17-
_ctx
17+
_ctx,
18+
kaytu_account_id as kaytu_account_id,
19+
kaytu_resource_id as kaytu_resource_id
1820
from
1921
aws_elasticache_replication_group
2022
order by

policies/controls/aws/aws_elb_application_classic_network_lb_prohibit_public_access.yaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ Query:
1414
region,
1515
account_id,
1616
tags,
17-
_ctx
17+
_ctx,
18+
kaytu_account_id,
19+
kaytu_resource_id
1820
from
1921
aws_ec2_application_load_balancer
2022
union
@@ -25,7 +27,9 @@ Query:
2527
region,
2628
account_id,
2729
tags,
28-
_ctx
30+
_ctx,
31+
kaytu_account_id,
32+
kaytu_resource_id
2933
from
3034
aws_ec2_network_load_balancer
3135
union
@@ -36,7 +40,9 @@ Query:
3640
region,
3741
account_id,
3842
tags,
39-
_ctx
43+
_ctx,
44+
kaytu_account_id,
45+
kaytu_resource_id
4046
from
4147
aws_ec2_classic_load_balancer
4248
)

policies/controls/aws/aws_elb_application_network_lb_use_listeners.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ Query:
2929
)
3030
select
3131
distinct lb.arn as resource,
32-
lb.kaytu_account_id as kaytu_account_id,
33-
lb.kaytu_resource_id as kaytu_resource_id,
32+
l.kaytu_account_id as kaytu_account_id,
33+
l.kaytu_resource_id as kaytu_resource_id,
3434
case
3535
when l.load_balancer_arn is not null then 'ok'
3636
else 'alarm'

0 commit comments

Comments
 (0)