HarGenerator插件

從截獲的請求和響應生成 HTTP 封存 (HAR) 檔案。

設定範例

{
  "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v4.0.0/rc.schema.json",
  "plugins": [
    {
      "name": "HarGeneratorPlugin",
      "enabled": true,
      "pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",
      "configSection": "harGeneratorPlugin"
    }
  ],
  "harGeneratorPlugin": {
    "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v4.0.0/hargeneratorplugin.schema.json",
    "includeSensitiveInformation": false,
    "includeResponse": true
  }
}

設定屬性

房產 Description 預設
includeSensitiveInformation 決定是否在產生的 HAR 檔案中包含敏感資訊 (授權標頭、Cookie 等)。 當設定為 false時,敏感標頭、Cookie 及敏感查詢參數的值會以 以下值進行遮蔽 REDACTED false
includeResponse 決定是否要在產生的 HAR 檔案中包含回應本文內容 false

命令列選項

None

備註

HAR (HTTP 封存) 格式是一種以 JSON 為基礎的格式,用於記錄 HTTP 交易。 各種工具廣泛支持它並使用它來:

  • 分析網路流量和效能
  • 偵錯 API 互動
  • 共用 HTTP 工作階段資料
  • 匯入瀏覽器開發人員工具和其他分析工具

當 includeSensitiveInformation 設定為 false時,外掛程式會自動編輯下列敏感標頭:

  • authorization
  • cookie
  • from
  • proxy-authenticate
  • proxy-authorization
  • set-cookie
  • www-authenticate
  • x-api-key
  • x-auth-token
  • x-csrf-token
  • x-forwarded-for
  • x-real-ip
  • x-session-token
  • x-xsrf-token

外掛也會將所有請求與回應 Cookie (request.cookies 和 response.cookies) 的值替換為 REDACTED,同時保留 Cookie 名稱。

此外,外掛會刪除以下敏感查詢參數的值(大小寫不區分),同時在請求 URL (request.url) 和查詢字串中request.queryString ()。 其他查詢參數則保留原始值。

  • access_token
  • api_key
  • api-key
  • apikey
  • auth
  • client_secret
  • code
  • id_token
  • key
  • password
  • refresh_token
  • secret
  • sig
  • signature
  • token
  • x-amz-credential
  • x-amz-security-token
  • x-amz-signature
  • x-goog-credential
  • x-goog-signature

例如,請求網址 https://api.contoso.com/users?access_token=abc123&page=2 被記錄為 https://api.contoso.com/users?access_token=REDACTED&page=2。

產生的 HAR 檔案包括:

  • HTTP 請求詳細資訊(方法、URL、標頭、查詢參數、cookie)
  • HTTP 回應詳細資料 (狀態、標頭、Cookie)
  • 請求和回應本文資料 (如適用)
  • 內容類型和大小
  • HTTP 版本資訊

外掛程式會在記錄停止後,在目前目錄中建立名為 devproxy-{timestamp}.har 的 HAR 檔案。

也請參閱