Skip to content
Open
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
47 changes: 47 additions & 0 deletions src/python/rules/partial_encryption/partial_encryption.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't see findings for this.

# SPDX-License-Identifier: Apache-2.0

# {fact rule=partial-encryption@v1.0 defects=1}
def put_object_if_else_noncompliant():
import boto3
client = boto3.client('s3')
# Noncompliant: the data is not encrypted on all branches of a conditional.
if(some_condition):
client.put_object(
Body='filetoupload',
Bucket='examplebucket',
Key='objectkey',
SSEKMSKeyId="keyId"
)
else:
client.put_object(
Body='filetoupload',
Bucket='examplebucket',
Key='objectkey'
)
# {/fact}


# {fact rule=partial-encryption@v1.0 defects=0}
def put_object_if_else_compliant():
import boto3
client = boto3.client('s3')
# Compliant: the data is encrypted on all branches of the conditional.
if(some_condition):
some_intermediate_step = 1
client.put_object(
Body='filetoupload',
Bucket='examplebucket',
Key='objectkey',
SSECustomerKey="keyId"
)
some_intermediate_step = 1
else:
some_intermediate_step = 1
client.put_object(
Body='filetoupload',
Bucket='examplebucket',
Key='objectkey',
SSECustomerKey="keyId")
some_intermediate_step = 1
# {/fact}