merge: main(3e908c02, round9 #29~#31)을 받는다
This commit is contained in:
+8
-1
@@ -48,6 +48,14 @@ final class ProviderCallbackIngressBridge implements ProviderCallbackIngress {
|
||||
public CallbackIngestionResult ingest(ProviderCallbackHttpRequest request) {
|
||||
Objects.requireNonNull(request, "request");
|
||||
|
||||
// The profile comes from the unauthenticated path, so it is checked first: an unknown one is
|
||||
// refused before any limit check could write the caller's string to the security audit log.
|
||||
// No line either — any POST could otherwise fill the log at will (review 2026-11-12).
|
||||
ProviderCallbackAdapter adapter =
|
||||
adapters
|
||||
.find(request.providerProfileId())
|
||||
.orElseThrow(() -> rejected(NotificationFailureCode.CALLBACK_PAYLOAD_REJECTED));
|
||||
|
||||
CallbackLimits limits = adapters.limitsFor(request.providerProfileId());
|
||||
if (request.bodyLength() > limits.maxBodyBytes()) {
|
||||
securityAudit.callbackRejectedByLimit(request.providerProfileId(), "BODY_TOO_LARGE");
|
||||
@@ -58,7 +66,6 @@ final class ProviderCallbackIngressBridge implements ProviderCallbackIngress {
|
||||
throw rejected(NotificationFailureCode.CALLBACK_PAYLOAD_REJECTED);
|
||||
}
|
||||
|
||||
ProviderCallbackAdapter adapter = adapters.require(request.providerProfileId());
|
||||
if (!adapter.providerId().equals(request.providerId())) {
|
||||
securityAudit.callbackRejectedByLimit(
|
||||
request.providerProfileId(), "PROVIDER_PROFILE_MISMATCH");
|
||||
|
||||
+33
-2
@@ -24,6 +24,7 @@ import dev.caskeleton.application.notification.platform.api.NormalizedProviderEv
|
||||
import dev.caskeleton.application.notification.platform.api.ProviderId;
|
||||
import dev.caskeleton.application.notification.platform.api.ProviderProfileId;
|
||||
import dev.caskeleton.application.notification.platform.api.error.CallbackValidationException;
|
||||
import dev.caskeleton.application.notification.platform.api.error.NotificationFailureCode;
|
||||
import dev.caskeleton.application.notification.platform.observation.NotificationSecurityAuditPort;
|
||||
import dev.caskeleton.application.notification.platform.port.in.IngestProviderCallbackCommand;
|
||||
import dev.caskeleton.application.notification.platform.port.in.IngestProviderCallbackUseCase;
|
||||
@@ -193,6 +194,36 @@ class ProviderCallbackIngressBridgeTest {
|
||||
.containsExactly(CallbackIngressUnavailableException.class, List.of(), List.of());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName(
|
||||
"설정하지 않은 profile 의 콜백은 크기·형식 검사 전에 CALLBACK_PAYLOAD_REJECTED 로 거절되고 감사 로그에 그 문자열을 남기지 않는다")
|
||||
void aCallbackForAnUnconfiguredProfileIsRejectedFirstWithoutAuditingTheCallersString() {
|
||||
// given
|
||||
ProviderCallbackAdapterRegistry registry =
|
||||
new MapProviderCallbackAdapterRegistry(
|
||||
Map.of(), new CallbackLimits(4, Set.of("application/json")));
|
||||
RecordingAudit audit = new RecordingAudit();
|
||||
RecordingIngestion ingestion = new RecordingIngestion();
|
||||
ProviderCallbackIngressBridge bridge =
|
||||
new ProviderCallbackIngressBridge(registry, ingestion, audit);
|
||||
|
||||
// when
|
||||
Throwable failure =
|
||||
catchThrowable(() -> bridge.ingest(request("text/plain", "longer than four bytes")));
|
||||
|
||||
// then
|
||||
assertThat(
|
||||
List.of(
|
||||
failure instanceof CallbackValidationException rejected
|
||||
? rejected.descriptor().code()
|
||||
: String.valueOf(failure),
|
||||
audit.limitReasons,
|
||||
audit.signatureReasons,
|
||||
ingestion.callbacks))
|
||||
.containsExactly(
|
||||
NotificationFailureCode.CALLBACK_PAYLOAD_REJECTED, List.of(), List.of(), List.of());
|
||||
}
|
||||
|
||||
@Test
|
||||
void rawHttpLimitsAreEnforcedBeforeTheProviderAdapterRuns() {
|
||||
RecordingAdapter adapter = new RecordingAdapter(TWILIO, true);
|
||||
@@ -215,8 +246,8 @@ class ProviderCallbackIngressBridgeTest {
|
||||
ProviderCallbackAdapterRegistry registry =
|
||||
new ProviderCallbackAdapterRegistry() {
|
||||
@Override
|
||||
public ProviderCallbackAdapter require(ProviderProfileId profileId) {
|
||||
return adapter;
|
||||
public Optional<ProviderCallbackAdapter> find(ProviderProfileId profileId) {
|
||||
return Optional.of(adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user