Conversation
Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>
Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>
|
| Metric | Base | PR | Delta |
|---|---|---|---|
| Lines | 77.19% | 76.28% | 📉 -0.91% |
| Statements | 77.27% | 76.35% | 📉 -0.92% |
| Functions | 77.17% | 74.38% | 📉 -2.79% |
| Branches | 69.76% | 69.12% | 📉 -0.64% |
✨ New Files (1 files)
src/benchmarks/benchmark-runner.ts: 64.0% lines
Coverage comparison generated by scripts/ci/compare-coverage.ts
| // Generate and save benchmark report | ||
| const report = await benchmarkRunner.generateReport(); | ||
| const reportPath = path.join(os.tmpdir(), 'awf-benchmark-report.json'); | ||
| fs.writeFileSync(reportPath, JSON.stringify(report, null, 2)); |
Check failure
Code scanning / CodeQL
Insecure temporary file High test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 20 days ago
In general, to fix insecure temp file creation, avoid manually constructing paths under os.tmpdir() and instead use a secure temp-file API that (a) creates the file atomically, (b) ensures it doesn’t already exist, and (c) sets safe permissions. In Node.js, a common approach is to use the tmp library’s fileSync() / file() functions to obtain a securely created temporary file, then write to that file.
For this specific code, the safest non-breaking fix is:
- Replace the manual
path.join(os.tmpdir(), 'awf-benchmark-report.json')construction with a call totmp.fileSync, using a prefix/suffix so the filename is recognizable but still unique. - Use the returned
.nameasreportPathand continue to write to it withfs.writeFileSyncexactly as before. - Add an import for
tmpat the top oftests/benchmarks/performance.benchmark.ts.
Concrete changes in tests/benchmarks/performance.benchmark.ts:
-
Add
import * as tmp from 'tmp';alongside the existing imports. -
In
afterAll, change:const reportPath = path.join(os.tmpdir(), 'awf-benchmark-report.json'); fs.writeFileSync(reportPath, JSON.stringify(report, null, 2));
to:
const tmpFile = tmp.fileSync({ prefix: 'awf-benchmark-report-', postfix: '.json' }); const reportPath = tmpFile.name; fs.writeFileSync(reportPath, JSON.stringify(report, null, 2));
This preserves functionality (a JSON benchmark report saved to a temp file and its path logged) while ensuring the temp file is created securely.
| @@ -16,6 +16,7 @@ | ||
| import * as fs from 'fs'; | ||
| import * as path from 'path'; | ||
| import * as os from 'os'; | ||
| import * as tmp from 'tmp'; | ||
| import execa = require('execa'); | ||
|
|
||
| describe('Performance Benchmarks', () => { | ||
| @@ -38,7 +39,8 @@ | ||
| afterAll(async () => { | ||
| // Generate and save benchmark report | ||
| const report = await benchmarkRunner.generateReport(); | ||
| const reportPath = path.join(os.tmpdir(), 'awf-benchmark-report.json'); | ||
| const tmpFile = tmp.fileSync({ prefix: 'awf-benchmark-report-', postfix: '.json' }); | ||
| const reportPath = tmpFile.name; | ||
| fs.writeFileSync(reportPath, JSON.stringify(report, null, 2)); | ||
| console.log(`\nBenchmark report saved to: ${reportPath}`); | ||
|
|
| @@ -43,7 +43,8 @@ | ||
| "chalk": "^4.1.2", | ||
| "commander": "^12.0.0", | ||
| "execa": "^5.1.1", | ||
| "js-yaml": "^4.1.1" | ||
| "js-yaml": "^4.1.1", | ||
| "tmp": "^0.2.5" | ||
| }, | ||
| "devDependencies": { | ||
| "@commitlint/cli": "^20.1.0", |
| Package | Version | Security advisories |
| tmp (npm) | 0.2.5 | None |
| */ | ||
|
|
||
| import * as fs from 'fs'; | ||
| import * as path from 'path'; |
Check notice
Code scanning / CodeQL
Unused variable, import, function or class Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 20 days ago
In general, unused imports should be removed to make the code clearer and avoid confusion about their purpose. For this file, the simplest, behavior‑preserving fix is to delete the unused path import line.
Concretely, in scripts/ci/generate-benchmark-summary.ts, remove line 9: import * as path from 'path';. No other code changes are needed because nothing references path. No additional methods, definitions, or imports are required.
| @@ -6,7 +6,6 @@ | ||
| */ | ||
|
|
||
| import * as fs from 'fs'; | ||
| import * as path from 'path'; | ||
|
|
||
| interface BenchmarkMetric { | ||
| name: string; |
…ce-benchmarking-suite
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤 |
|
🎬 THE END — Smoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨ |
|
🌑 The shadows whisper... Smoke Codex failed. The oracle requires further meditation... |
🚨 Smoke Test Results: FAILLast 2 merged PRs (@Mossaka):
Test Results:
Status: FAIL (Playwright blocked)
|
Implements a performance benchmarking suite to track and prevent performance regressions over time, as outlined in the CI/CD Gap Assessment.
Benchmark Infrastructure
src/benchmarks/benchmark-types.ts- Types for results, stats, reports, regression detectionsrc/benchmarks/benchmark-runner.ts- Runner class with statistical analysis (min/max/mean/median/stdDev), regression detection, markdown formattingMetrics Tracked
CI Integration
.github/workflows/benchmark.yml- Runs on push/PR to main, uploads JSON report artifact, generates GitHub Actions summaryscripts/ci/generate-benchmark-summary.ts- Parses Jest output into markdown summaryUsage
Regression Detection
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.