0

This is my sample code to read a file and display its contents.

    public class TestClass3 {

    public static void main(String[] args) {        
        try {
            String pathString = "E:\\myFolder\\readSource.txt"; 
            Path filePath = Paths.get(pathString);; 
            List<String> lines;
            lines = Files.readAllLines(filePath);
            System.out.println(lines);  
            
        } catch (Exception e) {         
            System.out.println("Error");    
        }   

    }
}

While scanning this code in Checkmarx tool, the tool raises an issue of "Incorrect Permission Assignment For Critical Resources" at the following line.

Path filePath = Paths.get(pathString);

I have referred here about this issue and understand that it is about creating a file with the correct permissions so that it is not misused.

  1. here, I am not creating a file, but I am just preparing its path. Is this getting reported incorrectly by Checkmarx?
  2. If not, how will I resolve this issue in Checkmarx?
Erdnase
  • 700
  • 2
  • 10
  • 25

0 Answers0