Skip to content

Commit

Permalink
Merge branch 'main' into reduce-log-size
Browse files Browse the repository at this point in the history
  • Loading branch information
rotemavni committed Dec 17, 2024
2 parents 658a529 + a657e60 commit cfa9aa8
Show file tree
Hide file tree
Showing 33 changed files with 4,060 additions and 3,743 deletions.
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# CHANGELOG

## [Unreleased](https://github.com/bridgecrewio/checkov/compare/3.2.334...HEAD)
## [Unreleased](https://github.com/bridgecrewio/checkov/compare/3.2.336...HEAD)

## [3.2.336](https://github.com/bridgecrewio/checkov/compare/3.2.334...3.2.336) - 2024-12-16

### Feature

- **general:** add cortex:skip for suppressions - [#6908](https://github.com/bridgecrewio/checkov/pull/6908)

### Bug Fix

- **terraform:** fix CKV_AZURE_136 for replicas - [#6895](https://github.com/bridgecrewio/checkov/pull/6895)
- **terraform:** Fix CKV_AZURE_227 for Azure V4 - [#6906](https://github.com/bridgecrewio/checkov/pull/6906)

## [3.2.334](https://github.com/bridgecrewio/checkov/compare/3.2.332...3.2.334) - 2024-12-08

Expand Down
2 changes: 1 addition & 1 deletion checkov/arm/checks/resource/FunctionAppMinTLSVersion.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get_expected_value(self) -> Any:
return 1.2

def get_expected_values(self) -> List[Any]:
return ["1.2", 1.2]
return ["1.2", 1.2, "1.3", 1.3]


check = FunctionAppMinTLSVersion()
15 changes: 10 additions & 5 deletions checkov/arm/checks/resource/MySQLPublicAccessDisabled.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import List

from checkov.common.models.enums import CheckCategories
from checkov.arm.base_resource_value_check import BaseResourceValueCheck

Expand All @@ -6,18 +8,21 @@ class MySQLPublicAccessDisabled(BaseResourceValueCheck):
def __init__(self) -> None:
name = "Ensure 'public network access enabled' is set to 'False' for mySQL servers"
id = "CKV_AZURE_53"
supported_resources = ("Microsoft.DBforMySQL/servers",)
supported_resources = ("Microsoft.DBforMySQL/servers", "Microsoft.DBforMySQL/flexibleServers",)
categories = (CheckCategories.NETWORKING,)
super().__init__(name=name, id=id, categories=categories, supported_resources=supported_resources)

def get_inspected_key(self) -> str:
return "properties/publicNetworkAccess"
if self.entity_type == "Microsoft.DBforMySQL/servers":
return "properties/publicNetworkAccess"
else:
return "properties/network/publicNetworkAccess"

def get_expected_value(self) -> str:
"""
Returns the default expected value, governed by provider best practices
"""
return "disabled"

def get_expected_values(self) -> List[str]:
return ["disabled", "Disabled"]


check = MySQLPublicAccessDisabled()
2 changes: 1 addition & 1 deletion checkov/common/comment/enum.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import re

COMMENT_REGEX = re.compile(r'(checkov:skip=|bridgecrew:skip=) *([A-Za-z_\d]+(?:,[A-Za-z_\d]+)*)?(:[^\n]*)?')
COMMENT_REGEX = re.compile(r'(checkov:skip=|bridgecrew:skip=|cortex:skip=) *([A-Za-z_\d]+(?:,[A-Za-z_\d]+)*)?(:[^\n]*)?')
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ metadata:
definition:
or:
- cond_type: "attribute"
resource_types: "azurerm_sql_firewall_rule"
resource_types:
- "azurerm_sql_firewall_rule"
- "azurerm_mssql_firewall_rule"
attribute: "start_ip_address"
operator: "not_equals"
value: "0.0.0.0"

- cond_type: "attribute"
resource_types: "azurerm_sql_firewall_rule"
resource_types:
- "azurerm_sql_firewall_rule"
- "azurerm_mssql_firewall_rule"
attribute: "end_ip_address"
operator: "not_equals"
value: "0.0.0.0"
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ definition:
attribute: resource_type
value:
- azurerm_sql_server
- azurerm_mssql_server
operator: within
- resource_types:
- azurerm_sql_server
- azurerm_mssql_server
connected_resource_types:
- azurerm_mssql_server_security_alert_policy
operator: exists
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from checkov.common.models.enums import CheckCategories, CheckResult
from checkov.terraform.checks.resource.base_resource_value_check import BaseResourceValueCheck
from checkov.terraform.checks.resource.base_resource_check import BaseResourceCheck


class AKSEncryptionAtHostEnabled(BaseResourceValueCheck):
class AKSEncryptionAtHostEnabled(BaseResourceCheck):
def __init__(self) -> None:
"""
With host-based encryption, the data stored on the VM host of
Expand All @@ -22,14 +22,23 @@ def __init__(self) -> None:
id=id,
categories=categories,
supported_resources=supported_resources,
missing_block_result=CheckResult.FAILED,
)

def get_inspected_key(self) -> str:
def scan_resource_conf(self, conf) -> CheckResult:
if self.entity_type == "azurerm_kubernetes_cluster":
return "default_node_pool/[0]/enable_host_encryption"
if conf.get('default_node_pool'):
node_pool = conf['default_node_pool'][0]
if (node_pool.get('enable_host_encryption') == [True] or
node_pool.get('host_encryption_enabled') == [True]):
return CheckResult.PASSED
self.evaluated_keys = ['default_node_pool/[0]/enable_host_encryption',
'default_node_pool/[0]/host_encryption_enabled']
else:
return "enable_host_encryption"
if conf.get('enable_host_encryption') == [True] or conf.get('host_encryption_enabled') == [True]:
return CheckResult.PASSED
self.evaluated_keys = ['enable_host_encryption', 'host_encryption_enabled']

return CheckResult.FAILED


check = AKSEncryptionAtHostEnabled()
25 changes: 16 additions & 9 deletions checkov/terraform/checks/resource/azure/AKSNodePublicIpDisabled.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
from checkov.common.models.enums import CheckCategories
from checkov.terraform.checks.resource.base_resource_negative_value_check import BaseResourceNegativeValueCheck
from typing import List, Any
from typing import Dict, List, Any

from checkov.common.models.enums import CheckCategories, CheckResult
from checkov.terraform.checks.resource.base_resource_check import BaseResourceCheck

class AKSNodePublicIpDisabled(BaseResourceNegativeValueCheck):
def __init__(self):

class AKSNodePublicIpDisabled(BaseResourceCheck):
def __init__(self) -> None:
name = "Ensure AKS cluster nodes do not have public IP addresses"
id = "CKV_AZURE_143"
supported_resources = ['azurerm_kubernetes_cluster']
categories = [CheckCategories.NETWORKING]
super().__init__(name=name, id=id, categories=categories, supported_resources=supported_resources)

def get_inspected_key(self) -> str:
return "default_node_pool/[0]/enable_node_public_ip"
def scan_resource_conf(self, conf: Dict[str, List[Any]]) -> CheckResult:
if 'default_node_pool' in conf:
default_node_pool = conf['default_node_pool'][0]
if isinstance(default_node_pool, dict):
if default_node_pool.get('enable_node_public_ip') == [True] or default_node_pool.get('node_public_ip_enabled') == [True]:
return CheckResult.FAILED

return CheckResult.PASSED

def get_forbidden_values(self) -> List[Any]:
return [True]
def get_evaluated_keys(self) -> List[str]:
return ['default_node_pool/[0]/enable_node_public_ip', 'default_node_pool/[0]/node_public_ip_enabled']


check = AKSNodePublicIpDisabled()
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from typing import Any, List

from checkov.common.models.enums import CheckResult, CheckCategories
from checkov.terraform.checks.resource.base_resource_value_check import BaseResourceValueCheck


class FunctionAppMinTLSVersion(BaseResourceValueCheck):
def __init__(self):
def __init__(self) -> None:
"""
The minimum supported TLS version for the function app.
Defaults to 1.2 for new function apps.
Expand All @@ -20,17 +22,17 @@ def __init__(self):
super().__init__(name=name, id=id, categories=categories, supported_resources=supported_resources,
missing_block_result=CheckResult.PASSED)

def get_inspected_key(self):
def get_inspected_key(self) -> str:
if self.entity_type in ("azurerm_function_app", "azurerm_function_app_slot"):
return "site_config/[0]/min_tls_version"
else:
return "site_config/[0]/minimum_tls_version"

def get_expected_value(self):
def get_expected_value(self) -> float:
return 1.2

def get_expected_values(self):
return ["1.2", 1.2]
def get_expected_values(self) -> List[Any]:
return ["1.2", 1.2, "1.3", 1.3]


check = FunctionAppMinTLSVersion()
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def __init__(self):
'azurerm_sql_firewall_rule',
'azurerm_postgresql_firewall_rule',
'azurerm_mysql_firewall_rule',
'azurerm_mysql_flexible_server_firewall_rule',
'azurerm_mssql_firewall_rule',
)
categories = (CheckCategories.NETWORKING,)
super().__init__(name=name, id=id, categories=categories, supported_resources=supported_resources)
Expand Down
2 changes: 1 addition & 1 deletion checkov/terraform/context_parsers/base_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def _read_file_lines(self) -> List[Tuple[int, str]]:

@staticmethod
def is_optional_comment_line(line: str) -> bool:
return "checkov:skip=" in line or "bridgecrew:skip=" in line
return "checkov:skip=" in line or "bridgecrew:skip=" in line or "cortex:skip=" in line

def _collect_skip_comments(self, definition_blocks: List[Dict[str, Any]]) -> Dict[str, Any]:
"""
Expand Down
2 changes: 1 addition & 1 deletion checkov/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = '3.2.334'
version = '3.2.336'
Loading

0 comments on commit cfa9aa8

Please sign in to comment.