Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions benchmarks/fuzzer-check-errors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict'

const { FuzzedDataProvider } = require('@jazzer.js/core')
Comment thread
Fdawgs marked this conversation as resolved.
const fastContentTypeParse = require('../index.js')

function fuzz (data) {
const provider = new FuzzedDataProvider(data)

const fmtString = provider.consumeRemainingAsString()
try {
fastContentTypeParse.parse(fmtString)
} catch (error) {
// Ignore all expected errors
if (!(error instanceof TypeError)) {
throw error
}
}
}

module.exports = { fuzz }
14 changes: 14 additions & 0 deletions benchmarks/fuzzer-check-performance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict'

const { FuzzedDataProvider } = require('@jazzer.js/core')
Comment thread
Fdawgs marked this conversation as resolved.
const fastContentTypeParse = require('../index.js')

function fuzz (data) {
const provider = new FuzzedDataProvider(data)

const fmtString = provider.consumeRemainingAsString()
// Ignore errors; we're interested in performance slowdown
fastContentTypeParse.safeParse(fmtString)
}

module.exports = { fuzz }
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"lint:fix": "eslint --fix",
"test": "npm run test:unit && npm run test:typescript",
"test:typescript": "tsd",
"jazzer:errors": "npm rebuild @jazzer.js/core && jazzer benchmarks/fuzzer-check-errors --sync --timeout=100 -- -max_total_time=120",
"jazzer:performance": "npm rebuild @jazzer.js/core && jazzer benchmarks/fuzzer-check-performance --sync --timeout=100 -- -max_total_time=120",
"test:unit": "c8 --100 node --test"
},
"keywords": [
Expand Down Expand Up @@ -58,6 +60,7 @@
}
],
"devDependencies": {
"@jazzer.js/core": "^2.1.0",
"benchmark": "^2.1.4",
"busboy": "^1.6.0",
"c8": "^10.1.3",
Expand Down
Loading