-
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.
enforce encryption flag to be string for CKV_AZURE_97
- Loading branch information
Showing
3 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
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: 23 additions & 0 deletions
23
tests/bicep/checks/resource/azure/example_VMEncryptionAtHostEnabled/main.bicep
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// pass | ||
|
||
resource enabled 'Microsoft.Compute/virtualMachines@2021-11-01' = { | ||
name: virtualMachineName | ||
location: location | ||
properties: { | ||
securityProfile: { | ||
encryptionAtHost: true | ||
} | ||
} | ||
} | ||
|
||
// fail | ||
|
||
resource disabled 'Microsoft.Compute/virtualMachines@2021-11-01' = { | ||
name: virtualMachineName | ||
location: location | ||
properties: { | ||
securityProfile: { | ||
encryptionAtHost: false | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
tests/bicep/checks/resource/azure/test_VMEncryptionAtHostEnabled.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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from pathlib import Path | ||
|
||
from checkov.bicep.runner import Runner | ||
from checkov.arm.checks.resource.VMEncryptionAtHostEnabled import check | ||
from checkov.runner_filter import RunnerFilter | ||
|
||
|
||
def test_examples(): | ||
# given | ||
test_files_dir = Path(__file__).parent / "example_VMEncryptionAtHostEnabled" | ||
|
||
# when | ||
report = Runner().run(root_folder=str(test_files_dir), runner_filter=RunnerFilter(checks=[check.id])) | ||
|
||
# then | ||
summary = report.get_summary() | ||
|
||
passing_resources = { | ||
"Microsoft.Compute/virtualMachines.enabled", | ||
} | ||
|
||
failing_resources = { | ||
"Microsoft.Compute/virtualMachines.disabled", | ||
} | ||
|
||
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"] == len(passing_resources) | ||
assert summary["failed"] == len(failing_resources) | ||
assert summary["skipped"] == 0 | ||
assert summary["parsing_errors"] == 0 | ||
|
||
assert passed_check_resources == passing_resources | ||
assert failed_check_resources == failing_resources |