-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial support for ECMAScript modules (#239)
This is not yet a full solution as full ES6 projects won't get instrumented yet. Loading projects that (partially) rely on ES6 won't crash anymore though Note: A follow up PR will attempt to resolve the remaining problems Authored-by: 0xricksanchez <christopher.krah@code-intelligence.com>
- Loading branch information
1 parent
10f70a5
commit 0048593
Showing
22 changed files
with
253 additions
and
121 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ timeout-* | |
|
||
# Editors | ||
.idea | ||
.vscode | ||
|
||
# Build dir | ||
dist | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// The code in this file is based on the examples available in JSFuzz: | ||
// https://gitlab.com/gitlab-org/security-products/analyzers/fuzzers/jsfuzz/-/blob/34a694a8c73bfe0895c4e24784ba5b6dfe964b94/examples/jpeg/fuzz.js | ||
// The original code is available under the Apache License 2.0. | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
import { decode } from "jpeg-js"; | ||
|
||
/** | ||
* @param { Buffer } data | ||
*/ | ||
export function fuzz(data) { | ||
try { | ||
decode(data); | ||
} catch (error) { | ||
// Those are "valid" exceptions. we can't catch them in one line as | ||
// jpeg-js doesn't export/inherit from one exception class/style. | ||
if (!ignoredError(error)) throw error; | ||
} | ||
} | ||
|
||
function ignoredError(error) { | ||
return !!ignored.find((message) => error.message.indexOf(message) !== -1); | ||
} | ||
|
||
const ignored = [ | ||
"JPEG", | ||
"length octect", | ||
"Failed to", | ||
"DecoderBuffer", | ||
"invalid table spec", | ||
"SOI not found", | ||
]; |
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,19 @@ | ||
{ | ||
"name": "jpeg-es6-fuzz", | ||
"version": "1.0.0", | ||
"type": "module", | ||
"description": "", | ||
"main": "fuzz.js", | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"jpeg-js": "^0.4.4" | ||
}, | ||
"scripts": { | ||
"fuzz": "jazzer fuzz -i jpeg-js -e nothing --sync", | ||
"dryRun": "jazzer fuzz -i jpeg-js -e nothing --sync -- -runs=100 -seed=123456789" | ||
}, | ||
"devDependencies": { | ||
"@jazzer.js/core": "file:../../packages/core" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import proto from "protobufjs"; | ||
import { temporaryWriteSync } from "tempy"; | ||
|
||
/** | ||
* @param { Buffer } data | ||
*/ | ||
export function fuzz(data) { | ||
try { | ||
const file = temporaryWriteSync(data); | ||
const root = proto.loadSync(file); | ||
if (root.toString().length >= 30) { | ||
console.log("== Input: " + data.toString() + "\n== " + root.toString()); | ||
} | ||
} catch (e) { | ||
if ( | ||
e.name !== "SyntaxError" && | ||
e.message && | ||
!e.message.includes("illegal token") && | ||
!e.message.includes("illegal string") && | ||
!e.message.includes("illegal path") && | ||
!e.message.includes("illegal comment") && | ||
!e.message.includes("illegal reference") && | ||
!e.message.includes("illegal name") && | ||
!e.message.includes("illegal type") && | ||
!e.message.includes("illegal value") && | ||
!e.message.includes("illegal service") && | ||
!e.message.includes("name must be a string") && | ||
!e.message.includes("path must be relative") && | ||
!e.message.includes("duplicate name") && | ||
!e.message.includes("Unexpected token") && | ||
!e.message.includes("Unexpected end") | ||
) { | ||
throw e; | ||
} | ||
} | ||
} |
Oops, something went wrong.