Filtering using FortifyRemove comments
Similar to linters, compilers, and static analysis tools built directly into IDEs, developers are accustomed to controlling the results of these tools directly from the code. Similarly if required, developers can use inline comments to manage issues triggered by OpenText SAST. Developers can prevent issues from being reported by specifying either the rule ID that triggers the issue or the category of the finding in the FortifyRemove().
When issues are removed with comments, OpenText SAST logs the issues that are removed, including their location and category.
fortify-rules.properties by setting com.fortify.sca.rules.EnableRuleComments=false. For more information, see fortify-rules.propertiesBasic Comments
For example, consider the following Java Hello World application.
public class MyClass {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
Consider there is a rule with an ID 625EEE1F-464F-42DC-85D6-269A637EF747 that triggers on the main function as J2EE Bad Practices: Leftover Debug Code.
If the developer disagrees and they do not want this issue to display any longer, either of the following configurations will prevent the issue from appearing.
public class MyClass {
// FortifyRemove(ID="625EEE1F-464F-42DC-85D6-269A637EF747")
public static void main(String[] args) {
System.out.println("Hello World");
}
}
Or
public class MyClass {
// FortifyRemove(Category="J2EE Bad Practices: Leftover Debug Code")
public static void main(String[] args) {
System.out.println("Hello World");
}
}
Wildcards
* wildcard can be used to expand a category to cover multiple subcategories or multiple matching categories.// FortifyRemove(Category="Cross-Site Scripting: *")
// FortifyRemove(Category="Cross-Site *")
Multiple conditions
Categories or IDs properties respectively, which take arrays of strings.// FortifyRemove(Categories=["Cross-Site Scripting: Reflected", "Cross-Site Scripting: Persistent"])
Cross-Site Scripting: Reflected or Cross-Site Scripting: Persistent issues appearing on the following line. // FortifyRemove(IDs=["A", "B", "C", "D"]
A, B, C, or D from triggering on the following line. ; ).// FortifyRemove(Category="SQL Injection"; ID="ABCD-1234")
SQL Injection issues appearing on the following line, as well as prevent issues from rule ID ABCD-1234 triggering.Adding Justifications
FortifyRemove comments. A justification property can be specified that accepts a string that will be logged alongside the removal information that can help expand on why the issue is being removed.// FortifyRemove(Category="Cross-Site Scripting: *"; Justification="We remove XSS here because we're using custom framework XYZ that automatically protects against the attack")