From d5a8b6712a134cb0280437bb7a5a44b8250d91be Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Mon, 10 Jan 2022 23:26:14 +0000 Subject: [PATCH 1/3] chore: remove filterSensitiveLog for service exceptions --- .../amazon/smithy/typescript/codegen/StructureGenerator.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/StructureGenerator.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/StructureGenerator.java index efdfff70fa9..d4b45120961 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/StructureGenerator.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/StructureGenerator.java @@ -168,10 +168,6 @@ private void renderNonErrorStructure() { * $fault: "client"; * resourceType: string | undefined; * } - * - * export namespace NoSuchResource { - * export const filterSensitiveLog = (obj: NoSuchResource): any => ({...obj}); - * } * } */ private void renderErrorStructure() { @@ -197,7 +193,6 @@ private void renderErrorStructure() { structuredMemberWriter.writeMembers(writer, shape); writer.closeBlock("}"); // interface writer.write(""); - renderStructureNamespace(structuredMemberWriter, false); } private void renderStructureNamespace(StructuredMemberWriter structuredMemberWriter, boolean includeValidation) { From af5e1f9c639e6259ccfee72894da6baf7637a8c1 Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Mon, 10 Jan 2022 23:50:54 +0000 Subject: [PATCH 2/3] chore: remove check for namespace in error structures --- .../amazon/smithy/typescript/codegen/StructureGeneratorTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/StructureGeneratorTest.java b/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/StructureGeneratorTest.java index e0b07e138d2..6fa58946994 100644 --- a/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/StructureGeneratorTest.java +++ b/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/StructureGeneratorTest.java @@ -481,7 +481,6 @@ private void testErrorStructureCodegen(String file, String expectedType) { String contents = testStructureCodegen(file, expectedType); assertThat(contents, containsString("as __SmithyException")); - assertThat(contents, containsString("namespace Err {")); } @Test From 4e6ea27564b0c989fdab958aa4b8bd45ca55ec48 Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Tue, 11 Jan 2022 01:06:16 +0000 Subject: [PATCH 3/3] chore: do not call filterSensitiveLog on exceptions --- .../smithy/typescript/codegen/StructuredMemberWriter.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/StructuredMemberWriter.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/StructuredMemberWriter.java index 74676f12288..ab72e770ff9 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/StructuredMemberWriter.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/StructuredMemberWriter.java @@ -34,6 +34,7 @@ import software.amazon.smithy.model.shapes.StringShape; import software.amazon.smithy.model.shapes.StructureShape; import software.amazon.smithy.model.traits.EnumTrait; +import software.amazon.smithy.model.traits.ErrorTrait; import software.amazon.smithy.model.traits.IdempotencyTokenTrait; import software.amazon.smithy.model.traits.LengthTrait; import software.amazon.smithy.model.traits.MediaTypeTrait; @@ -163,6 +164,9 @@ private void writeStructureFilterSensitiveLog( } else if (structureTarget.hasTrait(StreamingTrait.class) && structureTarget.isUnionShape()) { // disable logging for StreamingTrait writer.write("'STREAMING_CONTENT'"); + } else if (structureTarget.hasTrait(ErrorTrait.class)) { + // Sensitive logs are not filtered from errors. + writer.write("$L", structureParam); } else { // Call filterSensitiveLog on Structure. writer.write("$T.filterSensitiveLog($L)", symbolProvider.toSymbol(structureTarget), structureParam);