@@ -2,7 +2,7 @@ import type { Page } from "@playwright/test";
22import * as fs from "node:fs" ;
33import * as os from "node:os" ;
44import * as path from "node:path" ;
5- import { exec } from "node:child_process" ;
5+ import { execFile } from "node:child_process" ;
66import { promisify } from "node:util" ;
77import { DetailsPage } from "../helpers/DetailsPage" ;
88import { clickAndDownload } from "./Helpers" ;
@@ -19,9 +19,12 @@ export const downloadLicenseReport = async (page: Page): Promise<string> => {
1919 . click ( ) ,
2020 ) ;
2121
22+ const sanitizedFilename = download
23+ . suggestedFilename ( )
24+ . replace ( / [ \/ \\ . ] / g, "_" ) ;
2225 const savePath = path . join (
2326 os . tmpdir ( ) ,
24- `license-report-${ Date . now ( ) } -${ download . suggestedFilename ( ) } ` ,
27+ `license-report-${ Date . now ( ) } -${ sanitizedFilename } ` ,
2528 ) ;
2629 await download . saveAs ( savePath ) ;
2730 return savePath ;
@@ -30,7 +33,7 @@ export const downloadLicenseReport = async (page: Page): Promise<string> => {
3033export const extractLicenseReport = async (
3134 downloadedFilePath : string ,
3235) : Promise < string > => {
33- const execAsync = promisify ( exec ) ;
36+ const execFileAsync = promisify ( execFile ) ;
3437 const extractionPath = path . join (
3538 path . dirname ( downloadedFilePath ) ,
3639 "extracted" ,
@@ -39,7 +42,7 @@ export const extractLicenseReport = async (
3942 fs . mkdirSync ( extractionPath ) ;
4043 }
4144
42- await execAsync ( ` tar -xzf ${ downloadedFilePath } -C ${ extractionPath } ` ) ;
45+ await execFileAsync ( " tar" , [ " -xzf" , downloadedFilePath , "-C" , extractionPath ] ) ;
4346 return extractionPath ;
4447} ;
4548
0 commit comments