Skip to content

Commit fac846d

Browse files
committed
fix(security): add typeof/isArray guards to satisfy CodeQL type-confusion check
1 parent 6056c34 commit fac846d

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

src/proxy/processors/pktLineParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { PACKET_SIZE } from './constants';
2323
* @return {[string[], number]} An array containing the parsed lines and the offset after the last parsed line/flush packet.
2424
*/
2525
export const parsePacketLines = (buffer: Buffer): [string[], number] => {
26-
if (!Buffer.isBuffer(buffer)) {
26+
if (typeof buffer === 'string' || Array.isArray(buffer) || !Buffer.isBuffer(buffer)) {
2727
throw new Error('parsePacketLines expected a Buffer');
2828
}
2929
const lines: string[] = [];

src/proxy/processors/push-action/parsePush.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ async function exec(req: Request, action: Action): Promise<Action> {
5757
if (!req.body || req.body.length === 0) {
5858
throw new Error('No body found in request');
5959
}
60-
if (!Buffer.isBuffer(req.body)) {
60+
if (typeof req.body === 'string' || Array.isArray(req.body) || !Buffer.isBuffer(req.body)) {
6161
throw new Error('Request body must be a Buffer');
6262
}
6363
const [packetLines, packDataOffset] = parsePacketLines(req.body);

0 commit comments

Comments
 (0)