mirror of
https://github.com/github/codeql.git
synced 2026-05-05 21:55:19 +02:00
Java: Added new query java/visible-for-testing-abuse
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package packagetwo;
|
||||
|
||||
import packageone.*;
|
||||
|
||||
public class Annotated {
|
||||
@VisibleForTesting
|
||||
static String m;
|
||||
@VisibleForTesting
|
||||
static protected String m1;
|
||||
|
||||
@VisibleForTesting
|
||||
static int f() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package packagetwo;
|
||||
|
||||
import packageone.*;
|
||||
|
||||
public class Source {
|
||||
void f() {
|
||||
int i = Annotated.f(); // NON_COMPLIANT
|
||||
String s = Annotated.m; // NON_COMPLIANT
|
||||
AnnotatedClass a = new AnnotatedClass(); // NON_COMPLIANT
|
||||
String s1 = Annotated.m1; // COMPLIANT - same package
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package packagetwo;
|
||||
|
||||
import packageone.*;
|
||||
|
||||
public class Test {
|
||||
void f() {
|
||||
int i = Annotated.f(); // COMPLIANT
|
||||
String s = Annotated.m; // COMPLIANT
|
||||
AnnotatedClass a = new AnnotatedClass(); // COMPLIANT
|
||||
String s1 = Annotated.m1; // COMPLIANT
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user