Skip to content

Commit

Permalink
[FormRecognizer] whitelist header names and query parameters for logg…
Browse files Browse the repository at this point in the history
…ing (#9149)
  • Loading branch information
jeremymeng authored Jun 5, 2020
1 parent 3093009 commit 527f241
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
15 changes: 15 additions & 0 deletions sdk/formrecognizer/ai-form-recognizer/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,18 @@ export const LIB_INFO = `azsdk-js-ai-formrecognizer/${SDK_VERSION}`;
* @internal
*/
export const MAX_INPUT_DOCUMENT_SIZE = 50 * 1024 * 1024; // 50 MB

export const FormRecognizerLoggingAllowedHeaderNames = [
"apim-request-id",
"Location",
"Operation-Location",
"Strict-Transport-Security",
"X-Content-Type-Options",
"x-envoy-upstream-service-time"
];

export const FormRecognizerLoggingAllowedQueryParameters = [
"includeTextDetails",
"includeKeys",
"op"
];
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ import {
} from "@azure/core-http";
import { TokenCredential } from "@azure/identity";
import { KeyCredential } from "@azure/core-auth";
import { SDK_VERSION, DEFAULT_COGNITIVE_SCOPE } from "./constants";
import {
SDK_VERSION,
DEFAULT_COGNITIVE_SCOPE,
FormRecognizerLoggingAllowedHeaderNames,
FormRecognizerLoggingAllowedQueryParameters
} from "./constants";
import { logger } from "./logger";
import { createSpan } from "./tracing";
import {
Expand Down Expand Up @@ -253,7 +258,8 @@ export class FormRecognizerClient {
...{
loggingOptions: {
logger: logger.info,
allowedHeaderNames: ["x-ms-correlation-request-id", "x-ms-request-id"]
allowedHeaderNames: FormRecognizerLoggingAllowedHeaderNames,
allowedQueryParameters: FormRecognizerLoggingAllowedQueryParameters
}
}
};
Expand Down
10 changes: 8 additions & 2 deletions sdk/formrecognizer/ai-form-recognizer/src/formTrainingClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ import { TokenCredential } from "@azure/identity";
import { KeyCredential } from "@azure/core-auth";
import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging";
import "@azure/core-paging";
import { SDK_VERSION, DEFAULT_COGNITIVE_SCOPE } from "./constants";
import {
SDK_VERSION,
DEFAULT_COGNITIVE_SCOPE,
FormRecognizerLoggingAllowedHeaderNames,
FormRecognizerLoggingAllowedQueryParameters
} from "./constants";
import { logger } from "./logger";
import { createSpan } from "./tracing";
import { CanonicalCode } from "@opentelemetry/api";
Expand Down Expand Up @@ -188,7 +193,8 @@ export class FormTrainingClient {
...{
loggingOptions: {
logger: logger.info,
allowedHeaderNames: ["x-ms-correlation-request-id", "x-ms-request-id"]
allowedHeaderNames: FormRecognizerLoggingAllowedHeaderNames,
allowedQueryParameters: FormRecognizerLoggingAllowedQueryParameters
}
}
};
Expand Down
1 change: 0 additions & 1 deletion sdk/formrecognizer/ai-form-recognizer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ export {
FormRecognizerOperationOptions } from "./common";
export * from "./formRecognizerClient";
export * from "./formTrainingClient";

export * from "./models";

0 comments on commit 527f241

Please sign in to comment.