From 3f63e0c32cce3ebe20f4dd81c92c4bd3c3899bac Mon Sep 17 00:00:00 2001 From: mvpoyatt Date: Thu, 31 Oct 2024 16:36:12 -0400 Subject: [PATCH] PR Feedback --- app/api/packets/request-handlers.ts | 3 ++- app/api/packets/route.ts | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/api/packets/request-handlers.ts b/app/api/packets/request-handlers.ts index 57e3c43..e8a7f05 100644 --- a/app/api/packets/request-handlers.ts +++ b/app/api/packets/request-handlers.ts @@ -58,6 +58,8 @@ export async function searchChannels( src?: string, dest?: string ): Promise { + let packetRes: PacketRes = { type: 'channel' }; + const channelFilter = `srcChannelId_eq: ${searchValue}`; const filterProps: FiltersProps = { start, end, states, src, dest }; const filters = generateSendPacketFilters(filterProps); @@ -69,7 +71,6 @@ export async function searchChannels( offset }); - let packetRes: PacketRes = { type: 'channel' }; try { const packets = await processRequest(generateSendPacketQuery(queryParams)); if (packets.length) { diff --git a/app/api/packets/route.ts b/app/api/packets/route.ts index d7fe397..e17d9d6 100644 --- a/app/api/packets/route.ts +++ b/app/api/packets/route.ts @@ -46,6 +46,12 @@ export async function GET(request: NextRequest) { // Search packets by channel id if (searchValue.slice(1, 8) === 'channel') { + // Validate channel ID format + searchValue = searchValue.trim(); + if (!/^["']?channel-\d+["']?$/.test(searchValue)) { + return NextResponse.json({ error: 'Invalid channel ID format' }, { status: 400 }); + } + let packetRes: PacketRes = await searchChannels(searchValue, start, end, limit, offset, states, src, dest); if (packetRes.error) { return NextResponse.json({ error: 'Internal Server Error' }, { status: 500 });