From 878c3953a9ea653bfd21a77cf08f5064e29d5183 Mon Sep 17 00:00:00 2001 From: huangyu Date: Fri, 5 Jul 2024 17:20:00 +0800 Subject: [PATCH] [Arkguard] Fix inconsistent obfuscated name in namecache and final result for export obfuscation Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/I9RVDU Test: arkguard test, test262, ts_extra_test and compiler_ts with obfuscation Signed-off-by: huangyu Change-Id: Ie14d7249bd3a5bd82d13938a15ae0c01b210e9e4 --- arkguard/src/utils/ScopeAnalyzer.ts | 4 +- .../export_namecache/namecacheTest7_export.ts | 49 +++++++++++++++++++ .../namecacheTest7_export_expected.txt | 26 ++++++++++ .../namecacheTest7_export_expected_cache.txt | 23 +++++++++ .../export_namecache/namecacheTest7_import.ts | 31 ++++++++++++ .../namecacheTest7_import_expected.txt | 14 ++++++ .../namecacheTest7_import_expected_cache.txt | 19 +++++++ .../export_namecache/namecacheTest8_export.ts | 45 +++++++++++++++++ .../namecacheTest8_export_expected.txt | 28 +++++++++++ .../namecacheTest8_export_expected_cache.txt | 14 ++++++ .../export_namecache/namecacheTest8_import.ts | 33 +++++++++++++ .../namecacheTest8_import_expected.txt | 14 ++++++ .../namecacheTest8_import_expected_cache.txt | 20 ++++++++ .../export_namecache/namecacheTest9_export.ts | 26 ++++++++++ .../namecacheTest9_export_expected.txt | 8 +++ .../namecacheTest9_export_expected_cache.txt | 7 +++ .../export_namecache/namecacheTest9_import.ts | 21 ++++++++ .../namecacheTest9_import_expected.txt | 4 ++ .../namecacheTest9_import_expected_cache.txt | 10 ++++ .../grammar/export_namecache/obfConfig.json | 21 ++++++++ .../xcommonjs-exports_1_expected.txt | 14 +++--- .../xcommonjs-exports_2_expected.txt | 2 +- .../xcommonjs-require_1_expected.txt | 24 ++++----- .../xcommonjs-require_2_expected.txt | 8 +-- .../y1_export_alias_expected.txt | 12 ++--- .../y1_import_alias_expected.txt | 12 ++--- .../y1_import_export_indrect_expected.txt | 14 +++--- .../y2_export_default_func_expected.txt | 4 +- .../y2_import_default_expected.txt | 8 +-- .../y3_export_list_default_expected.txt | 6 +-- .../y3_import_list_default_expected.txt | 8 +-- .../y4_export_as_expected.txt | 2 +- 32 files changed, 472 insertions(+), 59 deletions(-) create mode 100644 arkguard/test/grammar/export_namecache/namecacheTest7_export.ts create mode 100644 arkguard/test/grammar/export_namecache/namecacheTest7_export_expected.txt create mode 100644 arkguard/test/grammar/export_namecache/namecacheTest7_export_expected_cache.txt create mode 100644 arkguard/test/grammar/export_namecache/namecacheTest7_import.ts create mode 100644 arkguard/test/grammar/export_namecache/namecacheTest7_import_expected.txt create mode 100644 arkguard/test/grammar/export_namecache/namecacheTest7_import_expected_cache.txt create mode 100644 arkguard/test/grammar/export_namecache/namecacheTest8_export.ts create mode 100644 arkguard/test/grammar/export_namecache/namecacheTest8_export_expected.txt create mode 100644 arkguard/test/grammar/export_namecache/namecacheTest8_export_expected_cache.txt create mode 100644 arkguard/test/grammar/export_namecache/namecacheTest8_import.ts create mode 100644 arkguard/test/grammar/export_namecache/namecacheTest8_import_expected.txt create mode 100644 arkguard/test/grammar/export_namecache/namecacheTest8_import_expected_cache.txt create mode 100644 arkguard/test/grammar/export_namecache/namecacheTest9_export.ts create mode 100644 arkguard/test/grammar/export_namecache/namecacheTest9_export_expected.txt create mode 100644 arkguard/test/grammar/export_namecache/namecacheTest9_export_expected_cache.txt create mode 100644 arkguard/test/grammar/export_namecache/namecacheTest9_import.ts create mode 100644 arkguard/test/grammar/export_namecache/namecacheTest9_import_expected.txt create mode 100644 arkguard/test/grammar/export_namecache/namecacheTest9_import_expected_cache.txt create mode 100644 arkguard/test/grammar/export_namecache/obfConfig.json diff --git a/arkguard/src/utils/ScopeAnalyzer.ts b/arkguard/src/utils/ScopeAnalyzer.ts index b64f01e0b7..1e889ba074 100644 --- a/arkguard/src/utils/ScopeAnalyzer.ts +++ b/arkguard/src/utils/ScopeAnalyzer.ts @@ -317,9 +317,9 @@ namespace secharmony { if (def.exportSymbol) { current.exportNames.add(def.name); current.addDefinition(def.exportSymbol, true); + } else { + current.addDefinition(def); } - - current.addDefinition(def); }); } diff --git a/arkguard/test/grammar/export_namecache/namecacheTest7_export.ts b/arkguard/test/grammar/export_namecache/namecacheTest7_export.ts new file mode 100644 index 0000000000..b20628c1f6 --- /dev/null +++ b/arkguard/test/grammar/export_namecache/namecacheTest7_export.ts @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +export default function add(a: number, b: number): number { + return a + b; +} + +function subtract(a: number, b: number): number { + return a - b; +} + +export function multiply(a: number, b: number): number { + return a * b; +} + +export { multiply as times }; + +export const PI: number = 3.14; + +export class Student { + name: string; + age: number; + constructor(name: string, age: number) { + this.name = name; + this.age = age; + }; +} + +interface Lesson { + id: number, + date: string +} + +type customType = string; + +export { subtract, customType, Lesson }; \ No newline at end of file diff --git a/arkguard/test/grammar/export_namecache/namecacheTest7_export_expected.txt b/arkguard/test/grammar/export_namecache/namecacheTest7_export_expected.txt new file mode 100644 index 0000000000..fa6f68ef08 --- /dev/null +++ b/arkguard/test/grammar/export_namecache/namecacheTest7_export_expected.txt @@ -0,0 +1,26 @@ +export default function add(t: number, u: number): number { + return t + u; +} +function i(r: number, s: number): number { + return r - s; +} +export function multiply(p: number, q: number): number { + return p * q; +} +export { multiply as m }; +export const PI: number = 3.14; +export class j { + name: string; + g: number; + constructor(n: string, o: number) { + this.name = n; + this.g = o; + } + ; +} +interface k { + id: number; + h: string; +} +type l = string; +export { i, l, k }; diff --git a/arkguard/test/grammar/export_namecache/namecacheTest7_export_expected_cache.txt b/arkguard/test/grammar/export_namecache/namecacheTest7_export_expected_cache.txt new file mode 100644 index 0000000000..47012b8854 --- /dev/null +++ b/arkguard/test/grammar/export_namecache/namecacheTest7_export_expected_cache.txt @@ -0,0 +1,23 @@ +{ + "IdentifierCache": { + "#default": "default", + "#PI": "PI", + "#Student": "j", + "#Lesson": "k", + "#customType": "l", + "#times": "m", + "Student#$0#name": "n", + "Student#$0#age": "o", + "multiply#a": "p", + "multiply#b": "q", + "subtract#a": "r", + "subtract#b": "s", + "add#a": "t", + "add#b": "u", + "#subtract:21:23": "i", + "#multiply:25:27": "multiply" + }, + "MemberMethodCache": { + "Student:36:39": "j" + } +} \ No newline at end of file diff --git a/arkguard/test/grammar/export_namecache/namecacheTest7_import.ts b/arkguard/test/grammar/export_namecache/namecacheTest7_import.ts new file mode 100644 index 0000000000..f20d286745 --- /dev/null +++ b/arkguard/test/grammar/export_namecache/namecacheTest7_import.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +import add from './namecacheTest7_export'; +import { multiply, times } from './namecacheTest7_export'; +import { PI, Student } from './namecacheTest7_export'; +import { subtract, Lesson } from './namecacheTest7_export'; +import type { customType } from './namecacheTest7_export'; + +let xiaoming = new Student("xiaoming", 12); +let xiaohong: Student = new Student("xiaohong", 11); +var value: customType = "hello"; +const factor: number = 5; +let equal = (times(factor, PI) == multiply(factor, PI)); +let math: Lesson = { + id: 1, + date: "2023" +}; \ No newline at end of file diff --git a/arkguard/test/grammar/export_namecache/namecacheTest7_import_expected.txt b/arkguard/test/grammar/export_namecache/namecacheTest7_import_expected.txt new file mode 100644 index 0000000000..309dd5033b --- /dev/null +++ b/arkguard/test/grammar/export_namecache/namecacheTest7_import_expected.txt @@ -0,0 +1,14 @@ +import add from './namecacheTest7_export'; +import { multiply, m } from './namecacheTest7_export'; +import { PI, j } from './namecacheTest7_export'; +import { i, k } from './namecacheTest7_export'; +import type { l } from './namecacheTest7_export'; +let v = new j("xiaoming", 12); +let a1: j = new j("xiaohong", 11); +var value: l = "hello"; +const b1: number = 5; +let c1 = (m(b1, PI) == multiply(b1, PI)); +let d1: k = { + id: 1, + h: "2023" +}; diff --git a/arkguard/test/grammar/export_namecache/namecacheTest7_import_expected_cache.txt b/arkguard/test/grammar/export_namecache/namecacheTest7_import_expected_cache.txt new file mode 100644 index 0000000000..880d14ffe1 --- /dev/null +++ b/arkguard/test/grammar/export_namecache/namecacheTest7_import_expected_cache.txt @@ -0,0 +1,19 @@ +{ + "IdentifierCache": { + "#add": "add", + "#multiply": "multiply", + "#times": "m", + "#PI": "PI", + "#Student": "j", + "#subtract": "i", + "#Lesson": "k", + "#customType": "l", + "#xiaoming": "v", + "#xiaohong": "a1", + "#value": "value", + "#factor": "b1", + "#equal": "c1", + "#math": "d1" + }, + "MemberMethodCache": {} +} \ No newline at end of file diff --git a/arkguard/test/grammar/export_namecache/namecacheTest8_export.ts b/arkguard/test/grammar/export_namecache/namecacheTest8_export.ts new file mode 100644 index 0000000000..0ab05e685f --- /dev/null +++ b/arkguard/test/grammar/export_namecache/namecacheTest8_export.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +export default class Student { + name: string; + age: number; + constructor(name: string, age: number) { + this.name = name; + this.age = age; + }; +}; + +class Particle { + public row: number = 0; + public col: number = 0; +}; + +interface Lesson { + id: number, + date: string, + students: Student[] +}; + +export type Klass = { + date: number; + name: string; +}; + +export type customType = Student; + +export type { Particle }; +export { Lesson }; \ No newline at end of file diff --git a/arkguard/test/grammar/export_namecache/namecacheTest8_export_expected.txt b/arkguard/test/grammar/export_namecache/namecacheTest8_export_expected.txt new file mode 100644 index 0000000000..8ed86a2dc7 --- /dev/null +++ b/arkguard/test/grammar/export_namecache/namecacheTest8_export_expected.txt @@ -0,0 +1,28 @@ +export default class Student { + name: string; + g: number; + constructor(g1: string, h1: number) { + this.name = g1; + this.g = h1; + } + ; +} +; +class e1 { + public o: number = 0; + public p: number = 0; +} +; +interface k { + id: number; + h: string; + q: Student[]; +} +; +export type f1 = { + h: number; + name: string; +}; +export type l = Student; +export type { e1 }; +export { k }; diff --git a/arkguard/test/grammar/export_namecache/namecacheTest8_export_expected_cache.txt b/arkguard/test/grammar/export_namecache/namecacheTest8_export_expected_cache.txt new file mode 100644 index 0000000000..8bc28e84a8 --- /dev/null +++ b/arkguard/test/grammar/export_namecache/namecacheTest8_export_expected_cache.txt @@ -0,0 +1,14 @@ +{ + "IdentifierCache": { + "#default": "default", + "#Particle": "e1", + "#Lesson": "k", + "#Klass": "f1", + "#customType": "l", + "Student#$0#name": "g1", + "Student#$0#age": "h1" + }, + "MemberMethodCache": { + "Student:20:23": "Student" + } +} \ No newline at end of file diff --git a/arkguard/test/grammar/export_namecache/namecacheTest8_import.ts b/arkguard/test/grammar/export_namecache/namecacheTest8_import.ts new file mode 100644 index 0000000000..d3f4c6bff9 --- /dev/null +++ b/arkguard/test/grammar/export_namecache/namecacheTest8_import.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +import Student from './namecacheTest8_export'; +import type { Particle, Lesson, Klass, customType } from './namecacheTest8_export'; + +function test(s: Student, p: Particle, l: Lesson, k: Klass, c: customType): void { +} + +function init(p: Particle): void { + p.row = 1; + p.col = 2; +} + +let students: Student[]; +const math: Lesson = { + id: 0, + date: "2023", + students: [] +}; \ No newline at end of file diff --git a/arkguard/test/grammar/export_namecache/namecacheTest8_import_expected.txt b/arkguard/test/grammar/export_namecache/namecacheTest8_import_expected.txt new file mode 100644 index 0000000000..ab9a34bece --- /dev/null +++ b/arkguard/test/grammar/export_namecache/namecacheTest8_import_expected.txt @@ -0,0 +1,14 @@ +import j from './namecacheTest8_export'; +import type { e1, k, f1, l } from './namecacheTest8_export'; +function test(j1: j, k1: e1, l1: k, m1: f1, n1: l): void { +} +function init(i1: e1): void { + i1.o = 1; + i1.p = 2; +} +let q: j[]; +const d1: k = { + id: 0, + h: "2023", + q: [] +}; diff --git a/arkguard/test/grammar/export_namecache/namecacheTest8_import_expected_cache.txt b/arkguard/test/grammar/export_namecache/namecacheTest8_import_expected_cache.txt new file mode 100644 index 0000000000..4863217612 --- /dev/null +++ b/arkguard/test/grammar/export_namecache/namecacheTest8_import_expected_cache.txt @@ -0,0 +1,20 @@ +{ + "IdentifierCache": { + "#Student": "j", + "#Particle": "e1", + "#Lesson": "k", + "#Klass": "f1", + "#customType": "l", + "#students": "q", + "#math": "d1", + "init#p": "i1", + "test#s": "j1", + "test#p": "k1", + "test#l": "l1", + "test#k": "m1", + "test#c": "n1", + "#test:20:21": "test", + "#init:23:26": "init" + }, + "MemberMethodCache": {} +} \ No newline at end of file diff --git a/arkguard/test/grammar/export_namecache/namecacheTest9_export.ts b/arkguard/test/grammar/export_namecache/namecacheTest9_export.ts new file mode 100644 index 0000000000..c28ff924a7 --- /dev/null +++ b/arkguard/test/grammar/export_namecache/namecacheTest9_export.ts @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +interface I { + id: number; +} + +class A { + prop = 1; +} + +export { type I }; +export type { A }; \ No newline at end of file diff --git a/arkguard/test/grammar/export_namecache/namecacheTest9_export_expected.txt b/arkguard/test/grammar/export_namecache/namecacheTest9_export_expected.txt new file mode 100644 index 0000000000..c5b7f66e2b --- /dev/null +++ b/arkguard/test/grammar/export_namecache/namecacheTest9_export_expected.txt @@ -0,0 +1,8 @@ +interface o1 { + id: number; +} +class q1 { + t = 1; +} +export { type o1 }; +export type { q1 }; diff --git a/arkguard/test/grammar/export_namecache/namecacheTest9_export_expected_cache.txt b/arkguard/test/grammar/export_namecache/namecacheTest9_export_expected_cache.txt new file mode 100644 index 0000000000..b0ba6d7d6e --- /dev/null +++ b/arkguard/test/grammar/export_namecache/namecacheTest9_export_expected_cache.txt @@ -0,0 +1,7 @@ +{ + "IdentifierCache": { + "#I": "o1", + "#A": "q1" + }, + "MemberMethodCache": {} +} \ No newline at end of file diff --git a/arkguard/test/grammar/export_namecache/namecacheTest9_import.ts b/arkguard/test/grammar/export_namecache/namecacheTest9_import.ts new file mode 100644 index 0000000000..998ce5fe90 --- /dev/null +++ b/arkguard/test/grammar/export_namecache/namecacheTest9_import.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +import type { I } from "./namecacheTest9_export"; +import { type A } from "./namecacheTest9_export"; + + +function test(i: I, a: A): void { }; \ No newline at end of file diff --git a/arkguard/test/grammar/export_namecache/namecacheTest9_import_expected.txt b/arkguard/test/grammar/export_namecache/namecacheTest9_import_expected.txt new file mode 100644 index 0000000000..ec8143cc19 --- /dev/null +++ b/arkguard/test/grammar/export_namecache/namecacheTest9_import_expected.txt @@ -0,0 +1,4 @@ +import type { o1 } from "./namecacheTest9_export"; +import { type q1 } from "./namecacheTest9_export"; +function test(r1: o1, s1: q1): void { } +; diff --git a/arkguard/test/grammar/export_namecache/namecacheTest9_import_expected_cache.txt b/arkguard/test/grammar/export_namecache/namecacheTest9_import_expected_cache.txt new file mode 100644 index 0000000000..4dfdd597e2 --- /dev/null +++ b/arkguard/test/grammar/export_namecache/namecacheTest9_import_expected_cache.txt @@ -0,0 +1,10 @@ +{ + "IdentifierCache": { + "#I": "o1", + "#A": "q1", + "test#i": "r1", + "test#a": "s1", + "#test:21:21": "test" + }, + "MemberMethodCache": {} +} \ No newline at end of file diff --git a/arkguard/test/grammar/export_namecache/obfConfig.json b/arkguard/test/grammar/export_namecache/obfConfig.json new file mode 100644 index 0000000000..39e9cf62b5 --- /dev/null +++ b/arkguard/test/grammar/export_namecache/obfConfig.json @@ -0,0 +1,21 @@ +{ + "mCompact": false, + "mRemoveComments": true, + "mOutputDir": "../../local", + "mDisableHilog": false, + "mDisableConsole": false, + "mSimplify": false, + "mNameObfuscation": { + "mEnable": true, + "mNameGeneratorType": 1, + "mDictionaryList": [], + "mReservedNames": [], + "mRenameProperties": true, + "mReservedProperties": [], + "mKeepStringProperty": false, + "mTopLevel": true + }, + "mEnableSourceMap": true, + "mEnableNameCache": true, + "mExportObfuscation": true +} \ No newline at end of file diff --git a/arkguard/test/grammar/export_obfuscation/xcommonjs-exports_1_expected.txt b/arkguard/test/grammar/export_obfuscation/xcommonjs-exports_1_expected.txt index 9b51a4a492..dc4e491831 100644 --- a/arkguard/test/grammar/export_obfuscation/xcommonjs-exports_1_expected.txt +++ b/arkguard/test/grammar/export_obfuscation/xcommonjs-exports_1_expected.txt @@ -12,21 +12,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -let k5 = 1; -exports.v3 = k5; +let h5 = 1; +exports.v3 = h5; exports.w3 = 2; exports.x3 = function () { return 'Hello, world!'; }; class n4 { y3 = '00001'; - g4 = { i4: 'jack3', m4: 12 }; + j4 = { l4: 'jack3', m4: 12 }; } exports.n4 = n4; exports.o4 = class { - q4 = 11; - r4 = 15; - s4() { - return this.r4; + v4 = 11; + w4 = 15; + x4() { + return this.w4; } }; diff --git a/arkguard/test/grammar/export_obfuscation/xcommonjs-exports_2_expected.txt b/arkguard/test/grammar/export_obfuscation/xcommonjs-exports_2_expected.txt index 89cf29bb38..dd6771a63a 100644 --- a/arkguard/test/grammar/export_obfuscation/xcommonjs-exports_2_expected.txt +++ b/arkguard/test/grammar/export_obfuscation/xcommonjs-exports_2_expected.txt @@ -17,5 +17,5 @@ module.exports = { z4: function () { return 'Hello, world2!'; }, - a5: { p2: 22 } + i5: { p2: 22 } }; diff --git a/arkguard/test/grammar/export_obfuscation/xcommonjs-require_1_expected.txt b/arkguard/test/grammar/export_obfuscation/xcommonjs-require_1_expected.txt index 4396799526..a9de37e13d 100644 --- a/arkguard/test/grammar/export_obfuscation/xcommonjs-require_1_expected.txt +++ b/arkguard/test/grammar/export_obfuscation/xcommonjs-require_1_expected.txt @@ -13,15 +13,15 @@ * limitations under the License. */ const assert = require('assert'); -const m5 = require('./xcommonjs-exports_1'); -assert.strictEqual(m5.v3, 1); -assert.strictEqual(m5.w3, 2); -assert.strictEqual(m5.x3(), 'Hello, world!'); -let n5 = new m5.n4(); -assert.strictEqual(n5.y3, '00001'); -assert.strictEqual(n5.g4.i4, 'jack3'); -assert.strictEqual(n5.g4.m4, 12); -let o5 = new m5.o4(); -o5.r4 = 16; -assert.strictEqual(o5.q4, 11); -assert.strictEqual(o5.s4(), 16); +const j5 = require('./xcommonjs-exports_1'); +assert.strictEqual(j5.v3, 1); +assert.strictEqual(j5.w3, 2); +assert.strictEqual(j5.x3(), 'Hello, world!'); +let k5 = new j5.n4(); +assert.strictEqual(k5.y3, '00001'); +assert.strictEqual(k5.j4.l4, 'jack3'); +assert.strictEqual(k5.j4.m4, 12); +let l5 = new j5.o4(); +l5.w4 = 16; +assert.strictEqual(l5.v4, 11); +assert.strictEqual(l5.x4(), 16); diff --git a/arkguard/test/grammar/export_obfuscation/xcommonjs-require_2_expected.txt b/arkguard/test/grammar/export_obfuscation/xcommonjs-require_2_expected.txt index 8a0646dc0d..7c876091d7 100644 --- a/arkguard/test/grammar/export_obfuscation/xcommonjs-require_2_expected.txt +++ b/arkguard/test/grammar/export_obfuscation/xcommonjs-require_2_expected.txt @@ -13,7 +13,7 @@ * limitations under the License. */ const assert = require('assert'); -const p5 = require('./xcommonjs-exports_2'); -assert.strictEqual(p5.y4, 20); -assert.strictEqual(p5.z4(), 'Hello, world2!'); -assert.strictEqual(p5.a5.p2, 22); +const m5 = require('./xcommonjs-exports_2'); +assert.strictEqual(m5.y4, 20); +assert.strictEqual(m5.z4(), 'Hello, world2!'); +assert.strictEqual(m5.i5.p2, 22); diff --git a/arkguard/test/grammar/export_obfuscation/y1_export_alias_expected.txt b/arkguard/test/grammar/export_obfuscation/y1_export_alias_expected.txt index a4dbadccb3..36caa69aea 100644 --- a/arkguard/test/grammar/export_obfuscation/y1_export_alias_expected.txt +++ b/arkguard/test/grammar/export_obfuscation/y1_export_alias_expected.txt @@ -12,16 +12,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -export function q5() { +export function p5() { return '11'; } -interface s5 { - b5: number; +interface q5 { + n5: number; } -class t5 { - c5: number = 2; +class r5 { + o5: number = 2; } export default function fooOrignal2() { return 22; } -export { s5, t5 as u5 }; +export { q5, r5 as s5 }; diff --git a/arkguard/test/grammar/export_obfuscation/y1_import_alias_expected.txt b/arkguard/test/grammar/export_obfuscation/y1_import_alias_expected.txt index 824205d22e..54ed04ff13 100644 --- a/arkguard/test/grammar/export_obfuscation/y1_import_alias_expected.txt +++ b/arkguard/test/grammar/export_obfuscation/y1_import_alias_expected.txt @@ -13,10 +13,10 @@ * limitations under the License. */ import assert from 'assert'; -export * as y5 from './y1_export_alias'; +export * as w5 from './y1_export_alias'; export { default } from './y1_export_alias'; -import * as v5 from './y1_export_alias'; -let w5 = new v5.u5; -assert(w5.c5 === 2, 'success'); -type x5 = v5.s5; -assert(v5.q5() === '11', 'success'); +import * as t5 from './y1_export_alias'; +let u5 = new t5.s5; +assert(u5.o5 === 2, 'success'); +type v5 = t5.q5; +assert(t5.p5() === '11', 'success'); diff --git a/arkguard/test/grammar/export_obfuscation/y1_import_export_indrect_expected.txt b/arkguard/test/grammar/export_obfuscation/y1_import_export_indrect_expected.txt index f75b38b667..ef0f5a048c 100644 --- a/arkguard/test/grammar/export_obfuscation/y1_import_export_indrect_expected.txt +++ b/arkguard/test/grammar/export_obfuscation/y1_import_export_indrect_expected.txt @@ -13,11 +13,11 @@ * limitations under the License. */ import assert from 'assert'; -import { default as z5 } from './y1_export_default_value'; -import d4, { y5 } from './y1_import_alias'; -let w5 = new y5.u5; -assert(w5.c5 === 2, 'success'); -type x5 = y5.s5; -assert(y5.q5() === '11', 'success'); +import { default as x5 } from './y1_export_default_value'; +import d4, { w5 } from './y1_import_alias'; +let u5 = new w5.s5; +assert(u5.o5 === 2, 'success'); +type v5 = w5.q5; +assert(w5.p5() === '11', 'success'); assert(d4() === 22, 'success'); -assert(z5 === 5, 'success'); +assert(x5 === 5, 'success'); diff --git a/arkguard/test/grammar/export_obfuscation/y2_export_default_func_expected.txt b/arkguard/test/grammar/export_obfuscation/y2_export_default_func_expected.txt index 34725cb17f..5349b96aac 100644 --- a/arkguard/test/grammar/export_obfuscation/y2_export_default_func_expected.txt +++ b/arkguard/test/grammar/export_obfuscation/y2_export_default_func_expected.txt @@ -12,6 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -export default function fooY2(b6: number, c6: number) { - return b6 * c6; +export default function fooY2(y5: number, z5: number) { + return y5 * z5; } diff --git a/arkguard/test/grammar/export_obfuscation/y2_import_default_expected.txt b/arkguard/test/grammar/export_obfuscation/y2_import_default_expected.txt index f398d07bcf..a613bc13e0 100644 --- a/arkguard/test/grammar/export_obfuscation/y2_import_default_expected.txt +++ b/arkguard/test/grammar/export_obfuscation/y2_import_default_expected.txt @@ -13,7 +13,7 @@ * limitations under the License. */ import assert from 'assert'; -import d6 from './y2_export_default_func'; -import { default as e6 } from './y2_export_default_func'; -assert(d6(2, 3) === 6, 'success'); -assert(e6(3, 4) === 12, 'success'); +import a6 from './y2_export_default_func'; +import { default as b6 } from './y2_export_default_func'; +assert(a6(2, 3) === 6, 'success'); +assert(b6(3, 4) === 12, 'success'); diff --git a/arkguard/test/grammar/export_obfuscation/y3_export_list_default_expected.txt b/arkguard/test/grammar/export_obfuscation/y3_export_list_default_expected.txt index de6505fb30..1a96f373a1 100644 --- a/arkguard/test/grammar/export_obfuscation/y3_export_list_default_expected.txt +++ b/arkguard/test/grammar/export_obfuscation/y3_export_list_default_expected.txt @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -function f6(g6: number, h6: number) { - return g6 / h6; +function c6(d6: number, e6: number) { + return d6 / e6; } -export { f6 as default }; +export { c6 as default }; diff --git a/arkguard/test/grammar/export_obfuscation/y3_import_list_default_expected.txt b/arkguard/test/grammar/export_obfuscation/y3_import_list_default_expected.txt index d592269c3b..57731c6b3c 100644 --- a/arkguard/test/grammar/export_obfuscation/y3_import_list_default_expected.txt +++ b/arkguard/test/grammar/export_obfuscation/y3_import_list_default_expected.txt @@ -13,7 +13,7 @@ * limitations under the License. */ import assert from 'assert'; -import i6 from './y3_export_list_default'; -import { default as j6 } from './y3_export_list_default'; -assert(i6(6, 3) === 2, 'success'); -assert(j6(8, 2) === 4, 'success'); +import f6 from './y3_export_list_default'; +import { default as g6 } from './y3_export_list_default'; +assert(f6(6, 3) === 2, 'success'); +assert(g6(8, 2) === 4, 'success'); diff --git a/arkguard/test/grammar/export_obfuscation/y4_export_as_expected.txt b/arkguard/test/grammar/export_obfuscation/y4_export_as_expected.txt index 340a1573ee..abfbbab904 100644 --- a/arkguard/test/grammar/export_obfuscation/y4_export_as_expected.txt +++ b/arkguard/test/grammar/export_obfuscation/y4_export_as_expected.txt @@ -12,5 +12,5 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -export { default as k6 } from './y1_export_alias'; +export { default as h6 } from './y1_export_alias'; export * as default from './y3_export_list_default'; -- Gitee