Rule Definition
URI paths are not portable in different systems and hence their presence make the system non-portable. A file system or a web link may not be available for access across systems and environments.
Remediation
There should be dynamic access of URIs
Violation Code Sample
public class fileCreate {
public add<user> listUsers() {
FileStream fs = File.Create("/home/pass/myFileTest/users.txt"); // Violation
add users = parse(userList);
return users;
}
}
Fixed Code Sample
public class fileCreate {
public add<user> listUsers() {
String listingFolder = config.getProperty("myApplication.listingFolder");
FileStream fs = File.Create(listingFolder, "users.txt"); // Fix
add users = parse(userList);
return users;
}
}
Reference
https://wiki.sei.cmu.edu/confluence/display/java/MSC03-J.+Never+hard+code+sensitive+information
Related Technologies
Technical Criterion
CWE-1051 - Initialization with Hard-Coded Network Resource Configuration Data
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.