This commit is contained in:
yh-semmle 2018-11-01 20:29:46 -04:00
Родитель 8b866ade0e
Коммит f3fbc8a153
29 изменённых файлов: 0 добавлений и 295 удалений

Просмотреть файл

@ -1 +0,0 @@
| Test3.java:3:8:3:21 | AnnotatedClass |

Просмотреть файл

@ -1,4 +0,0 @@
import java
from GeneratedClass c
select c

Просмотреть файл

@ -1,4 +0,0 @@
class Test3 {
@javax.annotation.Generated(value = "test")
class AnnotatedClass {}
}

Просмотреть файл

@ -1,6 +0,0 @@
| 3 | 1 | annotations/C.java:3:1:3:61 | Pair | 1 |
| 3 | 14 | annotations/C.java:3:14:3:31 | Ann | 1 |
| 3 | 42 | annotations/C.java:3:42:3:60 | Ann | 1 |
| 4 | 1 | annotations/C.java:4:1:4:68 | Container | 1 |
| 4 | 25 | annotations/C.java:4:25:4:46 | Ann | 1 |
| 4 | 49 | annotations/C.java:4:49:4:65 | Ann | 1 |

Просмотреть файл

@ -1,15 +0,0 @@
/**
* @name Annotations
* @description Check that annotation ids are distinct
*/
import default
private int numberOfLocations(Annotation a) { result = count(a.getLocation()) }
from Annotation a, RefType c, Location loc
where
c.hasQualifiedName("annotations", "C") and
c.getAnAnnotation() = a.getParent*() and
loc = a.getLocation()
select loc.getStartLine(), loc.getStartColumn(), a, numberOfLocations(a)

Просмотреть файл

@ -1,43 +0,0 @@
| annotations/A.java:4:14:4:14 | A | key | annotations/A.java:3:10:3:16 | "value" |
| annotations/A.java:4:14:4:14 | A | unused1 | annotations/A.class:0:0:0:0 | {...} |
| annotations/A.java:4:14:4:14 | A | unused2 | annotations/A.class:0:0:0:0 | {...} |
| annotations/A.java:8:7:8:9 | Sub | key | annotations/A.java:3:10:3:16 | "value" |
| annotations/A.java:8:7:8:9 | Sub | unused1 | annotations/A.class:0:0:0:0 | {...} |
| annotations/A.java:8:7:8:9 | Sub | unused2 | annotations/A.class:0:0:0:0 | {...} |
| annotations/A.java:11:11:11:11 | I | key | annotations/A.java:10:10:10:15 | "IAnn" |
| annotations/A.java:11:11:11:11 | I | unused1 | annotations/I.class:0:0:0:0 | {...} |
| annotations/A.java:11:11:11:11 | I | unused2 | annotations/I.class:0:0:0:0 | {...} |
| annotations/A.java:14:7:14:10 | Sub2 | key | annotations/A.java:3:10:3:16 | "value" |
| annotations/A.java:14:7:14:10 | Sub2 | unused1 | annotations/A.class:0:0:0:0 | {...} |
| annotations/A.java:14:7:14:10 | Sub2 | unused2 | annotations/A.class:0:0:0:0 | {...} |
| annotations/A.java:18:7:18:10 | Sub3 | key | annotations/A.java:17:10:17:18 | "Sub3Ann" |
| annotations/A.java:18:7:18:10 | Sub3 | unused1 | annotations/Sub3.class:0:0:0:0 | {...} |
| annotations/A.java:18:7:18:10 | Sub3 | unused2 | annotations/Sub3.class:0:0:0:0 | {...} |
| annotations/B.java:3:42:3:42 | B | value | annotations/B.java:3:19:3:26 | "unused" |
| annotations/C.java:3:1:3:61 | Pair | key | annotations/C.java:3:25:3:30 | "Left" |
| annotations/C.java:3:1:3:61 | Pair | key | annotations/C.java:3:53:3:59 | "Right" |
| annotations/C.java:3:1:3:61 | Pair | unused1 | annotations/C.class:0:0:0:0 | {...} |
| annotations/C.java:3:1:3:61 | Pair | unused1 | annotations/C.class:0:0:0:0 | {...} |
| annotations/C.java:3:1:3:61 | Pair | unused2 | annotations/C.class:0:0:0:0 | {...} |
| annotations/C.java:3:1:3:61 | Pair | unused2 | annotations/C.class:0:0:0:0 | {...} |
| annotations/C.java:4:23:4:67 | {...} | key | annotations/C.java:4:36:4:45 | "On" + "e" |
| annotations/C.java:4:23:4:67 | {...} | key | annotations/C.java:4:60:4:64 | "Two" |
| annotations/C.java:4:23:4:67 | {...} | unused1 | annotations/C.class:0:0:0:0 | {...} |
| annotations/C.java:4:23:4:67 | {...} | unused1 | annotations/C.class:0:0:0:0 | {...} |
| annotations/C.java:4:23:4:67 | {...} | unused2 | annotations/C.class:0:0:0:0 | {...} |
| annotations/C.java:4:23:4:67 | {...} | unused2 | annotations/C.class:0:0:0:0 | {...} |
| annotations/C.java:5:14:5:14 | C | children | annotations/C.java:4:23:4:67 | {...} |
| annotations/C.java:5:14:5:14 | C | left | annotations/C.java:3:14:3:31 | Ann |
| annotations/C.java:5:14:5:14 | C | right | annotations/C.java:3:42:3:60 | Ann |
| annotations/FieldAnnotations.java:4:35:4:43 | listField | key | annotations/FieldAnnotations.java:4:11:4:17 | "value" |
| annotations/FieldAnnotations.java:4:35:4:43 | listField | unused1 | annotations/FieldAnnotations.class:0:0:0:0 | {...} |
| annotations/FieldAnnotations.java:4:35:4:43 | listField | unused2 | annotations/FieldAnnotations.class:0:0:0:0 | {...} |
| annotations/LocalVarAnnotations.java:5:3:5:41 | int unusedLocal | key | annotations/LocalVarAnnotations.java:5:12:5:18 | "value" |
| annotations/LocalVarAnnotations.java:5:3:5:41 | int unusedLocal | unused1 | annotations/LocalVarAnnotations.class:0:0:0:0 | {...} |
| annotations/LocalVarAnnotations.java:5:3:5:41 | int unusedLocal | unused2 | annotations/LocalVarAnnotations.class:0:0:0:0 | {...} |
| annotations/ParameterAnnotations.java:6:11:6:46 | listParameter | key | annotations/ParameterAnnotations.java:6:20:6:26 | "value" |
| annotations/ParameterAnnotations.java:6:11:6:46 | listParameter | unused1 | annotations/ParameterAnnotations.class:0:0:0:0 | {...} |
| annotations/ParameterAnnotations.java:6:11:6:46 | listParameter | unused2 | annotations/ParameterAnnotations.class:0:0:0:0 | {...} |
| annotations/SuppressWarningsExample.java:7:14:7:14 | g | value | annotations/SuppressWarningsExample.java:6:20:6:34 | {...} |
| annotations/SuppressWarningsExample.java:12:14:12:14 | h | value | annotations/SuppressWarningsExample.java:11:20:11:32 | "deprecation" |
| annotations/SuppressWarningsExample.java:17:14:17:14 | k | value | annotations/SuppressWarningsExample.java:16:20:16:46 | {...} |

Просмотреть файл

@ -1,9 +0,0 @@
/**
* @name GetAnnotationValue
*/
import default
from Annotatable a, string key
where a.fromSource()
select a, key, a.getAnAnnotation().getValue(key)

Просмотреть файл

@ -1,16 +0,0 @@
| annotations/A.java:4:14:4:14 | A | annotations/A.java:3:1:3:17 | Ann | annotations.Ann | key |
| annotations/A.java:4:14:4:14 | A | annotations/A.java:3:1:3:17 | Ann | annotations.Ann | unused1 |
| annotations/A.java:4:14:4:14 | A | annotations/A.java:3:1:3:17 | Ann | annotations.Ann | unused2 |
| annotations/A.java:8:7:8:9 | Sub | annotations/A.java:3:1:3:17 | Ann | annotations.Ann | key |
| annotations/A.java:8:7:8:9 | Sub | annotations/A.java:3:1:3:17 | Ann | annotations.Ann | unused1 |
| annotations/A.java:8:7:8:9 | Sub | annotations/A.java:3:1:3:17 | Ann | annotations.Ann | unused2 |
| annotations/A.java:14:7:14:10 | Sub2 | annotations/A.java:3:1:3:17 | Ann | annotations.Ann | key |
| annotations/A.java:14:7:14:10 | Sub2 | annotations/A.java:3:1:3:17 | Ann | annotations.Ann | unused1 |
| annotations/A.java:14:7:14:10 | Sub2 | annotations/A.java:3:1:3:17 | Ann | annotations.Ann | unused2 |
| annotations/A.java:18:7:18:10 | Sub3 | annotations/A.java:17:1:17:19 | Ann | annotations.Ann | key |
| annotations/A.java:18:7:18:10 | Sub3 | annotations/A.java:17:1:17:19 | Ann | annotations.Ann | unused1 |
| annotations/A.java:18:7:18:10 | Sub3 | annotations/A.java:17:1:17:19 | Ann | annotations.Ann | unused2 |
| annotations/B.java:3:42:3:42 | B | annotations/B.java:3:1:3:27 | SuppressWarnings | java.lang.SuppressWarnings | value |
| annotations/C.java:5:14:5:14 | C | annotations/C.java:3:1:3:61 | Pair | annotations.Pair | left |
| annotations/C.java:5:14:5:14 | C | annotations/C.java:3:1:3:61 | Pair | annotations.Pair | right |
| annotations/C.java:5:14:5:14 | C | annotations/C.java:4:1:4:68 | Container | annotations.Container | children |

Просмотреть файл

@ -1,13 +0,0 @@
/**
* @name GetLibraryAnnotationElement
*/
import default
from Class cl, Annotation ann, AnnotationType anntp, AnnotationElement anne
where
cl.fromSource() and
ann = cl.getAnAnnotation() and
anntp = ann.getType() and
anne = anntp.getAnAnnotationElement()
select cl, ann, anntp.getQualifiedName(), anne.getName()

Просмотреть файл

@ -1,5 +0,0 @@
| annotations/B.java:3:1:3:27 | SuppressWarnings | "unused" |
| annotations/SuppressWarningsExample.java:6:2:6:35 | SuppressWarnings | "deprecation" |
| annotations/SuppressWarningsExample.java:11:2:11:33 | SuppressWarnings | "deprecation" |
| annotations/SuppressWarningsExample.java:16:2:16:47 | SuppressWarnings | "deprecation" |
| annotations/SuppressWarningsExample.java:16:2:16:47 | SuppressWarnings | "rawtypes" |

Просмотреть файл

@ -1,4 +0,0 @@
import semmle.code.java.JDKAnnotations
from SuppressWarningsAnnotation swa
select swa, swa.getASuppressedWarning()

Просмотреть файл

@ -1,18 +0,0 @@
package annotations;
@Ann(key="value")
public class A {
}
// Sub inherits the Ann annotation from A
class Sub extends A {}
@Ann(key="IAnn")
interface I {}
// Sub2 inherits the Ann annotation from A, but not from I
class Sub2 extends Sub implements I {}
// Sub3 does not inherit any Ann annotations since it has its own
@Ann(key="Sub3Ann")
class Sub3 extends Sub2 {}

Просмотреть файл

@ -1,10 +0,0 @@
package annotations;
import java.lang.annotation.Inherited;
@Inherited
public @interface Ann {
String key();
String[] unused1() default {};
String[] unused2() default {};
}

Просмотреть файл

@ -1,4 +0,0 @@
package annotations;
@SuppressWarnings("unused") public class B {
}

Просмотреть файл

@ -1,5 +0,0 @@
package annotations;
@Pair(left = @Ann(key = "Left"), right = @Ann(key = "Right"))
@Container(children = { @Ann(key = "On" + "e"), @Ann(key = "Two") })
public class C { }

Просмотреть файл

@ -1,5 +0,0 @@
package annotations;
public @interface Container {
Ann[] children();
}

Просмотреть файл

@ -1,5 +0,0 @@
package annotations;
public class FieldAnnotations {
@Ann(key="value") java.util.List listField;
}

Просмотреть файл

@ -1,7 +0,0 @@
package annotations;
public class LocalVarAnnotations {
{
@Ann(key="value") int unusedLocal = 23;
}
}

Просмотреть файл

@ -1,6 +0,0 @@
package annotations;
public @interface Pair {
Ann left();
Ann right();
}

Просмотреть файл

@ -1,7 +0,0 @@
package annotations;
import java.util.List;
public class ParameterAnnotations {
void foo(@Ann(key="value") List listParameter) {}
}

Просмотреть файл

@ -1,20 +0,0 @@
package annotations;
public class SuppressWarningsExample {
@Deprecated void f() {}
@SuppressWarnings({"deprecation"})
public void g() {
f();
}
@SuppressWarnings("deprecation")
public void h() {
f();
}
@SuppressWarnings({"deprecation", "rawtypes"})
public void k(java.util.List l) {
f();
}
}

Просмотреть файл

@ -1,2 +0,0 @@
| Test.java:23:14:23:14 | i | Field i never assigned non-null value, yet it is read at $@. | Test.java:24:29:24:29 | i | Test.java:24 |
| Test.java:31:14:31:14 | i | Field i never assigned non-null value, yet it is read at $@. | Test.java:32:29:32:29 | i | Test.java:32 |

Просмотреть файл

@ -1,55 +0,0 @@
public class Test {
// OK: may be assigned by init() below
private int foo;
public Test() {
init();
}
private native void init();
public int getFoo() {
return foo;
}
}
class GsonTest {
@com.google.gson.annotations.Expose private String s; // OK
public String getS() { return s; }
}
class JacksonTest {
@com.fasterxml.jackson.annotation.JsonIgnore
private int i; // not OK; field is ignored for Jackson JSON deserialization
public int getI() { return i; }
{
new com.fasterxml.jackson.databind.ObjectMapper().readValue("...", JacksonTest.class);
}
}
class JacksonTest3 {
private int i; // not OK; field is never deserialized
public int getI() { return i; }
}
@com.fasterxml.jackson.annotation.JsonAutoDetect
@com.fasterxml.jackson.annotation.JsonIgnoreProperties
class JacksonTest2 {
private int i; // OK
public int getI() { return i; }
{
new com.fasterxml.jackson.databind.ObjectMapper().readValue("...", JacksonTest2.class);
}
}
class JacksonTest4 {
private int i; // OK
public int getI() { return i; }
{
Class<?> clazz = JacksonTest4.class;
readvalue(clazz);
}
public void readvalue(Class<?> clazz) {
new com.fasterxml.jackson.databind.ObjectMapper().readValue("...", clazz);
}
}

Просмотреть файл

@ -1,5 +0,0 @@
| p/JdkInternalAccess.java:1:1:1:18 | import sun.misc.* | Access to unsupported JDK-internal API 'sun.misc'. (Removed. See http://openjdk.java.net/jeps/260) |
| p/JdkInternalAccess.java:2:1:2:31 | import DirectBuffer | Access to unsupported JDK-internal API 'sun.nio.ch.DirectBuffer'. |
| p/JdkInternalAccess.java:5:2:5:7 | Unsafe | Access to unsupported JDK-internal API 'sun.misc.Unsafe'. (See http://openjdk.java.net/jeps/260) |
| p/JdkInternalAccess.java:6:2:6:14 | BASE64Encoder | Access to unsupported JDK-internal API 'sun.misc.BASE64Encoder'. (Use java.util.Base64 @since 1.8) |
| p/JdkInternalAccess.java:7:2:7:13 | DirectBuffer | Access to unsupported JDK-internal API 'sun.nio.ch.DirectBuffer'. |

Просмотреть файл

@ -1 +0,0 @@
Compatibility/JDK9/JdkInternalAccess.ql

Просмотреть файл

@ -1,5 +0,0 @@
| p/_/UnderscoreIdentifier.java:0:0:0:0 | UnderscoreIdentifier | Use of underscore as a one-character identifier in package name 'p._'. |
| p/_/UnderscoreIdentifier.java:4:8:4:8 | _ | Use of underscore as a one-character identifier. |
| p/_/UnderscoreIdentifier.java:5:6:5:6 | _ | Use of underscore as a one-character identifier. |
| p/_/UnderscoreIdentifier.java:6:12:6:16 | _ | Use of underscore as a one-character identifier. |
| p/_/UnderscoreIdentifier.java:9:3:9:12 | boolean _ | Use of underscore as a one-character identifier. |

Просмотреть файл

@ -1 +0,0 @@
Compatibility/JDK9/UnderscoreIdentifier.ql

Просмотреть файл

@ -1,8 +0,0 @@
import sun.misc.*;
import sun.nio.ch.DirectBuffer;
public class JdkInternalAccess {
Unsafe unsafe;
BASE64Encoder enc;
DirectBuffer buf;
}

Просмотреть файл

@ -1,11 +0,0 @@
package p._;
public class UnderscoreIdentifier {
class _ {}
int _;
void test(int _) {
}
{
boolean _;
}
}