Skip to content

Commit

Permalink
Modify Rule S6382: Fix outdated properties (APPSEC-773) (#2514)
Browse files Browse the repository at this point in the history
* Fix outdated property

* Swap Web Apps for Containers and App Service
  • Loading branch information
egon-okerman-sonarsource authored Sep 11, 2024
1 parent 0e30d8d commit a3a2e69
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion rules/S6382/terraform/highlighting.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
* If one (out of one) assignment is missing: Highlight the resource
* If an assignment is security-sensitive: Highlight the assignment
* For `linux_web_app` and `windows_web_app`:
** If both assignments are present and security-sensitive: Highlight `client_cert_enabled = false`
** If both assignments are present and security-sensitive: Highlight `client_certificate_enabled = false`
10 changes: 7 additions & 3 deletions rules/S6382/terraform/message.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@ For these resources:
* `app_service`
* `data_factory_linked_service_sftp`
* `data_factory_linked_service_web`
* `linux_web_app`
* `windows_web_app` (if both parameters are non-compliant, flag `client_cert_enabled` first)
* `linux_web_app`
* `windows_web_app` (if both parameters are non-compliant, flag `client_certificate_enabled` first)
These messages apply:

* If an assignment is missing: Omitting {property_name} disables certificate-based authentication. Make sure it is safe here.
* If the assignment is security-sensitive: Make sure that disabling certificate-based authentication is safe here.
* For `function_app` and `logic_app_standard`:
* For `function_app`:
** Omitting `client_cert_mode` makes certificate-based authentication optional. Make sure it is safe here.
** Make sure that setting certificate-based authentication as optional is safe here.
* For `logic_app_standard`:
** Omitting `client_certificate_mode` makes certificate-based authentication optional. Make sure it is safe here.
** Make sure that setting certificate-based authentication as optional is safe here.
Make sure that disabling certificate-based authentication is safe here.
28 changes: 14 additions & 14 deletions rules/S6382/terraform/rule.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ include::../common/recommended.adoc[]

== Sensitive Code Example

For https://azure.microsoft.com/en-us/services/app-service/[App Service]:
For https://azure.microsoft.com/en-us/services/app-service/containers/[Linux and Windows Web Apps]:

[source,terraform,diff-id=1,diff-type=noncompliant]
----
resource "azurerm_app_service" "example" {
resource "azurerm_linux_web_app" "example" {
client_cert_enabled = false # Sensitive
}
resource "azurerm_linux_web_app" "example2" {
client_certificate_enabled = true
client_certificate_mode = "Optional" # Sensitive
}
----

For https://azure.microsoft.com/en-us/services/logic-apps/[Logic App Standards] and https://azure.microsoft.com/en-us/services/functions/[Function Apps]:
Expand Down Expand Up @@ -43,27 +47,24 @@ resource "azurerm_api_management" "example" {
}
----

For https://azure.microsoft.com/en-us/services/app-service/containers/[Linux and Windows Web Apps]:
For https://azure.microsoft.com/en-us/services/app-service/[App Service]:

[source,terraform,diff-id=5,diff-type=noncompliant]
----
resource "azurerm_linux_web_app" "example" {
resource "azurerm_app_service" "example" {
client_cert_enabled = false # Sensitive
}
resource "azurerm_linux_web_app" "exemple2" {
client_cert_enabled = true
client_cert_mode = "Optional" # Sensitive
}
----

== Compliant Solution

For https://azure.microsoft.com/en-us/services/app-service/[App Service]:
For https://azure.microsoft.com/en-us/services/app-service/containers/[Linux and Windows Web Apps]:

[source,terraform,diff-id=1,diff-type=compliant]
----
resource "azurerm_app_service" "example" {
client_cert_enabled = true
resource "azurerm_linux_web_app" "example" {
client_certificate_enabled = true
client_certificate_mode = "Required"
}
----

Expand Down Expand Up @@ -95,13 +96,12 @@ resource "azurerm_api_management" "example" {
}
----

For https://azure.microsoft.com/en-us/services/app-service/containers/[Linux and Windows Web Apps]:
For https://azure.microsoft.com/en-us/services/app-service/[App Service]:

[source,terraform,diff-id=5,diff-type=compliant]
----
resource "azurerm_linux_web_app" "exemple" {
resource "azurerm_app_service" "example" {
client_cert_enabled = true
client_cert_mode = "Required"
}
----

Expand Down

0 comments on commit a3a2e69

Please sign in to comment.