@@ -9,11 +9,19 @@ suite('validateSafeBinaryPath', () => {
9
9
strictEqual ( validateSafeBinaryPath ( '/opt/oxc_language_server' ) , true ) ;
10
10
} ) ;
11
11
12
+ test ( 'should accept case variations of oxc_language_server' , ( ) => {
13
+ strictEqual ( validateSafeBinaryPath ( 'OXC_LANGUAGE_SERVER' ) , true ) ;
14
+ strictEqual ( validateSafeBinaryPath ( 'OXC_LANGUAGE_SERVER.exe' ) , true ) ;
15
+ strictEqual ( validateSafeBinaryPath ( '/usr/local/bin/OXC_LANGUAGE_SERVER' ) , true ) ;
16
+ strictEqual ( validateSafeBinaryPath ( 'C:\\Program Files\\OXC_LANGUAGE_SERVER.exe' ) , true ) ;
17
+ } ) ;
18
+
12
19
test ( 'should reject paths with directory traversal' , ( ) => {
13
20
strictEqual ( validateSafeBinaryPath ( '../oxc_language_server' ) , false ) ;
14
21
strictEqual ( validateSafeBinaryPath ( '../../oxc_language_server' ) , false ) ;
15
22
strictEqual ( validateSafeBinaryPath ( '/usr/local/../bin/oxc_language_server' ) , false ) ;
16
23
strictEqual ( validateSafeBinaryPath ( '..\\oxc_language_server' ) , false ) ;
24
+ strictEqual ( validateSafeBinaryPath ( '.\\oxc_language_server' ) , false ) ;
17
25
} ) ;
18
26
19
27
test ( 'should reject paths with malicious characters' , ( ) => {
@@ -24,6 +32,10 @@ suite('validateSafeBinaryPath', () => {
24
32
strictEqual ( validateSafeBinaryPath ( 'oxc_language_server<input.txt' ) , false ) ;
25
33
strictEqual ( validateSafeBinaryPath ( 'oxc_language_server`whoami`' ) , false ) ;
26
34
strictEqual ( validateSafeBinaryPath ( 'oxc_language_server!' ) , false ) ;
35
+
36
+ // windows specific
37
+ strictEqual ( validateSafeBinaryPath ( 'oxc_language_server^&pause' ) , false ) ;
38
+ strictEqual ( validateSafeBinaryPath ( 'oxc_language_server & del /f *' ) , false ) ;
27
39
} ) ;
28
40
29
41
test ( 'should reject paths not containing oxc_language_server' , ( ) => {
@@ -32,5 +44,7 @@ suite('validateSafeBinaryPath', () => {
32
44
strictEqual ( validateSafeBinaryPath ( '' ) , false ) ;
33
45
strictEqual ( validateSafeBinaryPath ( 'oxc_language' ) , false ) ;
34
46
strictEqual ( validateSafeBinaryPath ( 'language_server' ) , false ) ;
47
+ strictEqual ( validateSafeBinaryPath ( '/oxc_language_server/malicious' ) , false ) ;
48
+ strictEqual ( validateSafeBinaryPath ( 'C:\\oxc_language_server\\evil.exe' ) , false ) ;
35
49
} ) ;
36
50
} ) ;
0 commit comments