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

fix: logic error on a rego policy "Review origin transport configuration" #13

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions workflows/csp/aws-fsbp/cloudfront/transport/decide.rego
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ decisions[d] {
dist := account.cloudFront.distributions[_]

behaviors := cache_behaviors(dist)
allowed := includes_unallowed_behavior(behaviors)
allowed := includes_unallowed_behavior(behaviors) == false
d := shisho.decision.aws.cloudfront.transport({
"allowed": allow_if_excluded(allowed, dist),
"subject": dist.metadata.id,
Expand All @@ -17,7 +17,7 @@ decisions[d] {

cache_behaviors(dist) = array.concat(
[{
"path_pattern": cb.pathPattern,
"path_pattern": "",
"target_origin_id": cb.targetOriginId,
"viewer_protocol_policy": cb.viewerProtocolPolicy,
} |
Expand Down
17 changes: 1 addition & 16 deletions workflows/csp/aws-fsbp/cloudfront/transport/decide_test.rego
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ test_permissive_protocol_policy_will_be_denied if {
test_strict_protocol_policy_will_be_denied if {
count([d |
decisions[d]
not shisho.decision.is_allowed(d)
shisho.decision.is_allowed(d)
]) == 1 with input as {"aws": {"accounts": [{"cloudFront": {"distributions": [{
"metadata": {"id": "aws-cloudfront-distribution|EAA4TFOSOK0BL"},
"defaultCacheBehavior": {
Expand All @@ -45,19 +45,6 @@ test_strict_protocol_policy_will_be_denied if {
"cacheBehaviors": [],
}]}}]}}

count([d |
decisions[d]
not shisho.decision.is_allowed(d)
]) == 1 with input as {"aws": {"accounts": [{"cloudFront": {"distributions": [{
"metadata": {"id": "aws-cloudfront-distribution|EAA4TFOSOK0BL"},
"defaultCacheBehavior": {
"targetOriginId": "test-bucket.s3.ap-northeast-1.amazonaws.com",
"viewerProtocolPolicy": "REDIRECT_TO_HTTPS",
},
"cacheBehaviors": [],
}]}}]}}

# check tag_exceptions works
count([d |
decisions[d]
shisho.decision.is_allowed(d)
Expand All @@ -68,7 +55,5 @@ test_strict_protocol_policy_will_be_denied if {
"viewerProtocolPolicy": "REDIRECT_TO_HTTPS",
},
"cacheBehaviors": [],
"tags": [{"key": "foo", "value": "bar=piyo"}],
}]}}]}}
with data.params as {"tag_exceptions": ["foo=bar=piyo"]}
}
Loading