3

Can somebody please help me know java coding solution for below Vera code canning error?

I am creating a file and passing file location as argument.

File file1=new File(filePath);
**CWE-73: External Control of File Name or Path**
swiftBoy
  • 35,607
  • 26
  • 136
  • 135
Raj Singh
  • 39
  • 2
  • 6

1 Answers1

0

You can use the:

Validator validator = ESAPI.validator();
validator.getValidDirectoryPath(..) // to validate the directory path
validator.getValidFileName(...) // to validate the file name

and then use them to create your file

Botond Botos
  • 1,202
  • 13
  • 20
Chiraz
  • 1
  • 1
  • Thank you.Now I have to validate JavaScript code to pass through Coverity scan.My javascript code is reading data from HTTP request.There are many instance of such codes that I need to validate using ESAPI.one example is request.getParameter("transactionType"); other code is var transactionType='<%=tranType%>' – Raj Singh May 02 '18 at 08:39