Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add xml fuzzer #11

Merged
merged 2 commits into from Nov 10, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

Add xml2js fuzzer

  • Loading branch information
bookmoons committed Nov 7, 2019
commit f88b0521df947ac7f8c64174ffd824cd970e1270
@@ -0,0 +1,34 @@
const xml2js = require('xml2js')

async function fuzz (bytes) {
const string = String.fromCodePoint(...bytes)
try {
await xml2js.parseStringPromise(string)
} catch (error) {
if (!acceptable(error)) throw error
}
}

function acceptable (error) {
return !!expected
.find(message => error.message.startsWith(message))
}

const expected = [
'Non-whitespace before first tag',
'Unencoded',
'Unexpected end',
'Invalid character',
'Invalid attribute name',
'Invalid tagname',
'Unclosed root tag',
'Attribute without value',
'Forward-slash in opening tag',
'Text data outside of root node',
'Unquoted attribute value',
'Unmatched closing tag',
'No whitespace between attributes',
'Unexpected close tag'
]

exports.fuzz = fuzz

Some generated files are not rendered by default. Learn more.

@@ -0,0 +1,9 @@
{
"name": "xml2js-fuzz",
"version": "1.0.0",
"main": "fuzz.js",
"license": "ISC",
"dependencies": {
"xml2js": "^0.4.22"
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.