Throw when we're given invalid event/room ids in report forwarding.

https://github.com/the-draupnir-project/Draupnir/issues/643.
This commit is contained in:
gnuxie
2024-12-17 23:30:26 +00:00
parent 56a36de654
commit b8ce84301f
+16 -2
View File
@@ -16,6 +16,8 @@ import { IConfig } from "../config";
import {
StringRoomID,
StringEventID,
isStringRoomID,
isStringEventID,
} from "@the-draupnir-project/matrix-basic-types";
import { Logger, Task } from "matrix-protection-suite";
@@ -87,12 +89,24 @@ export class WebAPIs {
"X-Requested-With, Content-Type, Authorization, Date"
);
response.header("Access-Control-Allow-Methods", "POST, OPTIONS");
const roomID = request.params.room_id;
const eventID = request.params.event_id;
if (!isStringRoomID(roomID)) {
throw new TypeError(
`Invalid roomID provided when processing a report, check your webproxy: ${roomID}`
);
}
if (!isStringEventID(eventID)) {
throw new TypeError(
`Invalid eventID provided when processing a report, check your webproxy: ${eventID}`
);
}
void Task(
this.handleReport({
request,
response,
roomID: request.params.room_id as StringRoomID,
eventID: request.params.event_id as StringEventID,
roomID,
eventID,
})
);
}