@@ -10,7 +10,7 @@ test("should throw an unsafe-import because the hexadecimal string is equal to t
10
10
const str = "const foo = '68747470'" ;
11
11
const ast = parseScript ( str ) ;
12
12
13
- const sastAnalysis = getSastAnalysis ( str , isLiteral ) ;
13
+ const sastAnalysis = getSastAnalysis ( isLiteral ) ;
14
14
const analyzeStringMock = t . mock . method ( sastAnalysis . sourceFile . deobfuscator , "analyzeString" ) ;
15
15
sastAnalysis . execute ( ast . body ) ;
16
16
@@ -28,7 +28,7 @@ test("should throw an encoded-literal warning because the hexadecimal value is e
28
28
const str = "const _t = globalThis['72657175697265']" ;
29
29
const ast = parseScript ( str ) ;
30
30
31
- const sastAnalysis = getSastAnalysis ( str , isLiteral ) ;
31
+ const sastAnalysis = getSastAnalysis ( isLiteral ) ;
32
32
const analyzeStringMock = t . mock . method ( sastAnalysis . sourceFile . deobfuscator , "analyzeString" ) ;
33
33
sastAnalysis . execute ( ast . body ) ;
34
34
@@ -44,7 +44,7 @@ test("should throw an encoded-literal warning because the hexadecimal value is e
44
44
test ( "should not throw an encoded-literal warning because hexadecimal value is safe" , ( ) => {
45
45
const str = "const foo = '123456789'" ;
46
46
const ast = parseScript ( str ) ;
47
- const sastAnalysis = getSastAnalysis ( str , isLiteral )
47
+ const sastAnalysis = getSastAnalysis ( isLiteral )
48
48
. execute ( ast . body ) ;
49
49
50
50
assert . strictEqual ( sastAnalysis . warnings ( ) . length , 0 ) ;
@@ -54,7 +54,7 @@ test("should throw an encoded-literal warning because hexadecimal value is not s
54
54
// Note: hexadecimal equal 'hello world'
55
55
const str = "const foo = '68656c6c6f20776f726c64'" ;
56
56
const ast = parseScript ( str ) ;
57
- const sastAnalysis = getSastAnalysis ( str , isLiteral )
57
+ const sastAnalysis = getSastAnalysis ( isLiteral )
58
58
. execute ( ast . body ) ;
59
59
60
60
assert . strictEqual ( sastAnalysis . warnings ( ) . length , 1 ) ;
@@ -66,7 +66,7 @@ test("should not throw any warnings without hexadecimal value (and should call a
66
66
const str = "const foo = 'hello world!'" ;
67
67
const ast = parseScript ( str ) ;
68
68
69
- const sastAnalysis = getSastAnalysis ( str , isLiteral ) ;
69
+ const sastAnalysis = getSastAnalysis ( isLiteral ) ;
70
70
const analyzeLiteralMock = t . mock . method ( sastAnalysis . sourceFile , "analyzeLiteral" ) ;
71
71
sastAnalysis . execute ( ast . body ) ;
72
72
@@ -81,7 +81,7 @@ test("should not throw any warnings without hexadecimal value (and should call a
81
81
test ( "should detect shady link when an URL is bit.ly" , ( ) => {
82
82
const str = "const foo = 'http://bit.ly/foo'" ;
83
83
const ast = parseScript ( str ) ;
84
- const sastAnalysis = getSastAnalysis ( str , isLiteral ) . execute ( ast . body ) ;
84
+ const sastAnalysis = getSastAnalysis ( isLiteral ) . execute ( ast . body ) ;
85
85
86
86
assert . strictEqual ( sastAnalysis . warnings ( ) . length , 1 ) ;
87
87
const warning = sastAnalysis . getWarning ( "shady-link" ) ;
@@ -91,7 +91,7 @@ test("should detect shady link when an URL is bit.ly", () => {
91
91
test ( "should detect shady link when an URL is ipinfo.io when protocol is http" , ( ) => {
92
92
const str = "const foo = 'http://ipinfo.io/json'" ;
93
93
const ast = parseScript ( str ) ;
94
- const sastAnalysis = getSastAnalysis ( str , isLiteral ) . execute ( ast . body ) ;
94
+ const sastAnalysis = getSastAnalysis ( isLiteral ) . execute ( ast . body ) ;
95
95
assert . strictEqual ( sastAnalysis . warnings ( ) . length , 1 ) ;
96
96
const warning = sastAnalysis . getWarning ( "shady-link" ) ;
97
97
assert . strictEqual ( warning . value , "http://ipinfo.io/json" ) ;
@@ -100,7 +100,7 @@ test("should detect shady link when an URL is ipinfo.io when protocol is http",
100
100
test ( "should detect shady link when an URL is ipinfo.io when protocol is https" , ( ) => {
101
101
const str = "const foo = 'https://ipinfo.io/json'" ;
102
102
const ast = parseScript ( str ) ;
103
- const sastAnalysis = getSastAnalysis ( str , isLiteral ) . execute ( ast . body ) ;
103
+ const sastAnalysis = getSastAnalysis ( isLiteral ) . execute ( ast . body ) ;
104
104
assert . strictEqual ( sastAnalysis . warnings ( ) . length , 1 ) ;
105
105
const warning = sastAnalysis . getWarning ( "shady-link" ) ;
106
106
assert . strictEqual ( warning . value , "https://ipinfo.io/json" ) ;
@@ -109,7 +109,7 @@ test("should detect shady link when an URL is ipinfo.io when protocol is https",
109
109
test ( "should detect shady link when an URL is httpbin.org when protocol is http" , ( ) => {
110
110
const str = "const foo = 'http://httpbin.org/ip'" ;
111
111
const ast = parseScript ( str ) ;
112
- const sastAnalysis = getSastAnalysis ( str , isLiteral ) . execute ( ast . body ) ;
112
+ const sastAnalysis = getSastAnalysis ( isLiteral ) . execute ( ast . body ) ;
113
113
assert . strictEqual ( sastAnalysis . warnings ( ) . length , 1 ) ;
114
114
const warning = sastAnalysis . getWarning ( "shady-link" ) ;
115
115
assert . strictEqual ( warning . value , "http://httpbin.org/ip" ) ;
@@ -118,7 +118,7 @@ test("should detect shady link when an URL is httpbin.org when protocol is http"
118
118
test ( "should detect shady link when an URL is httpbin.org when protocol is https" , ( ) => {
119
119
const str = "const foo = 'https://httpbin.org/ip'" ;
120
120
const ast = parseScript ( str ) ;
121
- const sastAnalysis = getSastAnalysis ( str , isLiteral ) . execute ( ast . body ) ;
121
+ const sastAnalysis = getSastAnalysis ( isLiteral ) . execute ( ast . body ) ;
122
122
assert . strictEqual ( sastAnalysis . warnings ( ) . length , 1 ) ;
123
123
const warning = sastAnalysis . getWarning ( "shady-link" ) ;
124
124
assert . strictEqual ( warning . value , "https://httpbin.org/ip" ) ;
@@ -127,7 +127,7 @@ test("should detect shady link when an URL is httpbin.org when protocol is https
127
127
test ( "should detect shady link when an URL has a suspicious domain" , ( ) => {
128
128
const str = "const foo = 'http://foobar.link'" ;
129
129
const ast = parseScript ( str ) ;
130
- const sastAnalysis = getSastAnalysis ( str , isLiteral ) . execute ( ast . body ) ;
130
+ const sastAnalysis = getSastAnalysis ( isLiteral ) . execute ( ast . body ) ;
131
131
132
132
assert . strictEqual ( sastAnalysis . warnings ( ) . length , 1 ) ;
133
133
const warning = sastAnalysis . getWarning ( "shady-link" ) ;
@@ -137,23 +137,23 @@ test("should detect shady link when an URL has a suspicious domain", () => {
137
137
test ( "should not mark suspicious links the IPv4 address range 127.0.0.0/8 (localhost 127.0.0.1)" , ( ) => {
138
138
const str = "const IPv4URL = ['http://127.0.0.1/script', 'http://127.7.7.7/script']" ;
139
139
const ast = parseScript ( str ) ;
140
- const sastAnalysis = getSastAnalysis ( str , isLiteral ) . execute ( ast . body ) ;
140
+ const sastAnalysis = getSastAnalysis ( isLiteral ) . execute ( ast . body ) ;
141
141
142
142
assert . ok ( ! sastAnalysis . warnings ( ) . length ) ;
143
143
} ) ;
144
144
145
145
test ( "should not be considered suspicious a link with a raw IPv4 address 127.0.0.1 and a port" , ( ) => {
146
146
const str = "const IPv4URL = 'http://127.0.0.1:80/script'" ;
147
147
const ast = parseScript ( str ) ;
148
- const sastAnalysis = getSastAnalysis ( str , isLiteral ) . execute ( ast . body ) ;
148
+ const sastAnalysis = getSastAnalysis ( isLiteral ) . execute ( ast . body ) ;
149
149
150
150
assert . ok ( ! sastAnalysis . warnings ( ) . length ) ;
151
151
} ) ;
152
152
153
153
test ( "should detect the link as suspicious when a URL contains a raw IPv4 address" , ( ) => {
154
154
const str = "const IPv4URL = 'http://77.244.210.247/burpcollaborator.txt'" ;
155
155
const ast = parseScript ( str ) ;
156
- const sastAnalysis = getSastAnalysis ( str , isLiteral ) . execute ( ast . body ) ;
156
+ const sastAnalysis = getSastAnalysis ( isLiteral ) . execute ( ast . body ) ;
157
157
158
158
assert . strictEqual ( sastAnalysis . warnings ( ) . length , 1 ) ;
159
159
const warning = sastAnalysis . getWarning ( "shady-link" ) ;
@@ -163,7 +163,7 @@ test("should detect the link as suspicious when a URL contains a raw IPv4 addres
163
163
test ( "should detect suspicious links when a URL contains a raw IPv4 address with port" , ( ) => {
164
164
const str = "const IPv4URL = 'http://77.244.210.247:8080/script'" ;
165
165
const ast = parseScript ( str ) ;
166
- const sastAnalysis = getSastAnalysis ( str , isLiteral ) . execute ( ast . body ) ;
166
+ const sastAnalysis = getSastAnalysis ( isLiteral ) . execute ( ast . body ) ;
167
167
168
168
assert . strictEqual ( sastAnalysis . warnings ( ) . length , 1 ) ;
169
169
const warning = sastAnalysis . getWarning ( "shady-link" ) ;
@@ -173,7 +173,7 @@ test("should detect suspicious links when a URL contains a raw IPv4 address with
173
173
test ( "should detect suspicious links when a URL contains a raw IPv6 address" , ( ) => {
174
174
const str = "const IPv6URL = 'http://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]/index.html'" ;
175
175
const ast = parseScript ( str ) ;
176
- const sastAnalysis = getSastAnalysis ( str , isLiteral ) . execute ( ast . body ) ;
176
+ const sastAnalysis = getSastAnalysis ( isLiteral ) . execute ( ast . body ) ;
177
177
178
178
assert . strictEqual ( sastAnalysis . warnings ( ) . length , 1 ) ;
179
179
const warning = sastAnalysis . getWarning ( "shady-link" ) ;
@@ -183,7 +183,7 @@ test("should detect suspicious links when a URL contains a raw IPv6 address", ()
183
183
test ( "should detect suspicious links when a URL contains a raw IPv6 address with port" , ( ) => {
184
184
const str = "const IPv6URL = 'http://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]:100/script'" ;
185
185
const ast = parseScript ( str ) ;
186
- const sastAnalysis = getSastAnalysis ( str , isLiteral ) . execute ( ast . body ) ;
186
+ const sastAnalysis = getSastAnalysis ( isLiteral ) . execute ( ast . body ) ;
187
187
188
188
assert . strictEqual ( sastAnalysis . warnings ( ) . length , 1 ) ;
189
189
const warning = sastAnalysis . getWarning ( "shady-link" ) ;
0 commit comments