File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -205,10 +205,27 @@ function getLocalReportsPaths() {
205205 throw 'LOCAL_REPORTS_PATH env variable is not set' ;
206206 }
207207
208+ if ( ! fs . existsSync ( reportsPath ) ) {
209+ return [ ] ;
210+ }
211+
208212 return fs
209213 . readdirSync ( reportsPath , { withFileTypes : true } )
210- . filter ( d => d . isDirectory ( ) )
211- . map ( d => path . join ( reportsPath , d . name ) ) ;
214+ . filter ( dirent => {
215+ if ( ! dirent . isDirectory ( ) ) {
216+ return false ;
217+ }
218+
219+ // Validate directory name to prevent path traversal
220+ // Only allow alphanumeric, hyphens, and underscores
221+ if ( ! / ^ [ A - Z a - z 0 - 9 _ - ] + $ / . test ( dirent . name ) ) {
222+ console . warn ( `Skipping invalid directory name: ${ dirent . name } ` ) ;
223+ return false ;
224+ }
225+
226+ return true ;
227+ } )
228+ . map ( dirent => path . join ( reportsPath , dirent . name ) ) ;
212229}
213230
214231module . exports = {
You can’t perform that action at this time.
0 commit comments