Skip to content

Commit 42e2770

Browse files
committed
refactor: improve error handling and documentation
- Rename handleError to _handleError for clarity in index.ts - Update JSDoc comments in inline.ts and decode-strings.ts to enhance parameter descriptions - Mark saveObjects function as deprecated in save-objects.ts with a note for alternative usage - Adjust error handling in save-objects.ts and vm.ts to improve clarity and consistency - Make props in Console.vue optional for better flexibility - Remove unused computed property in Options.vue for cleaner code - Simplify props definition in Tooltip.vue
1 parent 71098c5 commit 42e2770

9 files changed

Lines changed: 15 additions & 16 deletions

File tree

packages/deob/src/ast-utils/inline.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import { findParent } from './matcher'
1313
* Example with `unsafeAssignments` being `true`:
1414
* `let a; a = 2; console.log(a);` -> `console.log(2);`
1515
*
16+
* @param binding Binding to inline
17+
* @param value Matcher for the initializer expression
1618
* @param unsafeAssignments Also inline assignments to the variable (not guaranteed to be the final value)
1719
*/
1820
export function inlineVariable(

packages/deob/src/deobfuscate/my-inline-decoder-wrappers.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ export default {
5555
// 调用传入参数 -57, 1080, 828, 469
5656
const callFn_args = ref.parentPath.node.arguments
5757

58-
// 实际用到的参数 _0x13ee81 - -674, _0x3dfa50
59-
const realFn_args = realFn.node.arguments
60-
6158
// 要替换的模版
6259
let templateCode = generate(realFn.node)
6360

packages/deob/src/deobfuscate/save-objects.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export type Objects = Record<`${string}_${string}`, t.ObjectExpression>
77

88
/**
99
* 保存代码中所有对象用于后续替换
10+
* @deprecated 该函数已弃用,请使用其他方式处理对象合并与替换
1011
* @example
1112
* var r = {
1213
* "PzXHf": "0|2|4|3|1",
@@ -39,7 +40,7 @@ export function saveObjects(ast: t.Node) {
3940

4041
traverse(ast, {
4142
VariableDeclaration: {
42-
exit(path, state) {
43+
exit(path, _state) {
4344
path.node.declarations.forEach((declaration) => {
4445
if (declaration.id.type === 'Identifier') {
4546
const objectName = declaration.id.name
@@ -133,8 +134,8 @@ export function saveObjects(ast: t.Node) {
133134
isReplace = true
134135
}
135136
}
136-
catch (error) {
137-
throw new Error('生成表达式失败')
137+
catch (_error: any) {
138+
throw new Error(`生成表达式失败${_error.message}`)
138139
}
139140

140141
if (isReplace) {

packages/deob/src/deobfuscate/vm.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ export class VMDecoder {
7171
const result = await this.sandbox(code)
7272
return result as unknown[]
7373
}
74-
catch (error) {
74+
// eslint-disable-next-line unused-imports/no-unused-vars
75+
catch (_error) {
7576
// ignore
7677
}
7778

packages/deob/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function parseCode(code: string): ParseResult<t.File> {
5454
}
5555

5656
// TODO: 错误输出处理 定位代码位置
57-
function handleError(error: any, rawCode: string) {
57+
function _handleError(error: any, rawCode: string) {
5858
if (error instanceof SyntaxError) {
5959
const codeFrame = codeFrameColumns(rawCode, {
6060
start: {

packages/deob/src/transforms/decode-strings.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import { evalCode } from '../deobfuscate/vm'
66

77
/**
88
* 执行解密器 (使用 eval 执行)
9-
* @param {*} decoder
9+
* @param sandbox 执行解密代码的沙箱环境
10+
* @param decoders 解密器列表
1011
* @example
1112
* _0x4698(_0x13ee81, _0x3dfa50)
1213
* ⬇️

website/components/Console.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import type { ConsoleLogEntry } from '~/types/logger'
33
import { Pane } from 'splitpanes'
44
55
const props = withDefaults(defineProps<{
6-
logs: ConsoleLogEntry[]
7-
size: number
8-
collapsed: boolean
6+
logs?: ConsoleLogEntry[]
7+
size?: number
8+
collapsed?: boolean
99
canExpand?: boolean
1010
}>(), {
1111
logs: () => [],

website/components/Options.vue

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ const isEvalCode = computed(
1515
const isCallCount = computed(
1616
() => options.value.decoderLocationMethod === 'callCount',
1717
)
18-
const isStringArray = computed(
19-
() => options.value.decoderLocationMethod === 'stringArray',
20-
)
2118
2219
const mangleModes = [
2320
{ value: 'off', label: '关闭' },

website/components/Tooltip.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts">
22
import { ref } from 'vue'
33
4-
const props = defineProps<{
4+
defineProps<{
55
text: string
66
}>()
77

0 commit comments

Comments
 (0)