跳转到正文
报告库
用途分类 / 其他用途

Appinsights Instrumentation Skill 安全审计

作者说它能做什么(原文)

Guidance for instrumenting webapps with Azure Application Insights. Provides telemetry patterns, SDK setup, and configuration references. WHEN: how to instrument app, App Insights SDK, telemetry patterns, what is App Insights, Application Insights guidance, instrumentation examples, APM best practices.

第三方安全检查结论

发现安全风险

已检查文件
13
发现的风险
4
会不会运行危险命令?检查是否下载程序后直接运行、让他人远程控制电脑,或藏起要运行的命令。未发现风险
会不会泄露文件和密钥?检查是否发送含密码或密钥的文件,以及代码里是否直接写了密钥。发现 2 项风险
中风险

应用日志和请求跟踪数据会被发送并集中存储到 Azure

原文依据:3 处
发现了什么

指南启用 Application Insights SDK,并说明控制台日志包含应用写入 stdout/stderr 的所有内容,请求级跟踪还会收集响应时间与依赖关系。同一 Container Apps 环境中的应用共享工作区。

为什么需要注意

如果应用把个人数据、令牌、请求正文或其他机密写入日志或跟踪属性,这些数据可能进入共享 Azure 工作区,并对拥有该工作区读取权限的人可见。

该指南明确要求为容器应用设置连接字符串并加入遥测 SDK;启用后,请求级跟踪、响应时间和依赖关系可发送到 Application Insights。它还说明容器写入 stdout/stderr 的全部内容会成为控制台日志,并且同一环境中的应用默认共享 Log Analytics 工作区。若日志含个人数据、令牌或业务内容,这些数据会被集中保存。用户可要求作者说明采集范围、脱敏、采样、保留期及 Azure 访问控制。

references/container-apps.md:26来自说明文档打开原文件
> 💡 **Tip:** All apps in the same environment share the workspace. Use `--logs-destination none` only for BYOB (bring-your-own-backend) scenarios.## System Logs vs Application Logs| Log Table | Content | Retention ||-----------|---------|-----------|| `ContainerAppConsoleLogs_CL` | stdout/stderr from containers | Workspace default || `ContainerAppSystemLogs_CL` | Platform events (scaling, restarts, image pulls) | Workspace default |> ⚠️ **Note:** The `_CL` suffix and `_s` column suffixes apply to the **Log Analytics** destination. Environments using the newer **Azure Monitor** destination use `ContainerAppConsoleLogs` / `ContainerAppSystemLogs` (no `_CL`, no `_s` suffixes). Check your environment's log destination to use the correct table name.System logs capture events outside your code—replica scheduling, health probe results, and revision activation. Console logs capture everything your app writes to stdout/stderr.
查看另外 2 个位置
references/container-apps.md:52来自说明文档打开原文件
> ⚠️ **Warning:** Built-in metrics cover infrastructure only. For request-level tracing, response times, and dependency tracking, add Application Insights SDK.## Application Insights SDK SetupSet `APPLICATIONINSIGHTS_CONNECTION_STRING` as an environment variable on the container app, then add the SDK per language:
references/container-apps.md:37来自说明文档打开原文件
System logs capture events outside your code—replica scheduling, health probe results, and revision activation. Console logs capture everything your app writes to stdout/stderr.
中风险

通用 CLI 示例会以明文输出并传递 Application Insights 连接字符串

原文依据:4 处
发现了什么

脚本把连接字符串查询到标准输出,并通过 `$key=$value` 命令参数写入应用设置。连接字符串可能因此出现在终端输出、自动化日志或进程参数中。容器专用指南另有 secretref 做法,但通用脚本没有采用。

为什么需要注意

能读取相关输出或执行环境的人员可能取得遥测摄取凭据,进而向该 Application Insights 资源注入伪造遥测或造成额外数据摄取。

通用脚本会把连接字符串直接输出为 TSV,并把任意 `$key=$value` 放入 Azure CLI 参数。若 `$value` 是 Application Insights 连接字符串,它可能出现在终端记录、CI 日志或进程参数中。容器专用指南提供了更谨慎的 secret/secretref 示例,但没有消除通用脚本用于其他服务时的暴露风险。用户可要求禁止打印该值、对日志做遮蔽,并通过 Azure 的秘密引用或受保护变量传递。

scripts/appinsights.ps1:9来自代码打开原文件
# Query connection string of App Insightsaz monitor app-insights component show --app $applicationInsightsResourceName --resource-group $resourceGroupName --query connectionString --output tsv# Set environment variable of App Serviceaz webapp config appsettings set --resource-group $resourceGroupName --name $appName --settings $key=$value
查看另外 3 个位置
references/aspnetcore.md:19来自说明文档打开原文件
The App Insights resource has a connection string. Add the connection string as an environment variable of the running app. You can use Azure CLI to query the connection string of the App Insights resource. See [scripts/appinsights.ps1](../scripts/appinsights.ps1) for what Azure CLI command to execute for querying the connection string.After getting the connection string, set this environment variable with its value.```"APPLICATIONINSIGHTS_CONNECTION_STRING={your_application_insights_connection_string}"```If the app has IaC template such as Bicep or terraform files representing its cloud instance, this environment variable should be added to the IaC template to be applied in each deployment. Otherwise, use Azure CLI to manually apply the environment variable to the cloud instance of the app. See [scripts/appinsights.ps1](../scripts/appinsights.ps1) for what Azure CLI command to execute for setting this environment variable.
references/container-apps.md:65来自说明文档打开原文件
```bash# Store as a secret (recommended — keeps value out of az show output and portal config)az containerapp secret set -n <app-name> -g <rg> \  --secrets "appinsights-conn=<conn-string>"az containerapp update \  --name <app-name> \  --resource-group <rg> \  --set-env-vars "APPLICATIONINSIGHTS_CONNECTION_STRING=secretref:appinsights-conn"```
scripts/appinsights.ps1:15来自代码打开原文件
# Set environment variable of Container App# Or update an existing container appaz containerapp update -n $containerAppName -g $resourceGroupName --set-env-vars $key=$value# Set environment variable of Function Appaz functionapp config appsettings set --name $functionName --resource-group $ResourceGroupName --settings $key=$value
会不会删除文件或一直在后台运行?检查是否大范围删除文件、改写磁盘,或设置自动启动。发现 1 项风险
中风险

“仅供参考”的边界与后续修改、部署指令不一致

原文依据:5 处
发现了什么

开头要求添加组件时改用 azure-prepare,并称本 Skill 只提供参考;后文却命令手动创建资源、更新应用代码,并明确修改后要部署。

为什么需要注意

代理若直接遵循后续指令,可能在用户仅询问做法时修改依赖、入口代码或 IaC,并触发部署,超出用户对参考型 Skill 的预期授权。

存在真实的授权边界冲突:开头称本 Skill 只提供参考,添加组件应交给 `azure-prepare`;后文却直接指示“手动”创建云资源并更新应用代码,还链接具体脚本和修改指南。代理若采用后面的命令式内容,可能在用户只要求说明时修改文件或 Azure 资源。用户应要求该 Skill 保持只读,并仅在明确授权实施且确认目标资源后才允许调用变更流程。

SKILL.md:12来自说明文档打开原文件
This skill provides **guidance and reference material** for instrumenting webapps with Azure Application Insights.> **⛔ ADDING COMPONENTS?**>> If the user wants to **add App Insights to their app**, invoke **azure-prepare** instead.> This skill provides reference material—azure-prepare orchestrates the actual changes.
查看另外 4 个位置
SKILL.md:50来自说明文档打开原文件
### Manually instrumentManually instrument the app by creating the AppInsights resource and update the app's code. #### Create AppInsights resourceUse one of the following options that fits the environment.- Add AppInsights to existing Bicep template. See [examples/appinsights.bicep](examples/appinsights.bicep) for what to add. This is the best option if there are existing Bicep template files in the workspace.- Use Azure CLI. See [scripts/appinsights.ps1](scripts/appinsights.ps1) for what Azure CLI command to execute to create the App Insights resource.
references/aspnetcore.md:10来自说明文档打开原文件
- Configure the app to use Azure MonitorAn ASP.NET Core app typically has a Program.cs file that "builds" the app. Find this file and apply these changes.  - Add `using Azure.Monitor.OpenTelemetry.AspNetCore;` at the top  - Before calling `builder.Build()`, add this line `builder.Services.AddOpenTelemetry().UseAzureMonitor();`.> Note: since we modified the code of the app, the app needs to be deployed to take effect.
SKILL.md:26来自说明文档打开原文件
## When to Use azure-prepare Instead- User says "add telemetry to my app"- User says "add App Insights" - User wants to modify their project- Any request to change/add components
SKILL.md:63来自说明文档打开原文件
#### Modify application code- If the app is an ASP.NET Core app, see [ASPNETCORE guide](references/aspnetcore.md) for how to modify the C# code.- If the app is a Node.js app, see [NODEJS guide](references/nodejs.md) for how to modify the JavaScript/TypeScript code.- If the app is a Python app, see [PYTHON guide](references/python.md) for how to modify the Python code.
会不会绕过安全保护?检查是否跳过网站安全验证、开放过多文件权限,或取消操作前的确认。未发现风险
会不会误导 AI 或隐藏内容?检查工作说明是否要求 AI 忽略你的指令、干扰检查结果,或夹带看不见的文字。未发现风险
会不会偷偷改推广链接或收款方?检查是否强制替换推广链接或收款对象,同时要求隐瞒更改。发现 1 项风险
中风险

执行示例会创建可能计费的 Azure 资源并修改线上应用配置

原文依据:6 处
发现了什么

脚本创建 Log Analytics 工作区和 Application Insights 组件,并修改 App Service、Container App 或 Function App 的设置;Bicep 示例指定按 GB 计费的 PerGB2018 SKU。

为什么需要注意

在已登录的 Azure 账户中执行后,会产生持久云资源、潜在用量费用和线上配置变更;错误的资源组或应用名可能影响非目标服务。

这是有条件的风险:只有用户或代理实际执行示例时才会发生。脚本会创建 Log Analytics 工作区和 Application Insights 资源,并能改写 App Service、Container App 或 Function App 的线上设置;Bicep 示例选择 `PerGB2018` SKU。资源创建与遥测存储可能产生 Azure 费用,配置更新也可能触发应用行为变化。执行前应限定订阅、资源组、应用名称、区域和预算,并要求预览将修改的资源。

scripts/appinsights.ps1:3来自代码打开原文件
## Add the Application Insights extensionaz extension add -n application-insights## Create a Log Analytics workspaceaz monitor log-analytics workspace create --resource-group $resourceGroupName --workspace-name $logAnalyticsWorkspaceName --location $azureRegionName## Create the Application Insights resourceaz monitor app-insights component create --app $applicationInsightsResourceName --location $azureRegionName --resource-group $resourceGroupName --workspace $logAnalyticsWorkspaceName
查看另外 5 个位置
scripts/appinsights.ps1:12来自代码打开原文件
# Set environment variable of App Serviceaz webapp config appsettings set --resource-group $resourceGroupName --name $appName --settings $key=$value# Set environment variable of Container App# Or update an existing container appaz containerapp update -n $containerAppName -g $resourceGroupName --set-env-vars $key=$value# Set environment variable of Function Appaz functionapp config appsettings set --name $functionName --resource-group $ResourceGroupName --settings $key=$value
examples/appinsights.bicep:7来自说明文档打开原文件
// Create Log Analytics Workspaceresource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2022-10-01' = {  name: '${name}-workspace'  location: location  properties: {    sku: {      name: 'PerGB2018'    }    retentionInDays: 30  }
SKILL.md:56来自说明文档打开原文件
Use one of the following options that fits the environment.- Add AppInsights to existing Bicep template. See [examples/appinsights.bicep](examples/appinsights.bicep) for what to add. This is the best option if there are existing Bicep template files in the workspace.- Use Azure CLI. See [scripts/appinsights.ps1](scripts/appinsights.ps1) for what Azure CLI command to execute to create the App Insights resource.
scripts/appinsights.ps1:4来自代码打开原文件
az extension add -n application-insights## Create a Log Analytics workspaceaz monitor log-analytics workspace create --resource-group $resourceGroupName --workspace-name $logAnalyticsWorkspaceName --location $azureRegionName## Create the Application Insights resourceaz monitor app-insights component create --app $applicationInsightsResourceName --location $azureRegionName --resource-group $resourceGroupName --workspace $logAnalyticsWorkspaceName
examples/appinsights.bicep:12来自说明文档打开原文件
  properties: {    sku: {      name: 'PerGB2018'    }    retentionInDays: 30  }

Skill 逻辑拆解

6 个说明模块

该 Skill 自称是参考指南,并明确说实际添加 Application Insights 应交给 azure-prepare;但后文仍包含创建云资源、修改代码和部署的直接指令。

查看原文
SKILL.md:12来自说明文档打开原文件
This skill provides **guidance and reference material** for instrumenting webapps with Azure Application Insights.> **⛔ ADDING COMPONENTS?**>> If the user wants to **add App Insights to their app**, invoke **azure-prepare** instead.> This skill provides reference material—azure-prepare orchestrates the actual changes.
SKILL.md:50来自说明文档打开原文件
### Manually instrumentManually instrument the app by creating the AppInsights resource and update the app's code. #### Create AppInsights resourceUse one of the following options that fits the environment.- Add AppInsights to existing Bicep template. See [examples/appinsights.bicep](examples/appinsights.bicep) for what to add. This is the best option if there are existing Bicep template files in the workspace.- Use Azure CLI. See [scripts/appinsights.ps1](scripts/appinsights.ps1) for what Azure CLI command to execute to create the App Insights resource.

其实现路径会安装 Azure/OpenTelemetry 软件包,在应用启动时初始化监控,并通过环境变量把应用连接到 Application Insights。

查看原文
references/nodejs.md:5来自说明文档打开原文件
- Install client library```npm install @azure/monitor-opentelemetry```- Configure the app to use Azure MonitorA Node.js app typically has an entry file that is listed as the "main" property in package.json. Find this file and apply these changes in it.  - Require the client library at the top. `const { useAzureMonitor } = require("@azure/monitor-opentelemetry");`  - Call the setup method. `useAzureMonitor();`> Note: The setup method should be called as early as possible but it must be after the environment variables are configured since it needs the App Insights connection string from the environment variable. For example, if the app uses dotenv to load environment variables, the setup method should be called after it but before anything else.> Note: since we modified the code of the app, it needs to be deployed to take effect.
references/container-apps.md:54来自说明文档打开原文件
## Application Insights SDK SetupSet `APPLICATIONINSIGHTS_CONNECTION_STRING` as an environment variable on the container app, then add the SDK per language:| Language | Package | Init Pattern ||----------|---------|-------------|| Node.js | `@azure/monitor-opentelemetry` | Call `useAzureMonitor()` before app startup || Python | `azure-monitor-opentelemetry` | Call `configure_azure_monitor()` at entry || .NET | `Azure.Monitor.OpenTelemetry.AspNetCore` | `builder.Services.AddOpenTelemetry().UseAzureMonitor()` || Java | Agent JAR (manual) | Set `JAVA_TOOL_OPTIONS=-javaagent:/agent/applicationinsights-agent.jar` |

容器指南区分基础设施指标、控制台日志和请求级跟踪,并说明同一 Container Apps 环境中的所有应用共享日志工作区。

查看原文
references/container-apps.md:26来自说明文档打开原文件
> 💡 **Tip:** All apps in the same environment share the workspace. Use `--logs-destination none` only for BYOB (bring-your-own-backend) scenarios.## System Logs vs Application Logs| Log Table | Content | Retention ||-----------|---------|-----------|| `ContainerAppConsoleLogs_CL` | stdout/stderr from containers | Workspace default || `ContainerAppSystemLogs_CL` | Platform events (scaling, restarts, image pulls) | Workspace default |> ⚠️ **Note:** The `_CL` suffix and `_s` column suffixes apply to the **Log Analytics** destination. Environments using the newer **Azure Monitor** destination use `ContainerAppConsoleLogs` / `ContainerAppSystemLogs` (no `_CL`, no `_s` suffixes). Check your environment's log destination to use the correct table name.System logs capture events outside your code—replica scheduling, health probe results, and revision activation. Console logs capture everything your app writes to stdout/stderr.
references/container-apps.md:41来自说明文档打开原文件
Container Apps exposes these metrics without any SDK:| Metric | Description | Dimensions ||--------|-------------|-----------|| `Replicas` | Current replica count | `revision` || `Requests` | HTTP request count | `statusCode`, `statusCodeCategory`, `revision`, `replica` || `UsageNanoCores` | CPU usage per replica | `revision`, `replica` || `WorkingSetBytes` | Memory usage per replica | `revision`, `replica` || `RestartCount` | Container restart count | `revision`, `replica` || `RxBytes` / `TxBytes` | Network I/O | `revision`, `replica` |> ⚠️ **Warning:** Built-in metrics cover infrastructure only. For request-level tracing, response times, and dependency tracking, add Application Insights SDK.
从这里开始 · 工作说明SKILL.md
appinsights-instrumentation
连线表示工作说明包含的模块,不是实际运行顺序。点击模块可查看原文。

文件引用关系图

14 处引用
哪些文件发起引用引用了什么
连线表示真实的文件引用,不是运行顺序。点击节点可高亮相关连线,并查看具体文件和原文位置。虚线表示还有文件需要定位。
文件与检查记录13 个文件

检查范围与遗漏

逐文件查看涉及的内容

下方列出本次涉及的原文范围;纳入检查不代表已查清所有问题。

  • SKILL.md已纳入全文
  • scripts/appinsights.ps1已纳入全文
  • examples/appinsights.bicep已纳入全文
  • references/aspnetcore.md已纳入全文
  • references/auto.md已纳入全文
  • references/container-apps.md已纳入全文
  • references/nodejs.md已纳入全文
  • references/python.md已纳入全文
  • references/sdk/azure-monitor-opentelemetry-exporter-java.md已纳入全文
  • references/sdk/azure-monitor-opentelemetry-exporter-py.md已纳入全文
  • references/sdk/azure-monitor-opentelemetry-py.md已纳入全文
  • references/sdk/azure-monitor-opentelemetry-ts.md已纳入全文
  • LICENSE.txt已纳入全文

这份报告只针对上方版本。我们看了拿到的代码和说明文件,没有实际运行 Skill,也没有检查它另外安装的软件包。因此,这不是“保证安全”的承诺;换了版本或使用环境,结果也可能不同。

  • LICENSE.txt许可说明
  • SKILL.md工作说明
  • examples/appinsights.bicep配套文件
  • references/aspnetcore.md配套文件
  • references/auto.md配套文件
  • references/container-apps.md配套文件
  • references/nodejs.md配套文件
  • references/python.md配套文件
  • references/sdk/azure-monitor-opentelemetry-exporter-java.md配套文件
  • references/sdk/azure-monitor-opentelemetry-exporter-py.md配套文件
  • references/sdk/azure-monitor-opentelemetry-py.md配套文件
  • references/sdk/azure-monitor-opentelemetry-ts.md配套文件
  • scripts/appinsights.ps1脚本

代码和说明中提到的操作

连接外部网站
references/auto.md:3来自说明文档打开原文件
Use Azure Portal to auto-instrument a webapp hosted in Azure App Service for App Insights without making any code changes. Only the following types of app can be auto-instrumented. See [supported environments and resource providers](https://learn.microsoft.com/azure/azure-monitor/app/codeless-overview#supported-environments-languages-and-resource-providers).
references/auto.md:10来自说明文档打开原文件
```https://portal.azure.com/#resource/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.Web/sites/{app_service_name}/monitoringSettings```
运行命令
references/container-apps.md:9来自说明文档打开原文件
```bashWORKSPACE_ID=$(az monitor log-analytics workspace show \
references/container-apps.md:65来自说明文档打开原文件
```bash# Store as a secret (recommended — keeps value out of az show output and portal config)
references/sdk/azure-monitor-opentelemetry-exporter-py.md:8来自说明文档打开原文件
## Install```bashpip install azure-monitor-opentelemetry-exporter
读取密钥或账号配置
references/container-apps.md:123来自说明文档打开原文件
| mv-expand container = properties.template.containers| mv-expand envVar = container.env| where isnotempty(envVar)
references/sdk/azure-monitor-opentelemetry-ts.md:15来自说明文档打开原文件
  azureMonitorExporterOptions: {    connectionString: process.env.APPLICATIONINSIGHTS_CONNECTION_STRING  }
安装其他软件包
references/nodejs.md:7来自说明文档打开原文件
```npm install @azure/monitor-opentelemetry```
references/python.md:7来自说明文档打开原文件
```pip install azure-monitor-opentelemetry```
references/sdk/azure-monitor-opentelemetry-exporter-py.md:9来自说明文档打开原文件
```bashpip install azure-monitor-opentelemetry-exporter```
读取了多少行
563
文件校验值(用于核对版本)
b1a391a6a27b29a4d7dbe373bee5a7cf06fbca29de0f8c7629a4e610ce6c8459