Skip to content
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): ARM AppServiceSlotHTTPSOnly #6454

Merged
merged 3 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions checkov/arm/checks/resource/AppServiceSlotHTTPSOnly.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from checkov.arm.base_resource_value_check import BaseResourceValueCheck
from checkov.common.models.enums import CheckCategories


class AppServiceSlotHTTPSOnly(BaseResourceValueCheck):
def __init__(self) -> None:
name = "Ensure web app redirects all HTTP traffic to HTTPS in Azure App Service Slot"
id = "CKV_AZURE_153"
supported_resources = ("Microsoft.Web/sites", "Microsoft.Web/sites/slots",)
categories = (CheckCategories.NETWORKING,)
super().__init__(name=name, id=id, categories=categories, supported_resources=supported_resources)

def get_inspected_key(self) -> str:
return "properties/httpsOnly"


check = AppServiceSlotHTTPSOnly()
330 changes: 330 additions & 0 deletions tests/arm/checks/resource/example_AppServiceSlotHTTPSOnly/fail.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,330 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"webAppName": {
"type": "string",
"defaultValue": "AzureLinuxApp",
"metadata": {
"description": "Base name of the resource such as web app name and app service plan "
},
"minLength": 2
},
"sku": {
"type": "string",
"defaultValue": "S1",
"metadata": {
"description": "The SKU of App Service Plan "
}
},
"linuxFxVersion": {
"type": "string",
"defaultValue": "php|7.0",
"metadata": {
"description": "The Runtime stack of current web app"
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for all resources."
}
}
},
"variables": {
"webAppPortalName": "[concat(parameters('webAppName'), '-webapp')]",
"appServicePlanName": "[concat('AppServicePlan-', parameters('webAppName'))]"
},
"resources": [
{
"type": "Microsoft.Web/sites",
"apiVersion": "2022-09-01",
"name": "fail",
"location": "string",
"tags": {
"tagName1": "tagValue1",
"tagName2": "tagValue2"
},
"kind": "string",
"extendedLocation": {
"name": "string"
},
"identity": {
"type": "string",
"userAssignedIdentities": {}
},
"properties": {
"clientAffinityEnabled": "bool",
"clientCertEnabled": "bool",
"clientCertExclusionPaths": "string",
"clientCertMode": "string",
"cloningInfo": {
"appSettingsOverrides": {},
"cloneCustomHostNames": "bool",
"cloneSourceControl": "bool",
"configureLoadBalancing": "bool",
"correlationId": "string",
"hostingEnvironment": "string",
"overwrite": "bool",
"sourceWebAppId": "string",
"sourceWebAppLocation": "string",
"trafficManagerProfileId": "string",
"trafficManagerProfileName": "string"
},
"containerSize": "int",
"customDomainVerificationId": "string",
"dailyMemoryTimeQuota": "int",
"enabled": "bool",
"hostingEnvironmentProfile": {
"id": "string"
},
"hostNamesDisabled": "bool",
"hostNameSslStates": [
{
"hostType": "string",
"name": "string",
"sslState": "string",
"thumbprint": "string",
"toUpdate": "bool",
"virtualIP": "string"
}
],
"httpsOnly": false,
"hyperV": "bool",
"isXenon": "bool",
"keyVaultReferenceIdentity": "string",
"managedEnvironmentId": "string",
"publicNetworkAccess": "string",
"redundancyMode": "string",
"reserved": "bool",
"scmSiteAlsoStopped": "bool",
"serverFarmId": "string",
"siteConfig": {
"acrUseManagedIdentityCreds": "bool",
"acrUserManagedIdentityID": "string",
"alwaysOn": "bool",
"apiDefinition": {
"url": "string"
},
"apiManagementConfig": {
"id": "string"
},
"appCommandLine": "string",
"appSettings": [
{
"name": "string",
"value": "string"
}
],
"autoHealEnabled": "bool",
"autoHealRules": {
"actions": {
"actionType": "string",
"customAction": {
"exe": "string",
"parameters": "string"
},
"minProcessExecutionTime": "string"
},
"triggers": {
"privateBytesInKB": "int",
"requests": {
"count": "int",
"timeInterval": "string"
},
"slowRequests": {
"count": "int",
"path": "string",
"timeInterval": "string",
"timeTaken": "string"
},
"slowRequestsWithPath": [
{
"count": "int",
"path": "string",
"timeInterval": "string",
"timeTaken": "string"
}
],
"statusCodes": [
{
"count": "int",
"path": "string",
"status": "int",
"subStatus": "int",
"timeInterval": "string",
"win32Status": "int"
}
],
"statusCodesRange": [
{
"count": "int",
"path": "string",
"statusCodes": "string",
"timeInterval": "string"
}
]
}
},
"autoSwapSlotName": "string",
"azureStorageAccounts": {},
"connectionStrings": [
{
"connectionString": "string",
"name": "string",
"type": "string"
}
],
"cors": {
"allowedOrigins": [
"is try string to app service disallow cors"
],
"supportCredentials": "bool"
},
"defaultDocuments": [
"string"
],
"detailedErrorLoggingEnabled": "bool",
"documentRoot": "string",
"elasticWebAppScaleLimit": "int",
"experiments": {
"rampUpRules": [
{
"actionHostName": "string",
"changeDecisionCallbackUrl": "string",
"changeIntervalInMinutes": "int",
"changeStep": "int",
"maxReroutePercentage": "int",
"minReroutePercentage": "int",
"name": "string",
"reroutePercentage": "int"
}
]
},
"ftpsState": "string",
"functionAppScaleLimit": "int",
"functionsRuntimeScaleMonitoringEnabled": "bool",
"handlerMappings": [
{
"arguments": "string",
"extension": "string",
"scriptProcessor": "string"
}
],
"healthCheckPath": "string",
"http20Enabled": "bool",
"httpLoggingEnabled": "bool",
"ipSecurityRestrictions": [
{
"action": "string",
"description": "string",
"headers": {},
"ipAddress": "string",
"name": "string",
"priority": "int",
"subnetMask": "string",
"subnetTrafficTag": "int",
"tag": "string",
"vnetSubnetResourceId": "string",
"vnetTrafficTag": "int"
}
],
"ipSecurityRestrictionsDefaultAction": "string",
"javaContainer": "string",
"javaContainerVersion": "string",
"javaVersion": "string",
"keyVaultReferenceIdentity": "string",
"limits": {
"maxDiskSizeInMb": "int",
"maxMemoryInMb": "int",
"maxPercentageCpu": "int"
},
"linuxFxVersion": "string",
"loadBalancing": "string",
"localMySqlEnabled": "bool",
"logsDirectorySizeLimit": "int",
"managedPipelineMode": "string",
"managedServiceIdentityId": "int",
"metadata": [
{
"name": "string",
"value": "string"
}
],
"minimumElasticInstanceCount": "int",
"minTlsVersion": "string",
"netFrameworkVersion": "string",
"nodeVersion": "string",
"numberOfWorkers": "int",
"phpVersion": "string",
"powerShellVersion": "string",
"preWarmedInstanceCount": "int",
"publicNetworkAccess": "string",
"publishingUsername": "string",
"push": {
"kind": "string",
"properties": {
"dynamicTagsJson": "string",
"isPushEnabled": "bool",
"tagsRequiringAuth": "string",
"tagWhitelistJson": "string"
}
},
"pythonVersion": "string",
"remoteDebuggingEnabled": false,
"remoteDebuggingVersion": "string",
"requestTracingEnabled": "bool",
"requestTracingExpirationTime": "string",
"scmIpSecurityRestrictions": [
{
"action": "string",
"description": "string",
"headers": {},
"ipAddress": "string",
"name": "string",
"priority": "int",
"subnetMask": "string",
"subnetTrafficTag": "int",
"tag": "string",
"vnetSubnetResourceId": "string",
"vnetTrafficTag": "int"
}
],
"scmIpSecurityRestrictionsDefaultAction": "string",
"scmIpSecurityRestrictionsUseMain": "bool",
"scmMinTlsVersion": "string",
"scmType": "string",
"tracingOptions": "string",
"use32BitWorkerProcess": "bool",
"virtualApplications": [
{
"physicalPath": "string",
"preloadEnabled": "bool",
"virtualDirectories": [
{
"physicalPath": "string",
"virtualPath": "string"
}
],
"virtualPath": "string"
}
],
"vnetName": "string",
"vnetPrivatePortsCount": "int",
"vnetRouteAllEnabled": "bool",
"websiteTimeZone": "string",
"webSocketsEnabled": "bool",
"windowsFxVersion": "string",
"xManagedServiceIdentityId": "int"
},
"storageAccountRequired": "bool",
"virtualNetworkSubnetId": "string",
"vnetContentShareEnabled": "bool",
"vnetImagePullEnabled": "bool",
"vnetRouteAllEnabled": "bool"
}
}
]
}

Loading
Loading