-
Notifications
You must be signed in to change notification settings - Fork 530
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
107 additions
and
123 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
'use strict' | ||
|
||
const { once } = require('node:events') | ||
const fc = require('fast-check') | ||
const netServer = require('./server') | ||
const { describe, before, after, test } = require('node:test') | ||
const { | ||
clientFuzzBody, | ||
clientFuzzHeaders, | ||
clientFuzzOptions | ||
} = require('./client') | ||
|
||
// Detect if running in CI (here we use GitHub Workflows) | ||
// https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables | ||
const isCI = process.env.CI === 'true' | ||
|
||
fc.configureGlobal({ | ||
interruptAfterTimeLimit: isCI ? 60_000 /* 1 minute */ : 10_000 /* 10 seconds */, | ||
numRuns: Number.MAX_SAFE_INTEGER | ||
}) | ||
|
||
describe('fuzzing', { timeout: 600_000 /* 10 minutes */ }, () => { | ||
before(async () => { | ||
netServer.listen(0) | ||
await once(netServer, 'listening') | ||
}) | ||
|
||
after(() => { | ||
netServer.close() | ||
}) | ||
|
||
test('body', async () => { | ||
const address = `http://localhost:${netServer.address().port}` | ||
await fc.assert( | ||
fc.asyncProperty(fc.uint8Array(), async (body) => { | ||
body = Buffer.from(body) | ||
const results = {} | ||
await clientFuzzBody(address, results, body) | ||
}) | ||
) | ||
}) | ||
|
||
test('headers', async () => { | ||
const address = `http://localhost:${netServer.address().port}` | ||
await fc.assert( | ||
fc.asyncProperty(fc.uint8Array(), async (body) => { | ||
body = Buffer.from(body) | ||
const results = {} | ||
await clientFuzzHeaders(address, results, body) | ||
}) | ||
) | ||
}) | ||
|
||
test('options', async () => { | ||
const address = `http://localhost:${netServer.address().port}` | ||
await fc.assert( | ||
fc.asyncProperty(fc.uint8Array(), async (body) => { | ||
body = Buffer.from(body) | ||
const results = {} | ||
await clientFuzzOptions(address, results, body) | ||
}) | ||
) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,15 @@ | ||
'use strict' | ||
|
||
module.exports = { | ||
splitData: require('./server-fuzz-split-data'), | ||
appendData: require('./server-fuzz-append-data') | ||
} | ||
const net = require('node:net') | ||
const serverFuzzFns = [ | ||
require('./server-fuzz-append-data'), | ||
require('./server-fuzz-split-data') | ||
] | ||
|
||
const netServer = net.createServer(socket => { | ||
socket.on('data', data => { | ||
serverFuzzFns[(Math.random() * 2) | 0](socket, data) | ||
}) | ||
}) | ||
|
||
module.exports = netServer |