js-confuser 1.5.3 → 1.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -132,7 +132,7 @@ class OpaquePredicates extends _transform.default {
|
|
|
132
132
|
|
|
133
133
|
var cloned = (0, _insert.clone)(expr);
|
|
134
134
|
|
|
135
|
-
if (object.type == "SwitchCase") {
|
|
135
|
+
if (object.type == "SwitchCase" && object.test) {
|
|
136
136
|
var matching = (0, _gen.Identifier)((0, _random.choice)(["undefined", "null"]));
|
|
137
137
|
var test = object.test;
|
|
138
138
|
|
package/package.json
CHANGED
|
@@ -199,8 +199,8 @@ export default class OpaquePredicates extends Transform {
|
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
var cloned = clone(expr);
|
|
202
|
-
if (object.type == "SwitchCase") {
|
|
203
|
-
var matching = Identifier(choice(["undefined", "null"]));
|
|
202
|
+
if (object.type == "SwitchCase" && object.test) {
|
|
203
|
+
var matching: Node = Identifier(choice(["undefined", "null"]));
|
|
204
204
|
|
|
205
205
|
var test = object.test;
|
|
206
206
|
|
|
@@ -16,3 +16,28 @@ it("should append logical expressions", async () => {
|
|
|
16
16
|
|
|
17
17
|
expect(output).not.toContain("(test)");
|
|
18
18
|
});
|
|
19
|
+
|
|
20
|
+
// https://github.com/MichaelXF/js-confuser/issues/45
|
|
21
|
+
it("should work on default Switch cases", async ()=>{
|
|
22
|
+
var code = `
|
|
23
|
+
|
|
24
|
+
switch (0) {
|
|
25
|
+
default:
|
|
26
|
+
input(true);
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
var output = await JsConfuser(code, {
|
|
31
|
+
target: "browser",
|
|
32
|
+
opaquePredicates: true,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
var value;
|
|
36
|
+
function input(valueIn){
|
|
37
|
+
value = valueIn;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
eval(output);
|
|
41
|
+
|
|
42
|
+
expect(value).toStrictEqual(true);
|
|
43
|
+
})
|