@@ -244,14 +244,12 @@ exports.setAccessibilityEventListeners = (bsConfig) => {
244244 }
245245
246246 // Build the correct glob pattern
247- const resolvedPath = path . resolve ( process . cwd ( ) , supportFilesData . supportFile ) ;
248- if ( ! resolvedPath . startsWith ( process . cwd ( ) ) ) {
249- throw new Error ( 'Path traversal attempt detected' ) ;
250- }
251- const globPattern = supportFilesData . supportFile . startsWith ( '/' )
252- ? process . cwd ( ) + supportFilesData . supportFile
253- : resolvedPath ;
254-
247+ // const globPattern = supportFilesData.supportFile.startsWith('/')
248+ // ? process.cwd() + supportFilesData.supportFile
249+ // : path.resolve(process.cwd(), supportFilesData.supportFile);
250+
251+ const globPattern = process . cwd ( ) + supportFilesData . supportFile ;
252+ console . log ( `Using glob pattern to find support files: ${ globPattern } ` ) ;
255253 glob ( globPattern , { } , ( err , files ) => {
256254 if ( err ) {
257255 logger . debug ( 'EXCEPTION IN BUILD START EVENT : Unable to parse cypress support files' ) ;
@@ -261,26 +259,31 @@ exports.setAccessibilityEventListeners = (bsConfig) => {
261259 files . forEach ( file => {
262260 try {
263261 const fileName = path . basename ( file ) ;
262+ console . log ( `Found support file: ${ file } ` ) ;
263+ console . log ( `File name: ${ fileName } ` ) ;
264264 if ( [ 'e2e.js' , 'e2e.ts' , 'component.ts' , 'component.js' ] . includes ( fileName ) && ! file . includes ( 'node_modules' ) ) {
265265
266266 const defaultFileContent = fs . readFileSync ( file , { encoding : 'utf-8' } ) ;
267267 let cypressCommandEventListener = getAccessibilityCypressCommandEventListener ( path . extname ( file ) ) ;
268-
268+ console . log ( `Cypress command event listener: ${ cypressCommandEventListener } ` ) ;
269269 if ( ! defaultFileContent . includes ( cypressCommandEventListener ) ) {
270270 let newFileContent = defaultFileContent +
271271 '\n' +
272272 cypressCommandEventListener +
273273 '\n' ;
274274 fs . writeFileSync ( file , newFileContent , { encoding : 'utf-8' } ) ;
275+ console . log ( `Updated file content for ${ file } : ${ newFileContent } ` ) ;
275276 supportFileContentMap [ file ] = supportFilesData . cleanupParams ? supportFilesData . cleanupParams : defaultFileContent ;
276277 }
277278 }
278279 } catch ( e ) {
280+ console . log ( `Error updating file content for ${ file } : ${ e } ` ) ;
279281 logger . debug ( `Unable to modify file contents for ${ file } to set event listeners with error ${ e } ` , true , e ) ;
280282 }
281283 } ) ;
282284 } ) ;
283285 } catch ( e ) {
286+ console . log ( `Error updating file content for2 ${ file } : ${ e } ` ) ;
284287 logger . debug ( `Unable to parse support files to set event listeners with error ${ e } ` , true , e ) ;
285288 }
286289}
0 commit comments