Skip to content
This repository was archived by the owner on Apr 30, 2021. It is now read-only.

Commit 13c58a3

Browse files
committed
Add path fuzzer
1 parent 3a56a38 commit 13c58a3

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

examples/path/fuzz.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const path = require('path')
2+
3+
async function fuzz (bytes) {
4+
const string = String.fromCodePoint(...bytes)
5+
try {
6+
path.basename(string)
7+
path.dirname(string)
8+
path.extname(string)
9+
path.isAbsolute(string)
10+
path.join(string)
11+
path.normalize(string)
12+
path.parse(string)
13+
path.resolve(string)
14+
path.toNamespacedPath(string)
15+
} catch (error) {
16+
if (!acceptable(error)) throw error
17+
}
18+
}
19+
20+
function acceptable (error) {
21+
return !!expected
22+
.find(message => error.message.startsWith(message))
23+
}
24+
25+
const expected = [
26+
27+
]
28+
29+
exports.fuzz = fuzz

examples/path/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "path-fuzz",
3+
"version": "1.0.0",
4+
"main": "fuzz.js",
5+
"license": "ISC"
6+
}

0 commit comments

Comments
 (0)