Skip to content

Commit 202d078

Browse files
OgeonX-AiAitomatesclaude
authored
fix: secure observability public network access by default (#7)
Parameterize public network access for Log Analytics and Application Insights instead of hardcoding 'Enabled'. Introduces bool param allowPublicNetworkAccess (default false) in the observability module, mapping to Enabled/Disabled for both ingestion and query on the workspace and the App Insights component. DisableLocalAuth and enableLogAccessUsingOnlyResourcePermissions are preserved. Wire allowObservabilityPublicNetworkAccess through main.bicep and the per-environment .bicepparam files: dev overrides to true, test and prod keep the secure default of false. Expand bicepconfig.json to production linter defaults: core analyzers enabled, secret/security rules at error, style/correctness rules at warning, no-hardcoded-env-urls at error, and use-recent-api-versions disabled to avoid churn. Co-authored-by: Kim Harjamäki <kim.harjamaki@prosimo.fi> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent aa38662 commit 202d078

6 files changed

Lines changed: 49 additions & 8 deletions

File tree

bicepconfig.json

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,45 @@
22
"analyzers": {
33
"core": {
44
"enabled": true,
5+
"verbose": false,
56
"rules": {
67
"adminusername-should-not-be-literal": { "level": "error" },
7-
"no-hardcoded-env-urls": { "level": "warning" },
8+
"artifacts-parameters": { "level": "warning" },
9+
"decompiler-cleanup": { "level": "warning" },
10+
"explicit-values-for-loc-params": { "level": "warning" },
11+
"max-asserts": { "level": "warning" },
12+
"max-outputs": { "level": "warning" },
13+
"max-params": { "level": "warning" },
14+
"max-resources": { "level": "warning" },
15+
"max-variables": { "level": "warning" },
16+
"nested-deployment-template-scoping": { "level": "error" },
17+
"no-conflicting-metadata": { "level": "warning" },
18+
"no-deployments-resources": { "level": "warning" },
19+
"no-hardcoded-env-urls": { "level": "error" },
20+
"no-hardcoded-location": { "level": "warning" },
21+
"no-loc-expr-outside-params": { "level": "warning" },
822
"no-unnecessary-dependson": { "level": "warning" },
23+
"no-unused-existing-resources": { "level": "warning" },
24+
"no-unused-params": { "level": "warning" },
25+
"no-unused-vars": { "level": "warning" },
926
"outputs-should-not-contain-secrets": { "level": "error" },
27+
"prefer-interpolation": { "level": "warning" },
28+
"prefer-unquoted-property-names": { "level": "warning" },
29+
"protect-commandtoexecute-secrets": { "level": "error" },
1030
"secure-parameter-default": { "level": "error" },
11-
"use-recent-api-versions": { "level": "warning" },
12-
"use-resource-id-functions": { "level": "warning" }
31+
"secure-params-in-nested-deploy": { "level": "error" },
32+
"secure-secrets-in-params": { "level": "error" },
33+
"simplify-interpolation": { "level": "warning" },
34+
"simplify-json-null": { "level": "warning" },
35+
"use-parent-property": { "level": "warning" },
36+
"use-recent-api-versions": { "level": "off" },
37+
"use-resource-id-functions": { "level": "warning" },
38+
"use-resource-symbol-reference": { "level": "warning" },
39+
"use-safe-access": { "level": "warning" },
40+
"use-secure-value-for-secure-inputs": { "level": "error" },
41+
"use-stable-resource-identifiers": { "level": "warning" },
42+
"use-stable-vm-image": { "level": "warning" }
1343
}
1444
}
1545
}
1646
}
17-

infra/main.bicep

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ param enableExternalIngress bool = false
5959
@minValue(30)
6060
param logRetentionDays int = 30
6161

62+
@description('Allow public network access to Log Analytics and Application Insights ingestion/query. Secure default is false; lower environments (for example dev) may override to true.')
63+
param allowObservabilityPublicNetworkAccess bool = false
64+
6265
@description('Optional monthly resource-group budget. Set to zero to disable.')
6366
@minValue(0)
6467
param monthlyBudget int = 0
@@ -94,6 +97,7 @@ module observability './modules/observability.bicep' = {
9497
location: location
9598
suffix: suffix
9699
retentionDays: logRetentionDays
100+
allowPublicNetworkAccess: allowObservabilityPublicNetworkAccess
97101
tags: tags
98102
}
99103
}

infra/modules/observability.bicep

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ param retentionDays int
1818
@description('Common Azure resource tags.')
1919
param tags object
2020

21+
@description('Allow public network access for observability ingestion and query. Secure default is false; individual environments (for example dev) may override to true.')
22+
param allowPublicNetworkAccess bool = false
23+
24+
var publicNetworkAccess = allowPublicNetworkAccess ? 'Enabled' : 'Disabled'
25+
2126
resource workspace 'Microsoft.OperationalInsights/workspaces@2025-02-01' = {
2227
name: 'log-${workloadName}-${environment}-${suffix}'
2328
location: location
@@ -27,8 +32,8 @@ resource workspace 'Microsoft.OperationalInsights/workspaces@2025-02-01' = {
2732
features: {
2833
enableLogAccessUsingOnlyResourcePermissions: true
2934
}
30-
publicNetworkAccessForIngestion: 'Enabled'
31-
publicNetworkAccessForQuery: 'Enabled'
35+
publicNetworkAccessForIngestion: publicNetworkAccess
36+
publicNetworkAccessForQuery: publicNetworkAccess
3237
}
3338
}
3439

@@ -42,8 +47,8 @@ resource applicationInsights 'Microsoft.Insights/components@2020-02-02' = {
4247
WorkspaceResourceId: workspace.id
4348
DisableLocalAuth: true
4449
IngestionMode: 'LogAnalytics'
45-
publicNetworkAccessForIngestion: 'Enabled'
46-
publicNetworkAccessForQuery: 'Enabled'
50+
publicNetworkAccessForIngestion: publicNetworkAccess
51+
publicNetworkAccessForQuery: publicNetworkAccess
4752
}
4853
}
4954

infra/parameters/dev.bicepparam

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ param foundryProjectResourceId = ''
1313
param foundryRoleDefinitionResourceId = ''
1414
param enableExternalIngress = false
1515
param logRetentionDays = 30
16+
param allowObservabilityPublicNetworkAccess = true
1617
param monthlyBudget = 0
1718
param budgetContactEmails = []

infra/parameters/prod.bicepparam

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ param foundryProjectResourceId = ''
1313
param foundryRoleDefinitionResourceId = ''
1414
param enableExternalIngress = false
1515
param logRetentionDays = 90
16+
param allowObservabilityPublicNetworkAccess = false
1617
param monthlyBudget = 0
1718
param budgetContactEmails = []

infra/parameters/test.bicepparam

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ param foundryProjectResourceId = ''
1313
param foundryRoleDefinitionResourceId = ''
1414
param enableExternalIngress = false
1515
param logRetentionDays = 30
16+
param allowObservabilityPublicNetworkAccess = false
1617
param monthlyBudget = 0
1718
param budgetContactEmails = []

0 commit comments

Comments
 (0)