-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #198 from nikpivkin/go2rego-azure-1
refactor(checks): migrate Azure appservice, authorization, container to Rego
- Loading branch information
Showing
59 changed files
with
1,122 additions
and
770 deletions.
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
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
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
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
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
41 changes: 41 additions & 0 deletions
41
checks/cloud/azure/appservice/account_identity_registered.rego
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,41 @@ | ||
# METADATA | ||
# title: Web App has registration with AD enabled | ||
# description: | | ||
# Registering the identity used by an App with AD allows it to interact with other services without using username and password | ||
# scope: package | ||
# schemas: | ||
# - input: schema["cloud"] | ||
# custom: | ||
# id: AVD-AZU-0002 | ||
# avd_id: AVD-AZU-0002 | ||
# provider: azure | ||
# service: appservice | ||
# severity: LOW | ||
# short_code: account-identity-registered | ||
# recommended_action: Register the app identity with AD | ||
# input: | ||
# selector: | ||
# - type: cloud | ||
# subtypes: | ||
# - service: appservice | ||
# provider: azure | ||
# terraform: | ||
# links: | ||
# - https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/app_service#identity | ||
# good_examples: checks/cloud/azure/appservice/account_identity_registered.tf.go | ||
# bad_examples: checks/cloud/azure/appservice/account_identity_registered.tf.go | ||
package builtin.azure.appservice.azure0002 | ||
|
||
import rego.v1 | ||
|
||
deny contains res if { | ||
some service in input.azure.appservice.services | ||
isManaged(service) | ||
not has_identity_type(service) | ||
res := result.new( | ||
"App service does not have an identity type.", | ||
object.get(service, ["identity", "type"], service), | ||
) | ||
} | ||
|
||
has_identity_type(service) := service.identity.type.value != "" |
69 changes: 0 additions & 69 deletions
69
checks/cloud/azure/appservice/account_identity_registered_test.go
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
checks/cloud/azure/appservice/account_identity_registered_test.rego
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,24 @@ | ||
package builtin.azure.appservice.azure0002_test | ||
|
||
import rego.v1 | ||
|
||
import data.builtin.azure.appservice.azure0002 as check | ||
import data.lib.test | ||
|
||
test_deny_identity_not_registerd if { | ||
inp := {"azure": {"appservice": {"services": [{"identity": {"type": {"value": ""}}}]}}} | ||
res := check.deny with input as inp | ||
count(res) == 1 | ||
} | ||
|
||
test_deny_identity_type_is_not_specified if { | ||
inp := {"azure": {"appservice": {"services": [{"identity": {}}]}}} | ||
res := check.deny with input as inp | ||
count(res) == 1 | ||
} | ||
|
||
test_allow_identity_registerd if { | ||
inp := {"azure": {"appservice": {"services": [{"identity": {"type": {"value": "UserAssigned"}}}]}}} | ||
res := check.deny with input as inp | ||
res == set() | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# METADATA | ||
# title: App Service authentication is activated | ||
# description: | | ||
# Enabling authentication ensures that all communications in the application are authenticated. The auth_settings block needs to be filled out with the appropriate auth backend settings | ||
# scope: package | ||
# schemas: | ||
# - input: schema["cloud"] | ||
# custom: | ||
# id: AVD-AZU-0003 | ||
# avd_id: AVD-AZU-0003 | ||
# provider: azure | ||
# service: appservice | ||
# severity: MEDIUM | ||
# short_code: authentication-enabled | ||
# recommended_action: Enable authentication to prevent anonymous request being accepted | ||
# input: | ||
# selector: | ||
# - type: cloud | ||
# subtypes: | ||
# - service: appservice | ||
# provider: azure | ||
# terraform: | ||
# links: | ||
# - https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/app_service#enabled | ||
# good_examples: checks/cloud/azure/appservice/authentication_enabled.tf.go | ||
# bad_examples: checks/cloud/azure/appservice/authentication_enabled.tf.go | ||
package builtin.azure.appservice.azure0003 | ||
|
||
import rego.v1 | ||
|
||
deny contains res if { | ||
some service in input.azure.appservice.services | ||
isManaged(service) | ||
not service.authentication.enabled.value | ||
res := result.new( | ||
"App service does not have authentication enabled.", | ||
object.get(service, ["authentication", "enabled"], service), | ||
) | ||
} |
69 changes: 0 additions & 69 deletions
69
checks/cloud/azure/appservice/authentication_enabled_test.go
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.