org.checkerframework.checker.tainting.qual.Untainted
标记的形参的方法的情况。
安全字符串为:
@Untainted
的方法调用@Untainted
且没有分配非安全方法调用的字段、局部变量或形参示例:
void doSmth(boolean b) {
String s = safe();
String s1 = "other";
if (b) s1 = s;
sink(s);
}
String sink(@Untainted String s) {}
此处没有将非安全字符串赋值给 s
,因此没有产生警告。 另一方面:
void doSmth(boolean b) {
String s = safe();
String s1 = "other";
s1 = foo();
if (b) s = s1;
sink(s); // 此处为警告
}
String foo();
String sink(@Untainted String s) {}
这里有一条警告,因为 s1
在 foo
调用结果赋值后具有未知状态。
2021.2 最新变化