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(bicep): ignore unresolvable properties for Bicep storage account checks #3946

Merged
merged 1 commit into from
Nov 27, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ def scan_resource_conf(self, conf: dict[str, Any]) -> CheckResult:
self.evaluated_keys = ["properties/networkAcls/defaultAction"]
properties = conf.get("properties")
if properties:
if not isinstance(properties, dict):
return CheckResult.UNKNOWN

nacls = properties.get("networkAcls")
if nacls:
default_action = nacls.get("defaultAction")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def scan_resource_conf(self, conf: dict[str, Any]) -> CheckResult:
self.evaluated_keys = ["properties/supportsHttpsTrafficOnly"]
properties = conf.get("properties")
if properties:
if not isinstance(properties, dict):
return CheckResult.UNKNOWN

https_only = properties.get("supportsHttpsTrafficOnly")
if https_only is True:
return CheckResult.PASSED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,16 @@ resource denyAndBypassNone 'Microsoft.Storage/storageAccounts@2019-06-01' = {
}
}
}

// unknown

resource unknown 'Microsoft.Storage/storageAccounts@2019-06-01' = {
name: diagStorageAccountName
location: location
sku: {
name: storageAccountType
}
kind: 'StorageV2'

properties: storageAccountProperties
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,17 @@ resource disabled 'Microsoft.Storage/storageAccounts@2019-06-01' = {
supportsHttpsTrafficOnly: false
}
}

// unknown

resource unknown 'Microsoft.Storage/storageAccounts@2019-06-01' = {
name: diagStorageAccountName
location: location
sku: {
name: storageAccountType
}
kind: 'StorageV2'

properties: storageAccountProperties
}

Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ def test_examples():
passed_check_resources = {c.resource for c in report.passed_checks}
failed_check_resources = {c.resource for c in report.failed_checks}

assert summary["passed"] == 3
assert summary["failed"] == 2
assert summary["passed"] == len(passing_resources)
assert summary["failed"] == len(failing_resources)
assert summary["skipped"] == 0
assert summary["parsing_errors"] == 0
assert summary["resource_count"] == len(passing_resources) + len(failing_resources) + 1 # unknown

assert passed_check_resources == passing_resources
assert failed_check_resources == failing_resources
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ def test_examples():
passed_check_resources = {c.resource for c in report.passed_checks}
failed_check_resources = {c.resource for c in report.failed_checks}

assert summary["passed"] == 2
assert summary["failed"] == 2
assert summary["passed"] == len(passing_resources)
assert summary["failed"] == len(failing_resources)
assert summary["skipped"] == 0
assert summary["parsing_errors"] == 0
assert summary["resource_count"] == len(passing_resources) + len(failing_resources) + 1 # unknown

assert passed_check_resources == passing_resources
assert failed_check_resources == failing_resources