From a1e2cd498865889105e3328007f39d3e198c9833 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Wed, 11 Nov 2026 23:53:22 +0900 Subject: [PATCH] =?UTF-8?q?docs(web-advanced):=20XML=20=EB=A7=A4=ED=8D=BC?= =?UTF-8?q?=EA=B0=80=20CBOR=EC=9D=98=20coercion=20=EC=9E=A0=EA=B8=88?= =?UTF-8?q?=EC=9D=84=20=EC=95=88=20=EC=93=B0=EB=8A=94=20=EC=9D=B4=EC=9C=A0?= =?UTF-8?q?=EB=A5=BC=20=EC=A0=81=EB=8A=94=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit red team 리뷰가 WebXmlMapperFactory를 WebCborMapperFactory의 scalar-coercion 잠금(withCoercionConfig String->Fail, Textual Integer->Fail)을 빠뜨린 것으로 보고 표현별 엄격성 불일치를 의심했다. 실제로는 by-design이다: XML은 textual 포맷이라 숫자·불리언 DTO 필드도 전부 String 토큰(5)으로 들어온다. 거기서 String 입력을 막으면 모든 숫자/불리언 바인딩이 깨지고, WebCodecMapperTest의 xmlRoundTripPreservesWireTypes(int count를 바인딩)가 바로 그걸 고정한다. CBOR과의 엄격성 차이는 검증 우회가 아니다 — FAIL_ON_UNKNOWN_PROPERTIES와 SecureXmlInputFactory 하드닝은 여기에도 적용되고, @Valid 제약은 바인딩 뒤 모든 표현에 돈다. 순진한 "parity fix"가 멀쩡한 XML 바인딩을 깨뜨리지 않도록, 왜 CoercionConfig를 두지 않는지 주석으로 못 박는다(동작 변경 없음). 검증: :adapter:inbound:web-advanced:test --tests '*WebCodecMapperTest*' rc=0(무회귀). --- .../inbound/web/advanced/codec/WebXmlMapperFactory.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/adapter/inbound/web-advanced/src/main/java/dev/caskeleton/adapter/inbound/web/advanced/codec/WebXmlMapperFactory.java b/src/adapter/inbound/web-advanced/src/main/java/dev/caskeleton/adapter/inbound/web/advanced/codec/WebXmlMapperFactory.java index ee36dbc9..f53b752f 100644 --- a/src/adapter/inbound/web-advanced/src/main/java/dev/caskeleton/adapter/inbound/web/advanced/codec/WebXmlMapperFactory.java +++ b/src/adapter/inbound/web-advanced/src/main/java/dev/caskeleton/adapter/inbound/web/advanced/codec/WebXmlMapperFactory.java @@ -77,6 +77,15 @@ public final class WebXmlMapperFactory { return XmlMapper.builder(factory) .enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) .disable(MapperFeature.ALLOW_COERCION_OF_SCALARS) + // Deliberately NOT the CBOR mapper's withCoercionConfig(String->Fail, Textual Integer->Fail). + // XML is a textual format: every scalar — a numeric or boolean DTO field included — arrives + // as a String token (5). Forbidding String-shaped input there would reject all + // numeric/boolean binding, and WebCodecMapperTest.xmlRoundTripPreservesWireTypes (which binds + // `int count`) pins exactly that. The parity a reader might expect with the CBOR profile is + // not a strictness bypass: FAIL_ON_UNKNOWN_PROPERTIES and the SecureXmlInputFactory hardening + // apply here too, @Valid constraints run post-binding on every representation, and binding + // "5"->int is XML's normal semantics, not the type confusion the CBOR lockdown guards against. + // (W4 red team BE-INPUT-001: the divergence is by design, not an omission.) .build(); }