报告将非安全字符串传递给带有使用注解 org.checkerframework.checker.tainting.qual.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) {}

这里有一条警告,因为 s1foo 调用结果赋值后具有未知状态。

2021.2 最新变化