Skip to content

Commit f54d909

Browse files
nullvariantclaude
andauthored
feat(security): add property-based fuzzing tests with fast-check (#62)
Add comprehensive fuzzing tests using fast-check library for property-based testing. This helps discover edge cases and potential security vulnerabilities in input validation code. Changes: - Add validation.fuzz.test.ts with 13 fuzzing tests (~4,650 test runs) - Install fast-check v4.5.3 as dev dependency - Integrate fuzzing into existing security test suite - Update security.yml workflow comment for clarity Test coverage: - validateIdentity(): crash resistance, return type, dangerous patterns - validateIdentities(): large array handling - isPathSafe(): path traversal, shell metacharacters - Field-specific: GPG key ID (hex), SSH host (hostname pattern) 🖥️ IDE: [Cursor](https://cursor.sh) 🔌 Extension: [Claude Code](https://claude.ai/download) Model-Raw: claude-opus-4-5-20251101 Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 479ec1c commit f54d909

5 files changed

Lines changed: 486 additions & 3 deletions

File tree

.github/workflows/security.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ jobs:
111111
- name: Compile TypeScript
112112
run: npm run compile
113113

114-
- name: Run security tests
114+
- name: Run security tests (includes fuzzing)
115115
run: npm run test:security
116116

117117
codeql-analysis:

extensions/git-id-switcher/package-lock.json

Lines changed: 43 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extensions/git-id-switcher/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@
260260
"lint": "eslint src --ext ts",
261261
"test": "npm run compile && node out/test/runTests.js",
262262
"test:security": "npm run compile && node out/test/runTests.js",
263+
"test:fuzz": "npm run compile && node -e \"require('./out/test/validation.fuzz.test').runFuzzingTests()\"",
263264
"package": "vsce package",
264265
"publish": "echo '❌ Do not use vsce publish directly. Push a tag instead: git tag git-id-switcher-vX.X.X && git push --tags' && exit 1",
265266
"generate:readme": "node scripts/generate-root-readme.js"
@@ -271,6 +272,7 @@
271272
"@typescript-eslint/parser": "^7.0.0",
272273
"@vscode/vsce": "^3.0.0",
273274
"eslint": "^8.57.0",
275+
"fast-check": "^4.5.3",
274276
"typescript": "^5.3.0"
275277
},
276278
"repository": {

extensions/git-id-switcher/src/test/runTests.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { runSshKeyFormatTests } from './sshKeyFormat.test';
1212
import { runValidatorsCommonTests } from './validatorsCommon.test';
1313
import { runVSCodeLoaderTests } from './vscodeLoader.test';
1414
import { runFileLogWriterTests } from './fileLogWriter.test';
15+
import { runFuzzingTests } from './validation.fuzz.test';
1516

1617
async function main(): Promise<void> {
1718
console.log('╔════════════════════════════════════════════╗');
@@ -43,6 +44,9 @@ async function main(): Promise<void> {
4344
// Run FileLogWriter tests
4445
await runFileLogWriterTests();
4546

47+
// Run fuzzing tests (property-based testing)
48+
runFuzzingTests();
49+
4650
console.log('╔════════════════════════════════════════════╗');
4751
console.log('║ 🎉 All Security Tests Passed! ║');
4852
console.log('╚════════════════════════════════════════════╝\n');

0 commit comments

Comments
 (0)