@Untainted
注解标记、从注解的方法返回,或被分配给注解的字段、形参或局部变量。 不支持将字段的 Kotlin set
和 get
方法作为入口点。
(相同类中的)安全对象为:
@Untainted
的方法进行调用的结果@Untainted
且不是从非安全对象赋值的局部变量或形参分析仅在一个文件内执行。 要处理来自其他类的依赖项,请使用选项。 分析会扩展到 private 或 static 方法,并且具有深度传播限值。
示例:
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 最新变化