Skip to content

Commit b702204

Browse files
committed
Fix #107
1 parent 4449944 commit b702204

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

src/transforms/rgf.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
} from "../util/gen";
2121
import { getIdentifierInfo } from "../util/identifiers";
2222
import { prepend, getDefiningContext } from "../util/insert";
23+
import Integrity from "./lock/integrity";
2324
import Transform from "./transform";
2425

2526
/**
@@ -200,6 +201,14 @@ export default class RGF extends Transform {
200201

201202
if (obfuscator.options.lock) {
202203
delete obfuscator.options.lock.countermeasures;
204+
205+
// Integrity will not recursively apply to RGF'd functions. This is intended.
206+
var lockTransform = obfuscator.transforms["Lock"];
207+
if (lockTransform) {
208+
lockTransform.before = lockTransform.before.filter(
209+
(beforeTransform) => !(beforeTransform instanceof Integrity)
210+
);
211+
}
203212
}
204213

205214
var transforms = obfuscator.array.filter(

test/transforms/lock/integrity.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,27 @@ it("should work on High Preset", async () => {
135135

136136
expect(TEST_OUTPUT).toStrictEqual("Hello World");
137137
});
138+
139+
it("should work with RGF enabled", async () => {
140+
var output = await JsConfuser(
141+
`
142+
function getTestOutput(){
143+
return "Hello World";
144+
}
145+
146+
TEST_OUTPUT = getTestOutput();
147+
`,
148+
{
149+
target: "node",
150+
rgf: true,
151+
lock: {
152+
integrity: true,
153+
},
154+
}
155+
);
156+
157+
var TEST_OUTPUT;
158+
eval(output);
159+
160+
expect(TEST_OUTPUT).toStrictEqual("Hello World");
161+
});

0 commit comments

Comments
 (0)