@azure-tools/test-recorder
Advanced tools
Comparing version 3.4.0 to 3.5.0
@@ -8,3 +8,3 @@ // Copyright (c) Microsoft Corporation. | ||
import { paths } from "./utils/paths"; | ||
import { addSanitizers, transformsInfo } from "./sanitizer"; | ||
import { addSanitizers, removeCentralSanitizers, transformsInfo } from "./sanitizer"; | ||
import { handleEnvSetup } from "./utils/envSetupForPlayback"; | ||
@@ -19,3 +19,2 @@ import { setMatcher } from "./matcher"; | ||
import { decodeBase64 } from "./utils/encoding"; | ||
import { fallbackSanitizers } from "./utils/fallbackSanitizers"; | ||
/** | ||
@@ -166,2 +165,3 @@ * This client manages the recorder life cycle and interacts with the proxy-tool to do the recording, | ||
async start(options) { | ||
var _a; | ||
await this.preStart(); | ||
@@ -225,4 +225,7 @@ if (isLiveMode()) | ||
await handleEnvSetup(this.httpClient, Recorder.url, this.recordingId, options.envSetupForPlayback); | ||
// Fallback sanitizers to be added in both record/playback modes | ||
await fallbackSanitizers(this.httpClient, Recorder.url, this.recordingId); | ||
// https://github.com/Azure/azure-sdk-tools/pull/8142/ | ||
// https://github.com/Azure/azure-sdk-tools/blob/main/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Common/SanitizerDictionary.cs | ||
const removalList = ["AZSDK2003"]; | ||
// Central test proxy Sanitizers to be removed | ||
await removeCentralSanitizers(this.httpClient, Recorder.url, this.recordingId, removalList.concat((_a = options.removeCentralSanitizers) !== null && _a !== void 0 ? _a : [])); | ||
// Sanitizers to be added only in record mode | ||
@@ -229,0 +232,0 @@ if (isRecordMode() && options.sanitizerOptions) { |
@@ -53,3 +53,3 @@ // Copyright (c) Microsoft Corporation. | ||
*/ | ||
export async function removeSanitizers(httpClient, url, recordingId, removalList) { | ||
export async function removeCentralSanitizers(httpClient, url, recordingId, removalList) { | ||
const uri = `${url}${paths.admin}${paths.removeSanitizers}`; | ||
@@ -56,0 +56,0 @@ const req = createRecordingRequest(uri, undefined, recordingId); |
@@ -427,3 +427,3 @@ 'use strict'; | ||
*/ | ||
async function removeSanitizers(httpClient, url, recordingId, removalList) { | ||
async function removeCentralSanitizers(httpClient, url, recordingId, removalList) { | ||
const uri = `${url}${paths.admin}${paths.removeSanitizers}`; | ||
@@ -678,124 +678,2 @@ const req = createRecordingRequest(uri, undefined, recordingId); | ||
// Licensed under the MIT license. | ||
const JSON_BODY_KEYS_TO_REDACT = [ | ||
"authHeader", | ||
"accountKey", | ||
"accessToken", | ||
"accountName", | ||
"applicationId", | ||
"apiKey", | ||
"client_secret", | ||
"connectionString", | ||
"url", | ||
"host", | ||
"password", | ||
"userName", | ||
"applicationSecret", | ||
"aliasSecondaryConnectionString", | ||
"aliasPrimaryConnectionString", | ||
"primaryKey", | ||
"secondaryKey", | ||
"adminPassword.value", | ||
"administratorLoginPassword", | ||
"runAsPassword", | ||
"adminPassword", | ||
"accessSAS", | ||
"WEBSITE_AUTH_ENCRYPTION_KEY", | ||
"decryptionKey", | ||
"primaryMasterKey", | ||
"primaryReadonlyMasterKey", | ||
"secondaryMasterKey", | ||
"secondaryReadonlyMasterKey", | ||
"certificatePassword", | ||
"clientSecret", | ||
"keyVaultClientSecret", | ||
"authHeader", | ||
"httpHeader", | ||
"encryptedCredential", | ||
"appkey", | ||
"functionKey", | ||
"atlasKafkaPrimaryEndpoint", | ||
"atlasKafkaSecondaryEndpoint", | ||
"certificatePassword", | ||
"storageAccountPrimaryKey", | ||
"privateKey", | ||
"fencingClientPassword", | ||
"acrToken", | ||
"scriptUrlSasToken", | ||
"azureBlobSource.containerUrl", | ||
"properties.DOCKER_REGISTRY_SEVER_PASSWORD", | ||
]; | ||
const BODY_REGEXES_TO_REDACT = [ | ||
"(?:(Password|User ID)=)(?<secret>.*)(?:;)", | ||
"client_secret=(?<secret>[^&]+)", | ||
"<PrimaryKey>(?<secret>.*?)</PrimaryKey>", | ||
"<SecondaryKey>(?<secret>.*?)</SecondaryKey>", | ||
"<UserDelegationKey>.*?<SignedOid>(?<secret>.*?)</SignedOid>.*?</UserDelegationKey>", | ||
"<UserDelegationKey>.*?<SignedTid>(?<secret>.*?)</SignedTid>.*?</UserDelegationKey>", | ||
"<UserDelegationKey>.*?<Value>(?<secret>.*?)</Value>.*?</UserDelegationKey>", | ||
'SharedAccessKey=(?<secret>[^;\\"]+)', | ||
'AccountKey=(?<secret>[^;\\"]+)', | ||
'accesskey=(?<secret>[^;\\"]+)', | ||
'AccessKey=(?<secret>[^;\\"]+)', | ||
'Secret=(?<secret>[^;\\"]+)', | ||
"access_token=(?<secret>.*?)(?=&|$)", | ||
"refresh_token=(?<secret>.*?)(?=&|$)", | ||
'(?:(sv|sig|se|srt|ss|sp)=)(?<secret>[^&\\"]*)', | ||
]; | ||
const URL_REGEX = "(?<=http://|https://)([^/?]+)"; | ||
const HEADER_KEYS_TO_REDACT = [ | ||
"Ocp-Apim-Subscription-Key", | ||
"api-key", | ||
"x-api-key", | ||
"subscription-key", | ||
"x-ms-encryption-key", | ||
"sshPassword", | ||
]; | ||
async function fallbackSanitizers(httpClient, url, recordingId) { | ||
const bodyKeySanitizers = JSON_BODY_KEYS_TO_REDACT.map((prop) => ({ | ||
jsonPath: `$..${prop}`, // Handles the request body | ||
value: "REDACTED", | ||
})); | ||
const generalSanitizers = BODY_REGEXES_TO_REDACT.map((regex) => ({ | ||
value: "REDACTED", | ||
regex: true, | ||
groupForReplace: "secret", | ||
target: regex, | ||
})); | ||
const headerSanitizers = [ | ||
{ | ||
key: "Operation-location", | ||
groupForReplace: "secret", | ||
regex: true, | ||
target: URL_REGEX, | ||
value: "REDACTED", | ||
}, | ||
{ | ||
key: "ServiceBusDlqSupplementaryAuthorization", | ||
groupForReplace: "secret", | ||
regex: true, | ||
target: '(?:(sv|sig|se|srt|ss|sp)=)(?<secret>[^&\\"]+)', | ||
value: "REDACTED", | ||
}, | ||
{ | ||
key: "ServiceBusSupplementaryAuthorization", | ||
groupForReplace: "secret", | ||
regex: true, | ||
target: '(?:(sv|sig|se|srt|ss|sp)=)(?<secret>[^&\\"]+)', | ||
value: "REDACTED", | ||
}, | ||
]; | ||
const headersForRemoval = HEADER_KEYS_TO_REDACT; | ||
// https://github.com/Azure/azure-sdk-tools/pull/8142/ | ||
const removalList = ["AZSDK2003"]; | ||
await removeSanitizers(httpClient, url, recordingId, removalList); | ||
await addSanitizers(httpClient, url, recordingId, { | ||
bodyKeySanitizers, | ||
generalSanitizers, | ||
removeHeaderSanitizer: { headersForRemoval }, | ||
headerSanitizers, | ||
}); | ||
} | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
var _a; | ||
@@ -947,2 +825,3 @@ /** | ||
async start(options) { | ||
var _a; | ||
await this.preStart(); | ||
@@ -1006,4 +885,7 @@ if (isLiveMode()) | ||
await handleEnvSetup(this.httpClient, Recorder.url, this.recordingId, options.envSetupForPlayback); | ||
// Fallback sanitizers to be added in both record/playback modes | ||
await fallbackSanitizers(this.httpClient, Recorder.url, this.recordingId); | ||
// https://github.com/Azure/azure-sdk-tools/pull/8142/ | ||
// https://github.com/Azure/azure-sdk-tools/blob/main/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Common/SanitizerDictionary.cs | ||
const removalList = ["AZSDK2003"]; | ||
// Central test proxy Sanitizers to be removed | ||
await removeCentralSanitizers(this.httpClient, Recorder.url, this.recordingId, removalList.concat((_a = options.removeCentralSanitizers) !== null && _a !== void 0 ? _a : [])); | ||
// Sanitizers to be added only in record mode | ||
@@ -1010,0 +892,0 @@ if (isRecordMode() && options.sanitizerOptions) { |
{ | ||
"name": "@azure-tools/test-recorder", | ||
"version": "3.4.0", | ||
"version": "3.5.0", | ||
"sdk-type": "utility", | ||
@@ -5,0 +5,0 @@ "description": "This library provides interfaces and helper methods to provide recording and playback capabilities for the tests in Azure JS/TS SDKs", |
@@ -14,3 +14,3 @@ import { HttpClient } from "@azure/core-rest-pipeline"; | ||
*/ | ||
export declare function removeSanitizers(httpClient: HttpClient, url: string, recordingId: string | undefined, removalList: string[]): Promise<void>; | ||
export declare function removeCentralSanitizers(httpClient: HttpClient, url: string, recordingId: string | undefined, removalList: string[]): Promise<void>; | ||
/** | ||
@@ -17,0 +17,0 @@ * Makes an /addSanitizers request to the test proxy |
@@ -226,2 +226,11 @@ /** | ||
tlsValidationCert?: string; | ||
/** | ||
* Central test-proxy sanitizers to be disabled | ||
* | ||
* More info: | ||
* | ||
* https://github.com/Azure/azure-sdk-tools/pull/8142/ | ||
* https://github.com/Azure/azure-sdk-tools/blob/main/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Common/SanitizerDictionary.cs | ||
*/ | ||
removeCentralSanitizers?: string[]; | ||
} | ||
@@ -228,0 +237,0 @@ /** |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
377602
88
2783