@@ -8,7 +8,7 @@ var fs = require('fs'),
88let app = express ( ) ;
99
1010app . get ( '/basic' , ( req , res ) => {
11- let path = req . query . path ;
11+ let path = req . query . path ; // $ Source
1212
1313 fs . readFileSync ( path ) ; // $ Alert
1414 fs . readFileSync ( './' + path ) ; // $ Alert
@@ -18,7 +18,7 @@ app.get('/basic', (req, res) => {
1818} ) ;
1919
2020app . get ( '/normalize' , ( req , res ) => {
21- let path = pathModule . normalize ( req . query . path ) ;
21+ let path = pathModule . normalize ( req . query . path ) ; // $ Source
2222
2323 fs . readFileSync ( path ) ; // $ Alert
2424 fs . readFileSync ( './' + path ) ; // $ Alert
@@ -28,7 +28,7 @@ app.get('/normalize', (req, res) => {
2828} ) ;
2929
3030app . get ( '/normalize-notAbsolute' , ( req , res ) => {
31- let path = pathModule . normalize ( req . query . path ) ;
31+ let path = pathModule . normalize ( req . query . path ) ; // $ Source
3232
3333 if ( pathModule . isAbsolute ( path ) )
3434 return ;
@@ -51,7 +51,7 @@ app.get('/normalize-notAbsolute', (req, res) => {
5151} ) ;
5252
5353app . get ( '/normalize-noInitialDotDot' , ( req , res ) => {
54- let path = pathModule . normalize ( req . query . path ) ;
54+ let path = pathModule . normalize ( req . query . path ) ; // $ Source
5555
5656 if ( path . startsWith ( ".." ) )
5757 return ;
@@ -70,7 +70,7 @@ app.get('/normalize-noInitialDotDot', (req, res) => {
7070
7171app . get ( '/prepend-normalize' , ( req , res ) => {
7272 // Coerce to relative prior to normalization
73- let path = pathModule . normalize ( './' + req . query . path ) ;
73+ let path = pathModule . normalize ( './' + req . query . path ) ; // $ Source
7474
7575 if ( ! path . startsWith ( ".." ) )
7676 fs . readFileSync ( path ) ;
@@ -79,7 +79,7 @@ app.get('/prepend-normalize', (req, res) => {
7979} ) ;
8080
8181app . get ( '/absolute' , ( req , res ) => {
82- let path = req . query . path ;
82+ let path = req . query . path ; // $ Source
8383
8484 if ( ! pathModule . isAbsolute ( path ) )
8585 return ;
@@ -91,7 +91,7 @@ app.get('/absolute', (req, res) => {
9191} ) ;
9292
9393app . get ( '/normalized-absolute' , ( req , res ) => {
94- let path = pathModule . normalize ( req . query . path ) ;
94+ let path = pathModule . normalize ( req . query . path ) ; // $ Source
9595
9696 if ( ! pathModule . isAbsolute ( path ) )
9797 return ;
@@ -114,7 +114,7 @@ app.get('/combined-check', (req, res) => {
114114} ) ;
115115
116116app . get ( '/realpath' , ( req , res ) => {
117- let path = fs . realpathSync ( req . query . path ) ;
117+ let path = fs . realpathSync ( req . query . path ) ; // $ Source
118118
119119 fs . readFileSync ( path ) ; // $ Alert
120120 fs . readFileSync ( pathModule . join ( path , 'index.html' ) ) ; // $ Alert
@@ -127,7 +127,7 @@ app.get('/realpath', (req, res) => {
127127} ) ;
128128
129129app . get ( '/coerce-relative' , ( req , res ) => {
130- let path = pathModule . join ( '.' , req . query . path ) ;
130+ let path = pathModule . join ( '.' , req . query . path ) ; // $ Source
131131
132132 if ( ! path . startsWith ( '..' ) )
133133 fs . readFileSync ( path ) ;
@@ -136,7 +136,7 @@ app.get('/coerce-relative', (req, res) => {
136136} ) ;
137137
138138app . get ( '/coerce-absolute' , ( req , res ) => {
139- let path = pathModule . join ( '/home/user/www' , req . query . path ) ;
139+ let path = pathModule . join ( '/home/user/www' , req . query . path ) ; // $ Source
140140
141141 if ( path . startsWith ( '/home/user/www' ) )
142142 fs . readFileSync ( path ) ;
@@ -145,7 +145,7 @@ app.get('/coerce-absolute', (req, res) => {
145145} ) ;
146146
147147app . get ( '/concat-after-normalization' , ( req , res ) => {
148- let path = 'foo/' + pathModule . normalize ( req . query . path ) ;
148+ let path = 'foo/' + pathModule . normalize ( req . query . path ) ; // $ Source
149149
150150 if ( ! path . startsWith ( '..' ) )
151151 fs . readFileSync ( path ) ; // $ Alert - prefixing foo/ invalidates check
@@ -157,7 +157,7 @@ app.get('/concat-after-normalization', (req, res) => {
157157} ) ;
158158
159159app . get ( '/noDotDot' , ( req , res ) => {
160- let path = pathModule . normalize ( req . query . path ) ;
160+ let path = pathModule . normalize ( req . query . path ) ; // $ Source
161161
162162 if ( path . includes ( '..' ) )
163163 return ;
@@ -171,7 +171,7 @@ app.get('/noDotDot', (req, res) => {
171171} ) ;
172172
173173app . get ( '/join-regression' , ( req , res ) => {
174- let path = req . query . path ;
174+ let path = req . query . path ; // $ Source
175175
176176 // Regression test for a specific corner case:
177177 // Some guard nodes sanitize both branches, but for a different set of flow labels.
@@ -211,7 +211,7 @@ app.get('/join-regression', (req, res) => {
211211} ) ;
212212
213213app . get ( '/decode-after-normalization' , ( req , res ) => {
214- let path = pathModule . normalize ( req . query . path ) ;
214+ let path = pathModule . normalize ( req . query . path ) ; // $ Source
215215
216216 if ( ! pathModule . isAbsolute ( path ) && ! path . startsWith ( '..' ) )
217217 fs . readFileSync ( path ) ;
@@ -223,7 +223,7 @@ app.get('/decode-after-normalization', (req, res) => {
223223} ) ;
224224
225225app . get ( '/replace' , ( req , res ) => {
226- let path = pathModule . normalize ( req . query . path ) . replace ( / % 2 0 / g, ' ' ) ;
226+ let path = pathModule . normalize ( req . query . path ) . replace ( / % 2 0 / g, ' ' ) ; // $ Source
227227 if ( ! pathModule . isAbsolute ( path ) ) {
228228 fs . readFileSync ( path ) ; // $ Alert
229229
@@ -233,7 +233,7 @@ app.get('/replace', (req, res) => {
233233} ) ;
234234
235235app . get ( '/resolve-path' , ( req , res ) => {
236- let path = pathModule . resolve ( req . query . path ) ;
236+ let path = pathModule . resolve ( req . query . path ) ; // $ Source
237237
238238 fs . readFileSync ( path ) ; // $ Alert
239239
@@ -251,7 +251,7 @@ app.get('/resolve-path', (req, res) => {
251251} ) ;
252252
253253app . get ( '/relative-startswith' , ( req , res ) => {
254- let path = pathModule . resolve ( req . query . path ) ;
254+ let path = pathModule . resolve ( req . query . path ) ; // $ Source
255255
256256 fs . readFileSync ( path ) ; // $ Alert
257257
@@ -300,7 +300,7 @@ app.get('/relative-startswith', (req, res) => {
300300var isPathInside = require ( "is-path-inside" ) ,
301301 pathIsInside = require ( "path-is-inside" ) ;
302302app . get ( '/pseudo-normalizations' , ( req , res ) => {
303- let path = req . query . path ;
303+ let path = req . query . path ; // $ Source
304304 fs . readFileSync ( path ) ; // $ Alert
305305 if ( isPathInside ( path , SAFE ) ) {
306306 fs . readFileSync ( path ) ;
@@ -336,7 +336,7 @@ app.get('/pseudo-normalizations', (req, res) => {
336336} ) ;
337337
338338app . get ( '/yet-another-prefix' , ( req , res ) => {
339- let path = pathModule . resolve ( req . query . path ) ;
339+ let path = pathModule . resolve ( req . query . path ) ; // $ Source
340340
341341 fs . readFileSync ( path ) ; // $ Alert
342342
@@ -351,7 +351,7 @@ app.get('/yet-another-prefix', (req, res) => {
351351
352352var rootPath = process . cwd ( ) ;
353353app . get ( '/yet-another-prefix2' , ( req , res ) => {
354- let path = req . query . path ;
354+ let path = req . query . path ; // $ Source
355355
356356 fs . readFileSync ( path ) ; // $ Alert
357357
@@ -374,15 +374,15 @@ app.get('/yet-another-prefix2', (req, res) => {
374374
375375import slash from 'slash' ;
376376app . get ( '/slash-stuff' , ( req , res ) => {
377- let path = req . query . path ;
377+ let path = req . query . path ; // $ Source
378378
379379 fs . readFileSync ( path ) ; // $ Alert
380380
381381 fs . readFileSync ( slash ( path ) ) ; // $ Alert
382382} ) ;
383383
384384app . get ( '/dotdot-regexp' , ( req , res ) => {
385- let path = pathModule . normalize ( req . query . x ) ;
385+ let path = pathModule . normalize ( req . query . x ) ; // $ Source
386386 if ( pathModule . isAbsolute ( path ) )
387387 return ;
388388 fs . readFileSync ( path ) ; // $ Alert
@@ -404,12 +404,12 @@ app.get('/dotdot-regexp', (req, res) => {
404404} ) ;
405405
406406app . get ( '/join-spread' , ( req , res ) => {
407- fs . readFileSync ( pathModule . join ( 'foo' , ...req . query . x . split ( '/' ) ) ) ; // $ Alert
408- fs . readFileSync ( pathModule . join ( ...req . query . x . split ( '/' ) ) ) ; // $ Alert
407+ fs . readFileSync ( pathModule . join ( 'foo' , ...req . query . x . split ( '/' ) ) ) ; // $ Alert Source
408+ fs . readFileSync ( pathModule . join ( ...req . query . x . split ( '/' ) ) ) ; // $ Alert Source
409409} ) ;
410410
411411app . get ( '/dotdot-matchAll-regexp' , ( req , res ) => {
412- let path = pathModule . normalize ( req . query . x ) ;
412+ let path = pathModule . normalize ( req . query . x ) ; // $ Source
413413 if ( pathModule . isAbsolute ( path ) )
414414 return ;
415415 fs . readFileSync ( path ) ; // $ Alert
0 commit comments