gpt4 book ai didi

c# - 控制发送到 AppInsight 跟踪的数据

转载 作者:行者123 更新时间:2023-12-03 04:16:46 25 4
gpt4 key购买 nike

有没有办法控制发送到 AppInsights 跟踪的数据。正如官方文档所述,过滤和预处理是可行的方法。我无法从 POST 和 PUT 中获取属性(密码)。由于密码很敏感,我不想被发送到 App Insights。以下是我的痕迹:

"Value": "client_id={someguid}&resource={someguid}&username={username}&password={password}&grant_type=password&scope=openid&nca=1;1;login-NonInteractive;False"

 public void Initialize(ITelemetry telemetry)
{
var requestTelemetry = telemetry as RequestTelemetry;
if (requestTelemetry != null && (HttpContext.Current.Request.HttpMethod == HttpMethod.Post.ToString() || HttpContext.Current.Request.HttpMethod == HttpMethod.Put.ToString()))
{
using (var reader = new StreamReader(HttpContext.Current.Request.InputStream))
{
string requestBody = reader.ReadToEnd();
requestTelemetry.Properties.Add("body", requestBody);
}
}
}

最佳答案

直接的答案是,目前 Application Insights 不支持此功能。

您可以在此处查看如何处理 Personal Data with Application insights

Note: If you’re interested in viewing or deleting personal data, please see the Azure Data Subject Requests for the GDPR article. If you’re looking for general info about GDPR, see the GDPR section of the Service Trust portal.

对于任何典型的项目,不建议将密码存储/显示为裸密码(即使在日志中)严重侵犯隐私

对于您的用例,正如 Ivan Yang 在评论中提到的。 您应该过滤掉/删除密码,而不是将整个请求正文内容放入/转储到应用洞察日志中。

   public void Initialize(ITelemetry telemetry)
{
var requestTelemetry = telemetry as RequestTelemetry;
if (requestTelemetry != null && (HttpContext.Current.Request.HttpMethod == HttpMethod.Post.ToString() || HttpContext.Current.Request.HttpMethod == HttpMethod.Put.ToString()))
{
using (var reader = new StreamReader(HttpContext.Current.Request.InputStream))
{
string requestBody = reader.ReadToEnd();
int startIndex= requestBody.LastIndexOf("&password=");
int endIndex= requestBody.LastIndexOf("&scope=");
requestBody = requestBody.Replace(requestBody.Substring(startIndex, (endIndex - startIndex) -1),"");
requestTelemetry.Properties.Add("body", requestBody);
}
}
}

您可以提供您的 own feedback here如果您确实想要一个功能,例如在登录应用程序洞察期间打开/关闭某些字段以屏蔽/取消屏蔽

关于c# - 控制发送到 AppInsight 跟踪的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52299555/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com