Skip to content

Commit 9a4b2d4

Browse files
committed
fix: remove duplicate permissions block and strengthen loop bound
- Remove duplicate `permissions` block in ci.yml (was added by both Copilot autofix and previous commit) - Strengthen telemetry loop bound: add Array.isArray guard and use Math.min() with explicit numeric cap instead of .slice().length to satisfy CodeQL taint analysis for loop-bound-injection rule https://claude.ai/code/session_012Y448H3mNA8HJsDRJtXvEC
1 parent a2d2ce6 commit 9a4b2d4

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ on:
99
branches: [main]
1010
workflow_dispatch:
1111

12-
permissions:
13-
contents: read
14-
1512
jobs:
1613
backend:
1714
runs-on: ubuntu-latest

packages/backend/src/telemetry/telemetry.service.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,17 @@ export class TelemetryService {
3030
private static readonly MAX_EVENTS_PER_BATCH = 1000;
3131

3232
async ingest(events: TelemetryEventDto[], userId: string): Promise<IngestResult> {
33-
const safeEvents = events.slice(0, TelemetryService.MAX_EVENTS_PER_BATCH);
33+
if (!Array.isArray(events)) {
34+
return { accepted: 0, rejected: 0, errors: [] };
35+
}
36+
const maxLen = Math.min(events.length, TelemetryService.MAX_EVENTS_PER_BATCH);
3437
let accepted = 0;
3538
let rejected = 0;
3639
const errors: Array<{ index: number; reason: string }> = [];
3740

38-
for (let i = 0; i < safeEvents.length; i++) {
41+
for (let i = 0; i < maxLen; i++) {
3942
try {
40-
await this.insertEvent(safeEvents[i], userId);
43+
await this.insertEvent(events[i], userId);
4144
accepted++;
4245
} catch (err) {
4346
rejected++;

0 commit comments

Comments
 (0)