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

feat(cloudformation): Adding Sse property to SQS Encryption check #5870

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 10 additions & 10 deletions checkov/cloudformation/checks/resource/aws/SQSQueueEncryption.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
from typing import Any
from checkov.common.models.enums import CheckCategories, CheckResult
from checkov.cloudformation.checks.resource.base_resource_value_check import BaseResourceCheck

from checkov.common.models.enums import CheckCategories
from checkov.cloudformation.checks.resource.base_resource_value_check import BaseResourceValueCheck
from checkov.common.models.consts import ANY_VALUE


class SQSQueueEncryption(BaseResourceValueCheck):
class SQSQueueEncryption(BaseResourceCheck):
def __init__(self) -> None:
name = "Ensure all data stored in the SQS queue is encrypted"
id = "CKV_AWS_27"
supported_resources = ['AWS::SQS::Queue']
categories = [CheckCategories.ENCRYPTION]
super().__init__(name=name, id=id, categories=categories, supported_resources=supported_resources)

def get_inspected_key(self) -> str:
return 'Properties/KmsMasterKeyId'
def scan_resource_conf(self, conf):
properties = conf.get("Properties", {})
kms_key_id_value = properties.get("KmsMasterKeyId")
sse_enabled_value = properties.get("SqsManagedSseEnabled")

def get_expected_value(self) -> Any:
return ANY_VALUE
if kms_key_id_value or sse_enabled_value:
return CheckResult.PASSED
return CheckResult.FAILED


check = SQSQueueEncryption()
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
AWSTemplateFormatVersion: "2010-09-09"
Resources:
MySourceQueue:
Type: AWS::SQS::Queue
Properties:
RedrivePolicy:
deadLetterTargetArn: "example_arn"
maxReceiveCount: 5
SqsManagedSseEnabled: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
AWSTemplateFormatVersion: "2010-09-09"
Resources:
MySourceQueue:
Type: AWS::SQS::Queue
Properties:
RedrivePolicy:
deadLetterTargetArn: "example_arn"
maxReceiveCount: 5
SqsManagedSseEnabled: true
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def test_summary(self):
report = runner.run(root_folder=test_files_dir, runner_filter=RunnerFilter(checks=[check.id]))
summary = report.get_summary()

self.assertEqual(summary['passed'], 1)
self.assertEqual(summary['failed'], 2)
self.assertEqual(summary['passed'], 2)
self.assertEqual(summary['failed'], 3)
self.assertEqual(summary['skipped'], 0)
self.assertEqual(summary['parsing_errors'], 0)

Expand Down
Loading