File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
javascript/ql/test/experimental/Security/CWE-918 Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ app.get('/check-with-axios', req => {
2525 } else {
2626 axios . get ( baseURL + req . params . tainted ) ; // OK
2727 }
28-
28+
2929 // Blacklists are not safe
3030 if ( ! req . query . tainted . match ( / ^ [ / \. % ] + $ / ) ) {
3131 axios . get ( "test.com/" + req . query . tainted ) ; // SSRF
@@ -39,6 +39,13 @@ app.get('/check-with-axios', req => {
3939 }
4040
4141 axios . get ( "test.com/" + req . query . tainted ) ; // OK - False Positive
42+
43+ if ( req . query . tainted . matchAll ( / ^ [ 0 - 9 a - z ] + $ / g) ) { // letters and numbers
44+ axios . get ( "test.com/" + req . query . tainted ) ; // OK
45+ }
46+ if ( req . query . tainted . matchAll ( / ^ [ 0 - 9 a - z \- _ ] + $ / g) ) { // letters, numbers, - and _
47+ axios . get ( "test.com/" + req . query . tainted ) ; // OK
48+ }
4249} ) ;
4350
4451const isValidPath = path => path . match ( / ^ [ 0 - 9 a - z ] + $ / ) ;
You can’t perform that action at this time.
0 commit comments