-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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(arm): AzureDefenderOStorage #6269
Merged
ChanochShayner
merged 24 commits into
bridgecrewio:main
from
shoshiGit:AzureDefenderOnStorage1
May 22, 2024
Merged
Changes from 19 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
f31821d
Storage Sync Public Access Disabled as arm
shoshiGit 61b10d6
Storage Sync Public Access Disabled as arm
shoshiGit 787f41d
Merge branch 'bridgecrewio:main' into main
shoshiGit 06e5548
Revert "Storage Sync Public Access Disabled as arm"
shoshiGit 450b6a9
Merge branch 'bridgecrewio:main' into main
shoshiGit 133b8b1
remove unneccessary file1
shoshiGit bb54b86
remove unneccessary file2
shoshiGit e624bfa
AzureDefenderOnStorage
shoshiGit a832df5
Merge remote-tracking branch 'origin/AzureDefenderOnStorage1' into Az…
shoshiGit f03bdaa
AzureDefenderOnStorage updated resource file
shoshiGit 8aa10cf
AzureDefenderOnStorage fix resource type
shoshiGit ac67212
AzureDefenderOnStorage fix resourceType
shoshiGit 9be9136
AzureDefenderOnStorage fix 3
shoshiGit aa6334a
AzureDefenderOnStorage fix 4
shoshiGit ff32550
Merge branch 'main' into AzureDefenderOnStorage1
shoshiGit 908ebcf
AzureDefenderOnStorage fix 5
shoshiGit 63ce79b
Merge remote-tracking branch 'origin/AzureDefenderOnStorage1' into Az…
shoshiGit 9e70e3f
AzureDefenderOnStorage fix 5
shoshiGit 578f3d1
AzureDefenderOnStorage fix 5
shoshiGit cd9c8a7
AzureDefenderOnStorage fix 6
shoshiGit c1c8acc
Merge branch 'main' into AzureDefenderOnStorage1
shoshiGit 9ab6d1c
AzureDefenderOnStorage fix 7
shoshiGit 810d3f9
Merge remote-tracking branch 'origin/AzureDefenderOnStorage1' into Az…
shoshiGit 02a52aa
Merge branch 'main' into AzureDefenderOnStorage1
shoshiGit File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from typing import List, Any, Dict | ||
from checkov.common.models.enums import CheckCategories, CheckResult | ||
from checkov.arm.base_resource_check import BaseResourceCheck | ||
|
||
|
||
class AzureDefenderOnStorage(BaseResourceCheck): | ||
def __init__(self) -> None: | ||
name = "Ensure that Azure Defender is set to On for Storage" | ||
id = "CKV_AZURE_84" | ||
supported_resources = ("Microsoft.Security/pricings",) | ||
categories = (CheckCategories.GENERAL_SECURITY,) | ||
super().__init__(name=name, id=id, categories=categories, supported_resources=supported_resources) | ||
|
||
def scan_resource_conf(self, conf: Dict[str, Any]) -> CheckResult: | ||
properties: Dict[str, Any] = conf.get("properties", {}) | ||
pricingTier = properties.get("pricingTier", "") | ||
resourceType = properties.get("resourceType", "") | ||
return ( | ||
CheckResult.PASSED | ||
if resourceType != "Microsoft.Security/pricings" or pricingTier == "Standard" | ||
else CheckResult.FAILED | ||
) | ||
|
||
def get_evaluated_keys(self) -> List[str]: | ||
return ["properties/pricingTier", "properties/resourceType"] | ||
|
||
|
||
check = AzureDefenderOnStorage() |
15 changes: 15 additions & 0 deletions
15
tests/arm/checks/resource/example_AzureDefenderOnStorage/fail.json
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,15 @@ | ||
{ | ||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | ||
"contentVersion": "1.0.0.0", | ||
"resources": [ | ||
{ | ||
"type": "Microsoft.Security/pricings", | ||
"apiVersion": "2018-06-01", | ||
"name": "fail", | ||
"properties": { | ||
"pricingTier": "Free", | ||
"resourceType": "Microsoft.Security/pricings" | ||
} | ||
} | ||
] | ||
} |
15 changes: 15 additions & 0 deletions
15
tests/arm/checks/resource/example_AzureDefenderOnStorage/pass.json
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,15 @@ | ||
{ | ||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | ||
"contentVersion": "1.0.0.0", | ||
"resources": [ | ||
{ | ||
"type": "Microsoft.Security/pricings", | ||
"apiVersion": "2018-06-01", | ||
"name": "pass", | ||
"properties": { | ||
"pricingTier": "Standard", | ||
"resourceType": "Microsoft.Security/pricings" | ||
} | ||
} | ||
] | ||
} |
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,33 @@ | ||
import unittest | ||
from checkov.arm.checks.resource.AzureDefenderOnStorage import check | ||
from pathlib import Path | ||
from checkov.arm.runner import Runner | ||
from checkov.runner_filter import RunnerFilter | ||
|
||
|
||
class TestAzureDefenderOnStorage(unittest.TestCase): | ||
def test_summary(self): | ||
test_files_dir = Path(__file__).parent / "example_AzureDefenderOnStorage" | ||
report = Runner().run(root_folder=str(test_files_dir), runner_filter=RunnerFilter(checks=[check.id])) | ||
summary = report.get_summary() | ||
passing_resources = { | ||
"Microsoft.Security/pricings.pass", | ||
} | ||
failing_resources = { | ||
"Microsoft.Security/pricings.fail", | ||
} | ||
|
||
passed_check_resources = {c.resource for c in report.passed_checks} | ||
failed_check_resources = {c.resource for c in report.failed_checks} | ||
|
||
self.assertEqual(summary["passed"], len(passing_resources)) | ||
self.assertEqual(summary["failed"], len(failing_resources)) | ||
self.assertEqual(summary["skipped"], 0) | ||
self.assertEqual(summary["parsing_errors"], 0) | ||
|
||
self.assertEqual(passed_check_resources, passing_resources) | ||
self.assertEqual(failed_check_resources, failing_resources) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove the
if resourceType != "Microsoft.Security/pricings"
- in ARM it will always be this type.(Just for terraform it can be other types as well)