Rule Definition
Built-in remote addresses cause problems when the target is moved. Avoid hardcoded network resources (e.g., IP addresses, URLs, etc.)
Remediation
Utilize indirect access to network resources using underlaying operating system calls and relative paths. In case hardcoding is necessary, isolating hardcoded data to installation scripts or configuration files can limit its potential negative impact.
Violation Code Sample
var a = '127.0.0.1' ;
//Or
let a = 'fe80:0000:0000:0000:0204:61ff:fe9d:f156/0';
Fixed Code Sample
//the url is loaded from somewhere else
var url = loadServerAddress()
Reference
ASCRM 1.0, Automated Source Code Reliability Measure, Object Management Group.
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.