repo
stringlengths
1
191
file
stringlengths
23
351
code
stringlengths
0
5.32M
file_length
int64
0
5.32M
avg_line_length
float64
0
2.9k
max_line_length
int64
0
288k
extension_type
stringclasses
1 value
codeql
codeql-master/java/ql/test/library-tests/successors/TestTryCatch/PopulateRuntimeException.java
// make sure java.lang.RuntimeException is extracted class MyRuntimeException extends RuntimeException {}
105
52
52
java
codeql
codeql-master/java/ql/test/library-tests/successors/CloseReaderTest/CloseReaderTest.java
package successors; import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; public class CloseReaderTest { public static String readPassword(File keyFile) { // TODO: use Console.readPassword() when it's available. System.out.print("Enter password for " +...
572
21.038462
66
java
codeql
codeql-master/java/ql/test/library-tests/successors/CloseReaderTest/PopulateRuntimeException.java
// make sure java.lang.RuntimeException is extracted class MyRuntimeException extends RuntimeException {}
105
52
52
java
codeql
codeql-master/java/ql/test/library-tests/successors/TestContinue/TestContinue.java
package successors; public class TestContinue { public void f() { //loop breaks a: for (int p = 0; p < 10;) { int x = 1; x = x + 1; if (x == 1) { continue; } else { for (int q : new int[20]) { if (q == 1) { continue; } else if (q == 2) {...
684
10.416667
30
java
codeql
codeql-master/java/ql/test/library-tests/successors/TestContinue/PopulateRuntimeException.java
// make sure java.lang.RuntimeException is extracted class MyRuntimeException extends RuntimeException {}
105
52
52
java
codeql
codeql-master/java/ql/test/library-tests/successors/TestBreak/TestBreak.java
package successors; public class TestBreak { public void f() { //loop breaks a: for (;;) { int x = 1; x = x + 1; if (x == 1) { break; } else { for (int q : new int[20]) { if (q == 1) { break; } else { break a; } } }...
908
9.448276
30
java
codeql
codeql-master/java/ql/test/library-tests/successors/TestBreak/PopulateRuntimeException.java
// make sure java.lang.RuntimeException is extracted class MyRuntimeException extends RuntimeException {}
105
52
52
java
codeql
codeql-master/java/ql/test/library-tests/successors/TestThrow2/TestThrow2.java
package successors; class TestThrow2 { native void thrower() throws Throwable; { try { thrower(); } catch (Exception e) { ; } } }
145
11.166667
40
java
codeql
codeql-master/java/ql/test/library-tests/successors/TestThrow2/PopulateRuntimeException.java
// make sure java.lang.RuntimeException is extracted class MyRuntimeException extends RuntimeException {}
105
52
52
java
codeql
codeql-master/java/ql/test/library-tests/javadoc/javadoc/Test.java
package javadoc; /** A test class. */ public class Test { /** A javadoc * comment */ void f() {} /** Another javadoc comment */ // and a normal comment void g() {} /* another normal comment */ int x; int y; /** @deprecated */ void h() {} }
260
12.736842
33
java
codeql
codeql-master/java/ql/test/library-tests/controlflow/dominance/Test.java
class Test { int test(int x, int w, int z) { int j; long y = 50; // if-else, multiple statements in block if (x > 0) { y = 20; z = 10; } else { y = 30; } z = (int) (x + y); // if-else with return in one branch if (x < 0) y = 40; else return z; // this is not the start of a BB d...
1,094
10.774194
52
java
codeql
codeql-master/java/ql/test/library-tests/controlflow/dominance/Test2.java
import java.math.*; class MyExn extends Throwable {} public class Test2 { void f() throws Throwable {} void g(boolean b) throws Throwable { while (b) { if (b) { } else { try { f(); } catch (MyExn e) {} ; } } } void t(int x) { if (x < 0) { return; } while(x >= 0) { if (...
479
13.117647
64
java
codeql
codeql-master/java/ql/test/library-tests/controlflow/paths/A.java
public class A { public void action() { } public void always_dom1() { action(); } public void always_dom2(boolean b) { if (b) { } else { } action(); } public void always_path(boolean b) { if (b) { action(); } else { action(); } } public void always_w_call(boolean ...
736
13.74
54
java
codeql
codeql-master/java/ql/test/library-tests/controlflow/basic/Test.java
package dominance; public class Test { public void test() { int x = 0; long y = 50; int z = 0; int w = 0; // if-else, multiple statements in block if (x > 0) { y = 20; z = 10; } else { y = 30; } z = 0; // if-else with return in one branch if(x < 0) y = 40; else return;...
910
10.831169
52
java
codeql
codeql-master/java/ql/test/library-tests/types/A.java
public class A { boolean b = new Boolean(true); byte y = new Byte((byte)23); char c = new Character('a'); short s = new Short((short)42); int i = new Integer(56); long l = new Long(72l); double d = new Double(2.3d); float f = new Float(4.2); }
251
24.2
32
java
codeql
codeql-master/java/ql/test/library-tests/generics/generics/A.java
package generics; import java.util.HashMap; import java.util.Map; public class A<T> { class B { } } class C { A<String> f; A<String>.B b; Map<String, Object> m = new HashMap<String, Object>(); } class D<V extends Number> { D<?> d1; D<? extends Object> d2; D<? extends Float> d3; D<? super Double> d4; { jav...
347
14.818182
55
java
codeql
codeql-master/java/ql/test/library-tests/locations/locations/F.java
public class F { void m() throws RuntimeException {} }
55
17.666667
36
java
codeql
codeql-master/java/ql/test/library-tests/locations/locations/G.java
public class G { { G[] g; Object[][] o; } }
50
6.285714
16
java
codeql
codeql-master/java/ql/test/library-tests/locations/locations/B.java
package locations; // empty class, just so we have something to put into the snapshot public class B { }
107
14.428571
66
java
codeql
codeql-master/java/ql/test/library-tests/locations/locations/D.java
package locations; public class D { class Inner {} { new D().new Inner(); } }
81
10.714286
25
java
codeql
codeql-master/java/ql/test/library-tests/locations/locations/A.java
package locations; @interface TestAnnotation { public int foo(); } @TestAnnotation(foo=-42) public class A { { int x = -23; } { System.out.println("Hello, " + "world!"); } { System.out.println("Hello" + ", " + "world!"); } { String s = null; } }
253
17.142857
51
java
codeql
codeql-master/java/ql/test/library-tests/locations/locations/E.java
enum E { First, Second, Third }
34
6
8
java
codeql
codeql-master/java/ql/test/library-tests/locations/locations/C.java
package locations; import java.util.List; public class C { List<?> stuff; List<? extends Number> numbers; List<? super Double> more_numbers; }
148
13.9
35
java
codeql
codeql-master/java/ql/test/library-tests/gwt/JSNI.java
class JSNI { class Element {} // this is a JSNI comment public native void scrollTo1(Element elem) /*-{ elem.scrollIntoView(true); }-*/; // this is not a JSNI comment: method is not declared `native` public void scrollTo2(Element elem) /*-{ elem.scrollIntoView(true); }-*/ {...
957
27.176471
80
java
codeql
codeql-master/java/ql/test/library-tests/properties/Test.java
public class Test { }
22
10.5
21
java
codeql
codeql-master/java/ql/test/library-tests/RelativePaths/Test.java
class Test { public static void main(String[] args) { // Relative paths Runtime.getRuntime().exec("make"); Runtime.getRuntime().exec("m"); Runtime.getRuntime().exec(new String[] { "make" }); Runtime.getRuntime().exec("c:make"); Runtime.getRuntime().exec("make " + args[0]); // Absolute paths Runtime.ge...
634
32.421053
72
java
codeql
codeql-master/java/ql/test/library-tests/modifiers/Test.java
public class Test { enum FinalEnum { RED, GREEN, BLUE }; enum NonFinalEnum { RED() { @Override public String toString() { return "red"; } }, GREEN, BLUE }; }
166
19.875
65
java
codeql
codeql-master/java/ql/test/library-tests/overrides/ConstructedOverrides.java
public class ConstructedOverrides { { new Sub().used(""); new Super<String>().used(""); new Super<String>().usedGeneric(1, ""); } public <S> S indirectUse(S t) { return new Super<S>().usedGeneric(null, t); } } class Super<T> { public T used(T t) { return t; } public T unused(T t) { return t; } public <U> U...
783
28.037037
78
java
codeql
codeql-master/java/ql/test/library-tests/UnsafeDeserialization/Test.java
import java.io.IOException; import java.io.ObjectInputStream; import org.apache.commons.io.serialization.ValidatingObjectInputStream; class Test { public void test() throws IOException, ClassNotFoundException { ObjectInputStream objectStream = new ObjectInputStream(null); ObjectInputStream validating = new Valida...
410
30.615385
71
java
codeql
codeql-master/java/ql/test/library-tests/ssa/Test.java
class Test { int field; int f(int param) { field = 3; int x = 1; int y; int z; if (param > 2) { x++; y = ++x; z = 3; } else { y = 2; y += 4; field = 10; z = 4; } ; while (x < y) { if (param++ > 4) { break; } y -= 1; } ; for (int i = 0; i<10; i++) { x += i;...
349
9.606061
30
java
codeql
codeql-master/java/ql/test/library-tests/ssa/Fields.java
class Fields { public int[] xs; public static int[] stat; public Fields() { upd(); } public void upd() { xs = new int[1]; stat = new int[0]; } public void f() { int[] x = xs; upd(); x = xs; if (x[0] > 2) upd(); x = this.xs; xs = new int[2]; x = xs; } public ...
739
13.509804
28
java
codeql
codeql-master/java/ql/test/library-tests/ssa/Nested.java
import java.util.*; class Nested { Iterable<Integer> get1(int p1) { int x1 = 5; return () -> new Iterator() { public boolean hasNext() { return true; } public Integer next() { return p1 + x1 + x1 + x1; } }; } interface IntGetter { int getInt(); } void methodRef() { Object obj = ne...
900
19.477273
57
java
codeql
codeql-master/java/ql/test/library-tests/ssa/TestInstanceOfPattern.java
class TestInstanceOfPattern { private String s = "field"; void test(Object obj) { if (obj instanceof String s) { if (s.contains("abc")) {} } else { if (s.contains("def")) {} } } void test2(Object obj) { if (!(obj instanceof String s)) { if (s.contains("abc")) {} } else { if (s.contains("def"))...
639
19
50
java
codeql
codeql-master/java/ql/test/library-tests/guards/Test.java
class Test { private int z; void test(int x) { z = 0; if (x < 0) { throw new Exception(); } int y = 0; while(x >= 0) { if (z >= 0) y++; if (y > 10) { z++; y++; z--; } else if (y < 10) { y--; } else if (y == 10) { y++; } x--; } } void test2(int x) { int y ...
461
10.846154
29
java
codeql
codeql-master/java/ql/test/library-tests/guards/Logic.java
public class Logic { boolean g(int i) { return i < 2; } void f(int[] a, String s) { boolean b = ((g(1)) ? g(2) : true); if (b != false) { } else { } int sz = a != null ? a.length : 0; for (int i = 0; i < sz; i++) { int e = a[i]; if (e > 2) break; ...
892
16.509804
57
java
codeql
codeql-master/java/ql/test/library-tests/GeneratedFiles/Test.java
/* Warning: Generated code, any modifications to this file will be lost. */ public class Test { }
97
31.666667
75
java
codeql
codeql-master/java/ql/test/library-tests/GeneratedFiles/HasBeenGenerated.java
// =========================================================================== // This file has been generated by // Typical, version 1.13.3, // (C) 2004-2007 Robert Grimm and New York University, // on Wednesday, February 27, 2008 at 5:11:34 PM. // Edit at your own risk. // ============================================...
378
41.111111
78
java
codeql
codeql-master/java/ql/test/library-tests/GeneratedFiles/FollowingCodeGenerated.java
//---------------------------------------------------- // The following code was generated by CUP v0.10k TUM Edition 20050516 // Fri Nov 11 20:53:50 CET 2005 //---------------------------------------------------- class FollowingCodeGenerated {}
245
40
70
java
codeql
codeql-master/java/ql/test/library-tests/GeneratedFiles/Test2.java
// This file was auto generated by me public class Test2 {}
60
19.333333
37
java
codeql
codeql-master/java/ql/test/library-tests/GeneratedFiles/JavaCharStream.java
/* Generated By:JavaCC: Do not edit this line. JavaCharStream.java Version 4.1 */ /* JavaCCOptions:STATIC=false */ public class JavaCharStream { }
148
23.833333
81
java
codeql
codeql-master/java/ql/test/library-tests/GeneratedFiles/Mithra.java
/** * This file was automatically generated */ public class Mithra { }
73
11.333333
40
java
codeql
codeql-master/java/ql/test/library-tests/GeneratedFiles/StandardCharsets.java
/* * Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved. * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Fr...
1,317
40.1875
79
java
codeql
codeql-master/java/ql/test/library-tests/GeneratedFiles/JavaParserTokenManager.java
/* Generated By:JJTree&JavaCC: Do not edit this line. JavaParserTokenManager.java */ /** Token Manager. */ public class JavaParserTokenManager { }
147
28.6
84
java
codeql
codeql-master/java/ql/test/library-tests/GeneratedFiles/FacebookAutoGen.java
/** * This class is auto-genereated. [sic] * * For any issues or feature requests related to this class, please let us know * on github and we'll fix in our codegen framework. We'll not be able to accept * pull request for this class. * */ public class FacebookAutoGen {}
279
27
80
java
codeql
codeql-master/java/ql/test/library-tests/GeneratedFiles/QLParser.java
// Generated from QL.g4 by ANTLR 4.4 @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) public class QLParser { }
133
25.8
69
java
codeql
codeql-master/java/ql/test/library-tests/GeneratedFiles/test/ThriftCompiler.java
/** * Autogenerated by Thrift Compiler (0.9.3) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ package test; // The `@generated` Javadoc tag is non-standard, so we detect this // file based on the marker comment added by the Thrift Compiler. class ThriftCompiler {}
311
23
67
java
codeql
codeql-master/java/ql/test/library-tests/defUse/Test.java
package defUse; public class Test { public void ifs(long w) { int x = 0; long y = 50; use(y); use(w); if (x > 0) { y = 20; use(y); } else { y = 30; w = 10; use(w); } use(y); use(w); if(x < 0) { y = 40; w = 20; } else return; use(y); use(w); if (...
421
8.813953
43
java
codeql
codeql-master/java/ql/test/library-tests/stmts/stmts/B.java
package stmts; public class B { public void foo(boolean b, boolean c) { outer: for (int i=0; i<10; ++i) { if (b) break; if (b) continue; while (i < 20) { if (c) break; if (b && c) break outer; if (b) continue; if (c && b) continue outer; switch (i) { ca...
417
12.483871
40
java
codeql
codeql-master/java/ql/test/library-tests/stmts/stmts/A.java
package stmts; public class A { public int foo(int x) { switch(x) { case 23: return 42; case 42: return 23; default: return x; } } }
155
9.4
24
java
codeql
codeql-master/java/ql/test/library-tests/fields/fields/FieldTest.java
package fields; public class FieldTest { float ff, g = 2.3f, hhh; static Object obj = null, obj2; @SuppressWarnings("rawtypes") java.util.List l, m; }
176
21.125
58
java
codeql
codeql-master/java/ql/test/experimental/Security/CWE/CWE-327/UnsafeTlsVersion.java
import java.io.IOException; import java.security.NoSuchAlgorithmException; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLParameters; import javax.net.ssl.SSLServerSocket; import javax.net.ssl.SSLServerSocketFactory; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocke...
3,907
30.264
104
java
codeql
codeql-master/java/ql/test/experimental/Security/CWE/CWE-094/MvelInjection.java
import java.io.IOException; import java.io.InputStream; import java.io.Serializable; import java.net.Socket; import java.util.HashMap; import javax.script.CompiledScript; import javax.script.SimpleScriptContext; import org.mvel2.MVEL; import org.mvel2.MVELRuntime; import org.mvel2.ParserContext; import org.mvel2.compil...
3,975
39.161616
99
java
codeql
codeql-master/java/ql/test/experimental/Security/CWE/CWE-094/SpelInjection.java
import java.io.IOException; import java.io.InputStream; import java.net.Socket; import org.springframework.expression.Expression; import org.springframework.expression.ExpressionParser; import org.springframework.expression.spel.standard.SpelExpressionParser; import org.springframework.expression.spel.support.SimpleEva...
3,199
30.683168
96
java
codeql
codeql-master/java/ql/test/experimental/Security/CWE/CWE-299/DisabledRevocationChecking.java
import java.security.KeyStore; import java.security.cert.CertPath; import java.security.cert.CertPathValidator; import java.security.cert.PKIXCertPathChecker; import java.security.cert.PKIXParameters; import java.security.cert.PKIXRevocationChecker; import java.util.ArrayList; import java.util.Arrays; import java.util....
3,486
42.049383
126
java
codeql
codeql-master/java/ql/test/experimental/query-tests/security/CWE-917/OgnlInjection.java
import ognl.Node; import ognl.Ognl; import java.util.HashMap; import com.opensymphony.xwork2.ognl.OgnlUtil; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestMapping; @Controller public class OgnlInjec...
1,619
32.061224
85
java
codeql
codeql-master/java/ql/test/experimental/query-tests/security/CWE-522/InsecureBasicAuth.java
import org.apache.http.RequestLine; import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.message.BasicHttpRequest; import org.apache.http.message.BasicRequestLine; import java.net.URI; import java.ne...
6,734
40.067073
131
java
codeql
codeql-master/java/ql/test/experimental/query-tests/security/CWE-074/JndiInjection.java
import java.io.IOException; import java.util.Hashtable; import java.util.Properties; import javax.management.remote.JMXConnector; import javax.management.remote.JMXConnectorFactory; import javax.management.remote.JMXServiceURL; import javax.naming.CompositeName; import javax.naming.CompoundName; import javax.naming.Co...
7,828
36.280952
107
java
codeql
codeql-master/java/ql/test/experimental/query-tests/security/CWE-273/UnsafeCertTrustTest.java
import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLParameters; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; ...
4,920
29.376543
92
java
codeql
codeql-master/java/ql/test/experimental/query-tests/security/CWE-297/InsecureJavaMail.java
import java.util.Properties; import javax.mail.Authenticator; import javax.mail.PasswordAuthentication; import javax.mail.Session; import org.apache.commons.mail.DefaultAuthenticator; import org.apache.commons.mail.Email; import org.apache.commons.mail.SimpleEmail; import java.util.Properties; class InsecureJavaMai...
1,452
31.288889
89
java
codeql
codeql-master/java/ql/test/experimental/query-tests/security/CWE-016/SpringBootActuators.java
import org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointRequest; import org.springframework.security.config.annotation.web.builders.HttpSecurity; public class SpringBootActuators { protected void configure(HttpSecurity http) throws Exception { http.requestMatcher(EndpointRequest.toAnyEndpo...
4,887
45.552381
160
java
codeql
codeql-master/java/ql/test/experimental/stubs/shiro-core-1.5.2/org/apache/shiro/jndi/JndiTemplate.java
package org.apache.shiro.jndi; import javax.naming.NamingException; public class JndiTemplate { public Object lookup(final String name) throws NamingException { return new Object(); } public Object lookup(String name, Class requiredType) throws NamingException { return new Object(); } }
308
22.769231
80
java
codeql
codeql-master/java/ql/test/experimental/stubs/ognl-3.2.14/ognl/OgnlException.java
package ognl; public class OgnlException extends Exception {}
62
20
47
java
codeql
codeql-master/java/ql/test/experimental/stubs/ognl-3.2.14/ognl/Node.java
package ognl; public interface Node extends JavaSource { public Object getValue(OgnlContext context, Object source) throws OgnlException; public void setValue(OgnlContext context, Object target, Object value) throws OgnlException; }
238
33.142857
94
java
codeql
codeql-master/java/ql/test/experimental/stubs/ognl-3.2.14/ognl/OgnlContext.java
package ognl; import java.util.*; public class OgnlContext extends Object implements Map { @Override public int size() { return 0; } @Override public boolean isEmpty() { return false; } @Override public boolean containsKey(Object key) { return true; } @Override public boolea...
1,041
13.676056
56
java
codeql
codeql-master/java/ql/test/experimental/stubs/ognl-3.2.14/ognl/Ognl.java
package ognl; import java.util.*; public abstract class Ognl { public static Object parseExpression(String expression) throws OgnlException { return new Object(); } public static Object getValue(Object tree, Map context, Object root) throws OgnlException { return new Object(); } public static void...
759
27.148148
99
java
codeql
codeql-master/java/ql/test/experimental/stubs/ognl-3.2.14/ognl/JavaSource.java
package ognl; public interface JavaSource {}
46
10.75
30
java
codeql
codeql-master/java/ql/test/experimental/stubs/struts2-core-2.5.22/com/opensymphony/xwork2/ognl/OgnlUtil.java
package com.opensymphony.xwork2.ognl; import java.util.*; import ognl.OgnlException; public class OgnlUtil { public Object getValue(final String name, final Map<String, Object> context, final Object root) throws OgnlException { return new Object(); } public void setValue(final String name, final Map<String...
556
33.8125
139
java
codeql
codeql-master/java/ql/test/query-tests/definitions/Test.java
class Test implements Func { public boolean test() { return false; } public static void test2(Func func) { } { test2(this::test); } } interface Func { public boolean test(); } class Test2 { { new Test().test2(() -> { Func f = () -> false; return fal...
757
20.055556
111
java
codeql
codeql-master/java/ql/test/query-tests/Naming/NamingTest.java
import java.util.*; import java.util.function.*; import java.util.stream.*; public class NamingTest { public boolean equals(Object other) { return false; } public boolean equals(NamingTest other) { return true; } public void visit(Object node) {} public void visit(NamingTest t) {} public class Elem<T> {} publ...
495
23.8
88
java
codeql
codeql-master/java/ql/test/query-tests/Nullness/F.java
public class F { public void m1(Object obj) { if (obj == null) throwMyException(); obj.hashCode(); // OK } public void m2(Object obj) { if (obj == null) doStuff(); obj.hashCode(); // NPE } public void m3(Object obj) { if (obj == null) doStuffOrThrow(0); obj.hashCode...
778
21.257143
97
java
codeql
codeql-master/java/ql/test/query-tests/Nullness/B.java
public class B { private boolean maybe; public final boolean flag; public B(boolean b, boolean f) { this.maybe = b; this.flag = f; } public void caller() { callee1(new Object()); callee1(null); callee2(new Object()); } public void callee1(Object param) { param.toString(); // NPE ...
7,908
20.090667
69
java
codeql
codeql-master/java/ql/test/query-tests/Nullness/D.java
import java.util.*; public class D { public static List<Object> p; void init() { List<Object> l = new ArrayList<Object>(); p = l; } void f() { int n = p == null ? 0 : p.size(); for (int i = 0; i < n; i++) { Object o = p.get(i); // OK } } public static class MyList<T> extends Ar...
445
16.153846
54
java
codeql
codeql-master/java/ql/test/query-tests/Nullness/A.java
import java.util.Iterator; import java.util.List; import static org.junit.Assert.*; import static org.hamcrest.core.IsNull.*; import static org.hamcrest.MatcherAssert.*; public class A { public void notTest() { Object not_ok = null; if (!(!(!(not_ok == null)))) { not_ok.hashCode(); } Object not...
7,395
22.405063
94
java
codeql
codeql-master/java/ql/test/query-tests/Nullness/E.java
import org.junit.jupiter.api.Test; public class E { public void f(Object obj) { obj.hashCode(); } @Test public void fTest() { f(null); } public interface I { void run(); } public void runI(I i) { i.run(); } @Test public void fTest2() { runI(() -> f(null)); } }
310
10.961538
34
java
codeql
codeql-master/java/ql/test/query-tests/Nullness/ExprDeref.java
public class ExprDeref { Integer getBoxed() { return 0; } int unboxBad(boolean b) { return (b ? null : getBoxed()); // NPE } }
144
13.5
42
java
codeql
codeql-master/java/ql/test/query-tests/Nullness/C.java
import java.util.*; public class C { public void ex1(long[][][] a1, int ix, int len) { long[][] a2 = null; boolean haveA2 = ix < len && (a2 = a1[ix]) != null; long[] a3 = null; final boolean haveA3 = haveA2 && (a3 = a2[ix]) != null; // NPE - false positive if (haveA3) a3[0] = 0; // NPE - false p...
5,323
20.467742
83
java
codeql
codeql-master/java/ql/test/query-tests/BusyWait/BusyWaits.java
class BusyWaits { public void badWait() throws InterruptedException { while(this.hashCode() != 0) Thread.sleep(1); } public void badWait2() throws InterruptedException, CloneNotSupportedException { while (this.hashCode() < 3) { for (int i = 0; i < this.hashCode(); this.clone()) Thread.sleep(new Strin...
625
20.586207
81
java
codeql
codeql-master/java/ql/test/query-tests/ContinueInFalseLoop/A.java
public class A { public interface Cond { boolean cond(); } void test1(int x, Cond c) { int i; // --- do loops --- do { if (c.cond()) continue; // BAD if (c.cond()) break; } while (false); do { if (c.cond()) continue; if (c.cond()) ...
1,559
17.352941
115
java
codeql
codeql-master/java/ql/test/query-tests/maven-dependencies/another-project/src/main/java/Library.java
public class Library { public static void test() { } }
67
6.555556
29
java
codeql
codeql-master/java/ql/test/query-tests/maven-dependencies/my-project/src/main/java/Test.java
public class Test { public Test() { } }
47
5
19
java
codeql
codeql-master/java/ql/test/query-tests/DefineEqualsWhenAddingFields/I.java
interface I { boolean equals(Object o); }
42
13.333333
26
java
codeql
codeql-master/java/ql/test/query-tests/DefineEqualsWhenAddingFields/DelegateEq.java
public class DelegateEq { abstract class Super { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } return doEquals((Super)obj); } abstract boolean doEquals(Super sup); } class Sub extends ...
430
16.958333
53
java
codeql
codeql-master/java/ql/test/query-tests/DefineEqualsWhenAddingFields/B.java
class B implements I { private int f; }
40
12.666667
22
java
codeql
codeql-master/java/ql/test/query-tests/DefineEqualsWhenAddingFields/MyFragment.java
public class MyFragment extends Fragment { // OK: super class enforces reference equality private int anotherField; }
121
19.333333
47
java
codeql
codeql-master/java/ql/test/query-tests/DefineEqualsWhenAddingFields/A.java
class A { // OK: super class is Object public int f; }
56
13.25
29
java
codeql
codeql-master/java/ql/test/query-tests/DefineEqualsWhenAddingFields/RefEq.java
public class RefEq { { class Super { @Override public boolean equals(Object obj) { return super.equals(obj); } } class Sub extends Super { int i; // OK } } { class Super { @Override public boolean equals(Object obj) { return (obj==this); } } class Sub extends Super { in...
536
12.425
38
java
codeql
codeql-master/java/ql/test/query-tests/DefineEqualsWhenAddingFields/Fragment.java
public class Fragment { private int field; // Enforce reference equality @Override final public boolean equals(Object o) { return super.equals(o); } @Override public final int hashCode() { return super.hashCode(); } }
233
13.625
40
java
codeql
codeql-master/java/ql/test/query-tests/CompareIdenticalValues/A.java
class Super { int foo; } public class A extends Super { class B extends Super { { if (this.foo == this.foo) ; if (B.this.foo == this.foo) ; if (super.foo == foo) ; if (B.super.foo == foo) ; if (A.this.foo != this.foo) ; if (A.super.foo == foo) ; } } { Double d = Do...
925
19.130435
66
java
codeql
codeql-master/java/ql/test/query-tests/InconsistentOperations/Test3.java
public class Test3 { static class A { void bar() {} } static A foo() { return new A(); } void test() { { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } { A a = foo(); ...
410
21.833333
45
java
codeql
codeql-master/java/ql/test/query-tests/InconsistentOperations/Operations.java
public class Operations implements AutoCloseable { interface NoBodies { NoBodies append(String s); } interface NoBodiesSubtype extends NoBodies { NoBodies append(String s); } public Operations open() { return this; } public Operations create() { return this; } public boolean isOpen() { return true; } p...
8,665
34.662551
88
java
codeql
codeql-master/java/ql/test/query-tests/InconsistentOperations/Test2.java
public class Test2 { static class A { void bar() {} } static A foo() { return new A(); } void test() { { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } { A a = foo(); ...
410
23.176471
46
java
codeql
codeql-master/java/ql/test/query-tests/InconsistentOperations/Test6.java
public class Test6 { static class A { void bar() {} } static A foo() { return new A(); } void test() { { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } { A a = foo(); ...
416
19.85
35
java
codeql
codeql-master/java/ql/test/query-tests/InconsistentOperations/Test4.java
public class Test4 { static class A { void bar() {} } static A foo() { return new A(); } void test() { { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } { A a = foo(); ...
384
20.388889
35
java
codeql
codeql-master/java/ql/test/query-tests/InconsistentOperations/Test5.java
public class Test5 { static class A { void bar() {} } static A foo() { return new A(); } void test() { { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } { A a = foo(); a.bar(); } { A a = foo(); ...
391
20.777778
35
java
codeql
codeql-master/java/ql/test/query-tests/security/CWE-190/semmle/tests/Test.java
// Semmle test case for CWE-190: Integer Overflow or Wraparound // http://cwe.mitre.org/data/definitions/190.html package test.cwe190.semmle.tests; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; import java.security.SecureRandom; import java.util.HashMap; class Test { pu...
5,240
19.797619
123
java
codeql
codeql-master/java/ql/test/query-tests/security/CWE-190/semmle/tests/ArithmeticTainted.java
// Semmle test case for CWE-190: Integer Overflow or Wraparound // http://cwe.mitre.org/data/definitions/190.html package test.cwe190.semmle.tests; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class ArithmeticTainted { public void main(String[] args) { Buffere...
3,259
21.957746
71
java
codeql
codeql-master/java/ql/test/query-tests/security/CWE-190/semmle/tests/Test2.java
public class Test2 { // IntMultToLong void foo() { for (int k = 1; k < 10; k++) { long res = k * 1000; // OK } } }
135
14.111111
34
java
codeql
codeql-master/java/ql/test/query-tests/security/CWE-190/semmle/tests/Holder.java
// Semmle test case for CWE-190: Integer Overflow or Wraparound // http://cwe.mitre.org/data/definitions/190.html package test.cwe190.semmle.tests; public class Holder { public int dat; public Holder(int d) { dat = d; } public void setData(int d) { dat = d; } public int getData() { return dat; } }
316
14.85
63
java
codeql
codeql-master/java/ql/test/query-tests/security/CWE-676/semmle/tests/Test.java
// Semmle test case for CWE-676: Use of Potentially Dangerous Function // http://cwe.mitre.org/data/definitions/676.html package test.cwe676.semmle.tests; class Test { private Thread worker; public Test(Thread worker) { this.worker = worker; } public void quit() { // Stop worker.stop(); // BAD: Thread.sto...
356
20
70
java
codeql
codeql-master/java/ql/test/query-tests/security/CWE-681/semmle/tests/Test.java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; class Test { public static void main(String[] args) throws IOException { { long data; BufferedReader readerBuffered = new BufferedReader( new InputStreamReader(System.in, "UTF-8")); String stringNumber = read...
820
23.878788
74
java