Skip to content

Commit

Permalink
Update fuzzing test
Browse files Browse the repository at this point in the history
  • Loading branch information
faisalman committed Apr 27, 2023
1 parent 1a80645 commit 102dc51
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion test/jazzer-test-fuzzing.js → test/jazzer-fuzz-test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
const { FuzzedDataProvider } = require('@jazzer.js/core');
const UAParser = require('ua-parser-js');
const UA_MAX_LENGTH = 350;

module.exports.fuzz = function (buffer) {
const userAgent = buffer.toString();
const data = new FuzzedDataProvider(buffer);
const userAgent = data.consumeString(UA_MAX_LENGTH, 'utf-8', true);
const start = process.hrtime();

UAParser(userAgent);

const elapsed = process.hrtime(start);
const milisec = (elapsed[0]*1e3+elapsed[1]*1e-6).toFixed(3);
if (milisec > 1000) {
Expand Down

0 comments on commit 102dc51

Please sign in to comment.