diff --git a/src/Deobfuscator.js b/src/Deobfuscator.js index 580d75c..f1ad6cf 100644 --- a/src/Deobfuscator.js +++ b/src/Deobfuscator.js @@ -63,6 +63,9 @@ export class Deobfuscator { * @param {*} node */ #extractCounterIdentifiers(nc, node) { + if (node === null) { + return; + } const { type } = nc; switch (type) { diff --git a/test/issues/295-deobfuscator-function-declaration-id-null.spec.js b/test/issues/295-deobfuscator-function-declaration-id-null.spec.js new file mode 100644 index 0000000..52ab4f1 --- /dev/null +++ b/test/issues/295-deobfuscator-function-declaration-id-null.spec.js @@ -0,0 +1,16 @@ +// Import Node.js Dependencies +import { test } from "node:test"; + +// Import Internal Dependencies +import { AstAnalyser } from "../../index.js"; + +/** + * @see https://github.com/NodeSecure/js-x-ray/issues/295 + */ +test("Deobfuscator.#extractCounterIdentifiers should not throw if FunctionDeclaration id is null", () => { + new AstAnalyser().analyse(` + export default async function (app) { + app.loaded = true + } + `); +});