-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
47 additions
and
58 deletions.
There are no files selected for viewing
22 changes: 12 additions & 10 deletions
22
checkov/cloudformation/checks/resource/aws/LambdaEnvironmentEncryptionSettings.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,32 @@ | ||
from typing import List | ||
from __future__ import annotations | ||
|
||
from typing import Any | ||
|
||
from checkov.common.models.enums import CheckResult, CheckCategories | ||
from checkov.cloudformation.checks.resource.base_resource_check import BaseResourceCheck | ||
|
||
|
||
class LambdaEnvironmentEncryptionSettings(BaseResourceCheck): | ||
def __init__(self): | ||
def __init__(self) -> None: | ||
name = "Check encryption settings for Lambda environmental variable" | ||
id = "CKV_AWS_173" | ||
supported_resources = ['AWS::Lambda::Function', "AWS::Serverless::Function"] | ||
categories = [CheckCategories.ENCRYPTION] | ||
supported_resources = ("AWS::Lambda::Function", "AWS::Serverless::Function") | ||
categories = (CheckCategories.ENCRYPTION,) | ||
super().__init__(name=name, id=id, categories=categories, supported_resources=supported_resources) | ||
|
||
def scan_resource_conf(self, conf): | ||
properties = conf.get('Properties') | ||
def scan_resource_conf(self, conf: dict[str, Any]) -> CheckResult: | ||
properties = conf.get("Properties") | ||
if properties is not None: | ||
env = properties.get('Environment') | ||
env = properties.get("Environment") | ||
if env is not None: | ||
if not isinstance(env, dict): | ||
return CheckResult.UNKNOWN | ||
elif env.get('Variables') and not properties.get('KmsKeyArn'): | ||
elif env.get("Variables") and not properties.get("KmsKeyArn"): | ||
return CheckResult.FAILED | ||
return CheckResult.PASSED | ||
|
||
def get_evaluated_keys(self) -> List[str]: | ||
return ['Properties/Environment/Variables', 'Properties/KmsKeyArn'] | ||
def get_evaluated_keys(self) -> list[str]: | ||
return ["Properties/KmsKeyArn"] | ||
|
||
|
||
check = LambdaEnvironmentEncryptionSettings() |
14 changes: 8 additions & 6 deletions
14
checkov/terraform/checks/resource/aws/EKSPublicAccessCIDR.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 10 additions & 13 deletions
23
checkov/terraform/checks/resource/azure/MariaDBPublicAccessDisabled.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,21 @@ | ||
from checkov.common.models.enums import CheckResult, CheckCategories | ||
from checkov.terraform.checks.resource.base_resource_value_check import BaseResourceCheck | ||
from typing import List | ||
from checkov.terraform.checks.resource.base_resource_value_check import BaseResourceValueCheck | ||
from typing import List, Any | ||
|
||
|
||
class MariaDBPublicAccessDisabled(BaseResourceCheck): | ||
def __init__(self): | ||
class MariaDBPublicAccessDisabled(BaseResourceValueCheck): | ||
def __init__(self) -> None: | ||
name = "Ensure 'public network access enabled' is set to 'False' for MariaDB servers" | ||
id = "CKV_AZURE_48" | ||
supported_resources = ['azurerm_mariadb_server'] | ||
categories = [CheckCategories.NETWORKING] | ||
supported_resources = ("azurerm_mariadb_server",) | ||
categories = (CheckCategories.NETWORKING,) | ||
super().__init__(name=name, id=id, categories=categories, supported_resources=supported_resources) | ||
|
||
def scan_resource_conf(self, conf): | ||
# Whether or not public network access is allowed for this server. Defaults to true. Which is not optimal | ||
if 'public_network_access_enabled' not in conf or conf['public_network_access_enabled'][0]: | ||
return CheckResult.FAILED | ||
return CheckResult.PASSED | ||
def get_inspected_key(self) -> str: | ||
return "public_network_access_enabled" | ||
|
||
def get_evaluated_keys(self) -> List[str]: | ||
return ['public_network_access_enabled'] | ||
def get_expected_value(self) -> Any: | ||
return False | ||
|
||
|
||
check = MariaDBPublicAccessDisabled() |
30 changes: 11 additions & 19 deletions
30
checkov/terraform/checks/resource/gcp/GKEClusterLogging.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,22 @@ | ||
from checkov.terraform.checks.resource.base_resource_check import BaseResourceCheck | ||
from checkov.common.models.enums import CheckResult, CheckCategories | ||
from typing import List | ||
|
||
from checkov.common.models.enums import CheckResult, CheckCategories | ||
from checkov.terraform.checks.resource.base_resource_negative_value_check import BaseResourceNegativeValueCheck | ||
|
||
|
||
class GKEClusterLogging(BaseResourceCheck): | ||
def __init__(self): | ||
class GKEClusterLogging(BaseResourceNegativeValueCheck): | ||
def __init__(self) -> None: | ||
name = "Ensure Stackdriver Logging is set to Enabled on Kubernetes Engine Clusters" | ||
id = "CKV_GCP_1" | ||
supported_resources = ['google_container_cluster'] | ||
categories = [CheckCategories.KUBERNETES] | ||
supported_resources = ("google_container_cluster",) | ||
categories = (CheckCategories.KUBERNETES,) | ||
super().__init__(name=name, id=id, categories=categories, supported_resources=supported_resources) | ||
|
||
def scan_resource_conf(self, conf): | ||
""" | ||
Looks for password configuration at azure_instance: | ||
https://www.terraform.io/docs/providers/google/r/compute_ssl_policy.html | ||
:param conf: google_compute_ssl_policy configuration | ||
:return: <CheckResult> | ||
""" | ||
if 'logging_service' in conf.keys(): | ||
if conf['logging_service'][0] == "none": | ||
return CheckResult.FAILED | ||
return CheckResult.PASSED | ||
def get_inspected_key(self): | ||
return "logging_service" | ||
|
||
def get_evaluated_keys(self) -> List[str]: | ||
return ['logging_service'] | ||
def get_forbidden_values(self): | ||
return "none" | ||
|
||
|
||
check = GKEClusterLogging() |