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.
- here, I am not creating a file, but I am just preparing its path. Is this getting reported incorrectly by Checkmarx?
- If not, how will I resolve this issue in Checkmarx?
