File tree 3 files changed +31
-2
lines changed
3 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,8 @@ export default [
4
4
{
5
5
ignores : [
6
6
"**/test/fixtures/**/*" ,
7
- "**/test/probes/fixtures/**/*.js"
7
+ "**/test/probes/fixtures/**/*.js" ,
8
+ "**/examples/*.js"
8
9
]
9
10
} ,
10
11
...ESLintConfig ,
Original file line number Diff line number Diff line change @@ -129,7 +129,7 @@ export class SourceFile {
129
129
this . deobfuscator . walk ( node ) ;
130
130
131
131
// Detect TryStatement and CatchClause to known which dependency is required in a Try {} clause
132
- if ( node . type === "TryStatement" && typeof node . handler !== "undefined" ) {
132
+ if ( node . type === "TryStatement" && node . handler ) {
133
133
this . inTryStatement = true ;
134
134
}
135
135
else if ( node . type === "CatchClause" ) {
Original file line number Diff line number Diff line change
1
+ // Import Node.js Dependencies
2
+ import { test } from "node:test" ;
3
+ import assert from "node:assert" ;
4
+
5
+ // Import Internal Dependencies
6
+ import { AstAnalyser } from "../../index.js" ;
7
+
8
+ /**
9
+ * @see https://github.com/NodeSecure/js-x-ray/issues/312
10
+ */
11
+ test ( "SourceFile inTryStatement must ignore try/finally statements" , ( ) => {
12
+ const { dependencies } = new AstAnalyser ( ) . analyse ( `
13
+ try {
14
+ // do something
15
+ }
16
+ finally {
17
+
18
+ }
19
+
20
+ var import_ts = __toESM(require("foobar"), 1);
21
+ ` ) ;
22
+ assert . strictEqual ( dependencies . size , 1 ) ;
23
+ assert . ok ( dependencies . has ( "foobar" ) ) ;
24
+
25
+ const dependency = dependencies . get ( "foobar" ) ;
26
+ assert . strictEqual ( dependency . unsafe , false ) ;
27
+ assert . strictEqual ( dependency . inTry , false ) ;
28
+ } ) ;
You can’t perform that action at this time.
0 commit comments