docs(web-advanced): XML 매퍼가 CBOR의 coercion 잠금을 안 쓰는 이유를 적는다
red team 리뷰가 WebXmlMapperFactory를 WebCborMapperFactory의 scalar-coercion 잠금(withCoercionConfig String->Fail, Textual Integer->Fail)을 빠뜨린 것으로 보고 표현별 엄격성 불일치를 의심했다. 실제로는 by-design이다: XML은 textual 포맷이라 숫자·불리언 DTO 필드도 전부 String 토큰(<count>5</count>)으로 들어온다. 거기서 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(무회귀).
This commit is contained in:
+9
@@ -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 (<count>5</count>). 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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user