Skip to content

Commit

Permalink
Fix #74
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelXF committed May 18, 2023
1 parent 78cf2e5 commit 2d0ef4b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/transforms/antiTooling.ts
Expand Up @@ -45,7 +45,7 @@ export default class AntiTooling extends Transform {
exprs[0],
ExpressionStatement(
UnaryExpression(
choice(["typeof", "void", "~", "!", "+"]),
choice(["typeof", "void", "!"]),
SequenceExpression(flattened)
)
)
Expand Down
30 changes: 30 additions & 0 deletions test/transforms/antiTooling.test.ts
@@ -0,0 +1,30 @@
import JsConfuser from "../../src/index";

// https://github.com/MichaelXF/js-confuser/issues/74
test("Variant #1: Don't break Symbols", async () => {
if (typeof Symbol !== "undefined") {
for (var i = 0; i < 6; i++) {
var output = await JsConfuser(
`
var sym1 = Symbol();
if (true) {
sym1;
sym1;
sym1;
}
TEST_OUTPUT = sym1;
`,
{ target: "node", renameVariables: true }
);

var TEST_OUTPUT;

eval(output);
expect(typeof TEST_OUTPUT).toStrictEqual("symbol");
}
}
});

0 comments on commit 2d0ef4b

Please sign in to comment.