Skip to content

Fix TypeScript errors in sanitizeStats XSS security fix#331

Merged
rajbos merged 2 commits intoalert-autofix-45from
copilot/sub-pr-330
Mar 1, 2026
Merged

Fix TypeScript errors in sanitizeStats XSS security fix#331
rajbos merged 2 commits intoalert-autofix-45from
copilot/sub-pr-330

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 1, 2026

The sanitizeStats function introduced to fix code scanning alert #45 (client-side XSS) had incorrect field names and missing required properties, causing the TypeScript build to fail.

Changes

  • sanitizeContextRefs: Added all missing ContextReferenceUsage fields (terminal, vscode, terminalLastCommand, terminalSelection, clipboard, changes, outputPanel, problemsPanel, byKind, copilotInstructions, agentsMd, byPath)
  • Field name corrections: toolUsagetoolCalls, mcpToolUsagemcpTools to match UsageAnalysisPeriod
  • Extracted sanitizePeriod helper to eliminate duplication and add the missing sessions and modelSwitching fields per period
  • UsageAnalysisStats object: Added required month and lastUpdated fields; removed erroneous repoAnalysis field not present in the type
const sanitizePeriod = (period: any): UsageAnalysisPeriod => ({
    sessions: coerceNumber(period?.sessions),
    modeUsage: sanitizeModeUsage(period?.modeUsage ?? {}),
    contextReferences: sanitizeContextRefs(period?.contextReferences ?? {}),
    toolCalls: { total: coerceNumber(period?.toolCalls?.total), byTool: period?.toolCalls?.byTool ?? {} },
    mcpTools: { ... },
    modelSwitching: period?.modelSwitching ?? { /* safe defaults */ },
});

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…issing properties

Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix client-side cross-site scripting code scanning alert Fix TypeScript errors in sanitizeStats XSS security fix Mar 1, 2026
@rajbos rajbos marked this pull request as ready for review March 1, 2026 19:46
@rajbos rajbos merged commit 46fb973 into alert-autofix-45 Mar 1, 2026
1 check passed
@rajbos rajbos deleted the copilot/sub-pr-330 branch March 1, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants