我试图消除来自HP Fortify扫描的Java应用程序的误报。HP Fortify - 注释方法参数
这种方法会导致“侵犯隐私权”的问题(在PrintWriter的是一个servlet响应)
private void writeOutput(String passwordRules, PrintWriter out) {
...
out.print(passwordRules);
...
}
这是因为Fortify的如下命名约定,以决定passwordRules
包含私人数据。但我的passwordRules
不是私人数据 - 它包含“最少8个字符”等内容。
我可以通过更改变量的名称使错误消失。然而,原则上我不想为了源代码分析器的利益而损害我的代码的可读性。
我预计修复它:
private void writeOutput(@FortifyNotPassword String passwordRules, PrintWriter out) ...
但是似乎注释没有为这方面的书面:
The annotation @FortifyNotPassword is disallowed for this location.
我想:
private void writeOutput(String passwordRules, PrintWriter out) {
...
@FortifyNotPassword String rules = passwordRules;
out.print(rules);
...
}
..但这并没有消除假阳性。 (这会影响我不让代码不易读的原则)。
我也尝试了以上与@FortifyNotPrivate,具有相同的结果。
那么有什么正确的方法来做到这一点?
糟糕!错过了那一段。道歉。 –