@@ -4,6 +4,14 @@ import { SquidConfig } from './types';
44describe ( 'defense-in-depth: rejects injected values' , ( ) => {
55 const defaultPort = 3128 ;
66
7+ const sslBumpBase = {
8+ domains : [ 'evil.com' ] ,
9+ port : defaultPort ,
10+ sslBump : true as const ,
11+ caFiles : { certPath : '/tmp/cert.pem' , keyPath : '/tmp/key.pem' } ,
12+ sslDbPath : '/tmp/ssl_db' ,
13+ } satisfies Partial < Parameters < typeof generateSquidConfig > [ 0 ] > ;
14+
715 it ( 'should reject newline in domain via validateDomainOrPattern' , ( ) => {
816 expect ( ( ) => {
917 generateSquidConfig ( {
@@ -18,42 +26,21 @@ describe('defense-in-depth: rejects injected values', () => {
1826 // The assertSafeForSquidConfig guard should catch this.
1927 const maliciousPattern = 'https://evil.com/path\nhttp_access allow all' ;
2028 expect ( ( ) => {
21- generateSquidConfig ( {
22- domains : [ 'evil.com' ] ,
23- port : defaultPort ,
24- sslBump : true ,
25- caFiles : { certPath : '/tmp/cert.pem' , keyPath : '/tmp/key.pem' } ,
26- sslDbPath : '/tmp/ssl_db' ,
27- urlPatterns : [ maliciousPattern ] ,
28- } ) ;
29+ generateSquidConfig ( { ...sslBumpBase , urlPatterns : [ maliciousPattern ] } ) ;
2930 } ) . toThrow ( / S E C U R I T Y / ) ;
3031 } ) ;
3132
3233 it ( 'should reject hash character in URL pattern (Squid comment injection)' , ( ) => {
3334 const maliciousPattern = 'https://evil.com/path#http_access allow all' ;
3435 expect ( ( ) => {
35- generateSquidConfig ( {
36- domains : [ 'evil.com' ] ,
37- port : defaultPort ,
38- sslBump : true ,
39- caFiles : { certPath : '/tmp/cert.pem' , keyPath : '/tmp/key.pem' } ,
40- sslDbPath : '/tmp/ssl_db' ,
41- urlPatterns : [ maliciousPattern ] ,
42- } ) ;
36+ generateSquidConfig ( { ...sslBumpBase , urlPatterns : [ maliciousPattern ] } ) ;
4337 } ) . toThrow ( / S E C U R I T Y / ) ;
4438 } ) ;
4539
4640 it ( 'should reject semicolon in URL pattern (Squid token injection)' , ( ) => {
4741 const maliciousPattern = 'https://evil.com/path;injected' ;
4842 expect ( ( ) => {
49- generateSquidConfig ( {
50- domains : [ 'evil.com' ] ,
51- port : defaultPort ,
52- sslBump : true ,
53- caFiles : { certPath : '/tmp/cert.pem' , keyPath : '/tmp/key.pem' } ,
54- sslDbPath : '/tmp/ssl_db' ,
55- urlPatterns : [ maliciousPattern ] ,
56- } ) ;
43+ generateSquidConfig ( { ...sslBumpBase , urlPatterns : [ maliciousPattern ] } ) ;
5744 } ) . toThrow ( / S E C U R I T Y / ) ;
5845 } ) ;
5946
0 commit comments