Project: KICS (Provisioning / Security & Compliance)
File: cc4aaa9d-1070-461a-b519-04e00f42db8a.md

title: App Service Without Latest Python Version hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: cc4aaa9d-1070-461a-b519-04e00f42db8a Query name: App Service Without Latest Python Version Platform: Terraform Severity: <span style="color:#edd57e">Low</span> Category: Best Practices URL: Periodically, newer versions are released for Python software either due to security flaws or to include additional functionality. Using the latest full Python version for web apps is recommended in order to take advantage of security fixes, if any, and/or additional functionalities of the newer version.<br> ```tf title="Positive test num. 1 - tf file" hl_lines="11" resource "azurermappservice" "example4" { name = "example4-app-service" location = azurermresourcegroup.example.location resourcegroupname = azurermresourcegroup.example.name appserviceplanid = azurermappserviceplan.example.id site_config { dotnetframeworkversion = "v4.0" scm_type = "LocalGit" python_version = "2.7" } app_settings = { "SOME_KEY" = "some-value" } connection_string { name = "Database" type = "SQLServer" value = "Server=some-server.mydomain.com;Integrated Security=SSPI" } } ``` ```tf title="Positive test num. 2 - tf file" hl_lines="25" provider "azurerm" { features {} } resource "azurermresourcegroup" "example" { name = "example-resources" location = "West Europe" } resource "azurermserviceplan" "example" { name = "example" resourcegroupname = azurermresourcegroup.example.name location = azurermresourcegroup.example.location sku_name = "P1v2" } resource "azurermwindowsweb_app" "example5" { name = "example5" resourcegroupname = azurermresourcegroup.example.name location = azurermserviceplan.example.location serviceplanid = azurermserviceplan.example.id site_config{ application_stack{ python_version = "v2.7" } } } ``` ```tf title="Positive test num. 3 - tf file" hl_lines="26" provider "azurerm" { features {} } resource "azurermresourcegroup" "example" { name = "example-resources" location = "West Europe" } resource "azurermserviceplan" "example" { name = "example" resourcegroupname = azurermresourcegroup.example.name location = azurermresourcegroup.example.location os_type = "Linux" sku_name = "P1v2" } resource "azurermlinuxweb_app" "example6" { name = "example6" resourcegroupname = azurermresourcegroup.example.name location = azurermserviceplan.example.location serviceplanid = azurermserviceplan.example.id site_config{ application_stack{ python_version = "2.7" } } } ``` ```tf title="Negative test num. 1 - tf file" resource "azurermappservice" "example1" { name = "example1-app-service" location = azurermresourcegroup.example.location resourcegroupname = azurermresourcegroup.example.name appserviceplanid = azurermappserviceplan.example.id site_config { dotnetframeworkversion = "v4.0" scm_type = "LocalGit" python_version = "3.10" } app_settings = { "SOME_KEY" = "some-value" } connection_string { name = "Database" type = "SQLServer" value = "Server=some-server.mydomain.com;Integrated Security=SSPI" } } ``` ```tf title="Negative test num. 2 - tf file" provider "azurerm" { features {} } resource "azurermresourcegroup" "example" { name = "example-resources" location = "West Europe" } resource "azurermserviceplan" "example" { name = "example" resourcegroupname = azurermresourcegroup.example.name location = azurermresourcegroup.example.location sku_name = "P1v2" } resource "azurermwindowsweb_app" "example2" { name = "example2" resourcegroupname = azurermresourcegroup.example.name location = azurermserviceplan.example.location serviceplanid = azurermserviceplan.example.id site_config{ application_stack{ python_version = "v3.10" } } } ``` ```tf title="Negative test num. 3 - tf file" provider "azurerm" { features {} } resource "azurermresourcegroup" "example" { name = "example-resources" location = "West Europe" } resource "azurermserviceplan" "example" { name = "example" resourcegroupname = azurermresourcegroup.example.name location = azurermresourcegroup.example.location sku_name = "P1v2" } resource "azurermlinuxweb_app" "example3" { name = "example3" resourcegroupname = azurermresourcegroup.example.name location = azurermserviceplan.example.location serviceplanid = azurermserviceplan.example.id site_config{ application_stack{ python_version = "3.10" } } } ``` <details><summary>Negative test num. 4 - tf file</summary> ```tf resource "azurermappservice" "example1" { name = "example1-app-service" location = azurermresourcegroup.example.location resourcegroupname = azurermresourcegroup.example.name appserviceplanid = azurermappserviceplan.example.id site_config { dotnetframeworkversion = "v4.0" scm_type = "LocalGit" } app_settings = { "SOME_KEY" = "some-value" } connection_string { name = "Database" type = "SQLServer" value = "Server=some-server.mydomain.com;Integrated Security=SSPI" } } ``` </details>