1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
import org.checkerframework.checker.tainting.qual.Untainted;
class SimpleTainting {
void execute(@Untainted String s) {}
void tainted(String s) {}
void stringLiteral() {
execute("ldskjfldj");
tainted("lksjdflkjdf");
}
void stringRef(String ref) {
// :: error: (argument.type.incompatible)
execute(ref); // error
tainted(ref);
}
void untaintedRef(@Untainted String ref) {
execute(ref);
tainted(ref);
}
void concatenation(@Untainted String s1, String s2) {
execute(s1 + s1);
execute(s1 += s1);
execute(s1 + "m");
// :: error: (argument.type.incompatible)
execute(s1 + s2); // error
// :: error: (argument.type.incompatible)
execute(s2 + s1); // error
// :: error: (argument.type.incompatible)
execute(s2 + "m"); // error
// :: error: (argument.type.incompatible)
execute(s2 + s2); // error
tainted(s1 + s1);
tainted(s1 + "m");
tainted(s1 + s2);
tainted(s2 + s1);
tainted(s2 + "m");
tainted(s2 + s2);
}
}
|