code
stringlengths 14
2.05k
| label
int64 0
1
| programming_language
stringclasses 7
values | cwe_id
stringlengths 6
14
| cwe_name
stringlengths 5
98
⌀ | description
stringlengths 36
379
⌀ | url
stringlengths 36
48
⌀ | label_name
stringclasses 2
values |
---|---|---|---|---|---|---|---|
public static LicenseInfo retrieveDistributor() {
final InputStream dis = PSystemVersion.class.getResourceAsStream("/distributor.txt");
if (dis == null)
return null;
try {
final BufferedReader br = new BufferedReader(new InputStreamReader(dis));
final String licenseString = br.readLine();
br.close();
final LicenseInfo result = PLSSignature.retrieveDistributor(licenseString);
final Throwable creationPoint = new Throwable();
creationPoint.fillInStackTrace();
for (StackTraceElement ste : creationPoint.getStackTrace())
if (ste.toString().contains(result.context))
return result;
return null;
} catch (Exception e) {
Logme.error(e);
return null;
}
} | 1 | Java | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | safe |
private static LicenseInfo setIfValid(LicenseInfo value, LicenseInfo def) {
if (value.isValid() || def.isNone())
return value;
return def;
} | 1 | Java | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | safe |
public AFile getAFile(String nameOrPath) throws IOException {
// Log.info("ImportedFiles::getAFile nameOrPath = " + nameOrPath);
// Log.info("ImportedFiles::getAFile currentDir = " + currentDir);
final AParentFolder dir = currentDir;
if (dir == null || isAbsolute(nameOrPath))
return new AFileRegular(new SFile(nameOrPath).getCanonicalFile());
// final File filecurrent = SecurityUtils.File(dir.getAbsoluteFile(),
// nameOrPath);
final AFile filecurrent = dir.getAFile(nameOrPath);
Log.info("ImportedFiles::getAFile filecurrent = " + filecurrent);
if (filecurrent != null && filecurrent.isOk())
return filecurrent;
for (SFile d : getPath()) {
if (d.isDirectory()) {
final SFile file = d.file(nameOrPath);
if (file.exists())
return new AFileRegular(file.getCanonicalFile());
} else if (d.isFile()) {
final AFileZipEntry zipEntry = new AFileZipEntry(d, nameOrPath);
if (zipEntry.isOk())
return zipEntry;
}
}
return filecurrent;
} | 1 | Java | CWE-284 | Improper Access Control | The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor. | https://cwe.mitre.org/data/definitions/284.html | safe |
public ImportedFiles withCurrentDir(AParentFolder newCurrentDir) {
if (newCurrentDir == null)
return this;
return new ImportedFiles(imported, newCurrentDir);
} | 1 | Java | CWE-284 | Improper Access Control | The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor. | https://cwe.mitre.org/data/definitions/284.html | safe |
public FileWithSuffix getFile(String filename, String suffix) throws IOException {
final int idx = filename.indexOf('~');
final AFile file;
final String entry;
if (idx == -1) {
file = getAFile(filename);
entry = null;
} else {
file = getAFile(filename.substring(0, idx));
entry = filename.substring(idx + 1);
}
// if (isAllowed(file) == false)
if (file == null || file.getUnderlyingFile().isFileOk() == false)
return FileWithSuffix.none();
return new FileWithSuffix(filename, suffix, file, entry);
} | 1 | Java | CWE-284 | Improper Access Control | The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor. | https://cwe.mitre.org/data/definitions/284.html | safe |
public boolean isFileOk() {
// ::comment when __CORE__
if (SecurityUtils.getSecurityProfile() == SecurityProfile.SANDBOX)
// In SANDBOX, we cannot read any files
return false;
// In any case SFile should not access the security folders
// (the files must be handled internally)
try {
if (isDenied())
return false;
} catch (IOException e) {
return false;
}
// Files in "plantuml.include.path" and "plantuml.allowlist.path" are ok.
if (isInAllowList(SecurityUtils.getPath(SecurityUtils.PATHS_INCLUDES)))
return true;
if (isInAllowList(SecurityUtils.getPath(SecurityUtils.ALLOWLIST_LOCAL_PATHS)))
return true;
if (SecurityUtils.getSecurityProfile() == SecurityProfile.INTERNET)
return false;
if (SecurityUtils.getSecurityProfile() == SecurityProfile.ALLOWLIST)
return false;
if (SecurityUtils.getSecurityProfile() != SecurityProfile.UNSECURE) {
// For UNSECURE, we did not do those checks
final String path = getCleanPathSecure();
if (path.startsWith("/etc/") || path.startsWith("/dev/") || path.startsWith("/boot/")
|| path.startsWith("/proc/") || path.startsWith("/sys/"))
return false;
if (path.startsWith("//"))
return false;
}
// ::done
return true;
} | 1 | Java | CWE-284 | Improper Access Control | The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor. | https://cwe.mitre.org/data/definitions/284.html | safe |
public static SFile fromFile(File internal) {
if (internal == null)
return null;
return new SFile(internal);
} | 1 | Java | CWE-284 | Improper Access Control | The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor. | https://cwe.mitre.org/data/definitions/284.html | safe |
public boolean isUrlOk() {
// ::comment when __CORE__
if (SecurityUtils.getSecurityProfile() == SecurityProfile.SANDBOX)
// In SANDBOX, we cannot read any URL
return false;
if (SecurityUtils.getSecurityProfile() == SecurityProfile.LEGACY)
return true;
if (SecurityUtils.getSecurityProfile() == SecurityProfile.UNSECURE)
// We are UNSECURE anyway
return true;
if (isInUrlAllowList())
// ::done
return true;
// ::comment when __CORE__
if (SecurityUtils.getSecurityProfile() == SecurityProfile.INTERNET) {
if (forbiddenURL(cleanPath(internal.toString())))
return false;
final int port = internal.getPort();
// Using INTERNET profile, port 80 and 443 are ok
return port == 80 || port == 443 || port == -1;
}
return false;
// ::done
} | 1 | Java | CWE-284 | Improper Access Control | The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor. | https://cwe.mitre.org/data/definitions/284.html | safe |
public boolean canWeReadThisEnvironmentVariable(String name) {
if (name == null)
return false;
if (this == UNSECURE)
return true;
if (name.toLowerCase().startsWith("plantuml"))
return true;
return true;
} | 1 | Java | CWE-284 | Improper Access Control | The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor. | https://cwe.mitre.org/data/definitions/284.html | safe |
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
// ::comment when __CORE__
final String path = values.get(0).toString();
return TValue.fromBoolean(new SFile(path).exists());
// ::done
// ::uncomment when __CORE__
// return TValue.fromBoolean(false);
// ::done
} | 1 | Java | CWE-284 | Improper Access Control | The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor. | https://cwe.mitre.org/data/definitions/284.html | safe |
private String getenv(String name) {
// Check, if the script requests secret information.
// A plantuml server should have an own SecurityManager to
// avoid access to properties and environment variables, but we should
// also stop here in other deployments.
if (SecurityUtils.getSecurityProfile().canWeReadThisEnvironmentVariable(name) == false)
return null;
final String env = System.getProperty(name);
if (env != null)
return env;
return System.getenv(name);
} | 1 | Java | CWE-284 | Improper Access Control | The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor. | https://cwe.mitre.org/data/definitions/284.html | safe |
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
// ::comment when __CORE__
final String value = getenv(values.get(0).toString());
if (value == null)
return TValue.fromString("");
return TValue.fromString(value);
// ::done
// ::uncomment when __CORE__
// return TValue.fromString("");
// ::done
} | 1 | Java | CWE-284 | Improper Access Control | The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor. | https://cwe.mitre.org/data/definitions/284.html | safe |
private String loadStringData(String path, String charset) throws EaterException, UnsupportedEncodingException {
byte[] byteData = null;
if (path.startsWith("http://") || path.startsWith("https://")) {
final SURL url = SURL.create(path);
if (url != null)
byteData = url.getBytes();
// ::comment when __CORE__
} else {
try {
final SFile file = FileSystem.getInstance().getFile(path);
if (file != null && file.exists() && file.canRead() && !file.isDirectory()) {
final ByteArrayOutputStream out = new ByteArrayOutputStream(1024 * 8);
FileUtils.copyToStream(file, out);
byteData = out.toByteArray();
}
} catch (IOException e) {
Logme.error(e);
}
// ::done
}
if (byteData == null || byteData.length == 0)
return null; // no length, no data (we want the default)
return new String(byteData, charset);
} | 1 | Java | CWE-284 | Improper Access Control | The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor. | https://cwe.mitre.org/data/definitions/284.html | safe |
public static synchronized LicenseInfo retrieveNamedSlow() {
cache = LicenseInfo.NONE;
// if (OptionFlags.ALLOW_INCLUDE == false)
// return cache;
final String key = prefs.get("license", "");
if (key.length() > 0) {
cache = setIfValid(retrieveNamed(key), cache);
if (cache.isValid())
return cache;
}
for (SFile f : fileCandidates()) {
try {
if (f.exists() && f.canRead()) {
final LicenseInfo result = retrieve(f);
if (result == null)
return null;
cache = setIfValid(result, cache);
if (cache.isValid())
return cache;
}
} catch (IOException e) {
Log.info("Error " + e);
// Logme.error(e);
}
}
return cache;
} | 1 | Java | CWE-284 | Improper Access Control | The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor. | https://cwe.mitre.org/data/definitions/284.html | safe |
public static PSystemVersion createShowVersion2(UmlSource source) {
final List<String> strings = new ArrayList<>();
strings.add("<b>PlantUML version " + Version.versionString() + "</b> (" + Version.compileTimeString() + ")");
strings.add("(" + License.getCurrent() + " source distribution)");
// :: uncomment when __CORE__
// strings.add(" ");
// strings.add("Compiled with CheerpJ 2.3");
// strings.add("Powered by CheerpJ, a Leaning Technologies Java tool");
// :: done
// :: comment when __CORE__
GraphvizCrash.checkOldVersionWarning(strings);
if (SecurityUtils.getSecurityProfile() == SecurityProfile.UNSECURE) {
strings.add("Loaded from " + Version.getJarPath());
if (OptionFlags.getInstance().isWord()) {
strings.add("Word Mode");
strings.add("Command Line: " + Run.getCommandLine());
strings.add("Current Dir: " + new SFile(".").getAbsolutePath());
strings.add("plantuml.include.path: " + PreprocessorUtils.getenv(SecurityUtils.PATHS_INCLUDES));
}
}
strings.add(" ");
GraphvizUtils.addDotStatus(strings, true);
strings.add(" ");
for (String name : OptionPrint.interestingProperties())
strings.add(name);
for (String v : OptionPrint.interestingValues())
strings.add(v);
// ::done
return new PSystemVersion(source, true, strings);
} | 1 | Java | CWE-284 | Improper Access Control | The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor. | https://cwe.mitre.org/data/definitions/284.html | safe |
public static byte[] shuffle(double[] input) throws IOException {
if (input.length * 8 < input.length) {
throw new SnappyError(SnappyErrorCode.TOO_LARGE_INPUT, "input array size is too large: " + input.length);
}
byte[] output = new byte[input.length * 8];
int numProcessed = impl.shuffle(input, 0, 8, input.length * 8, output, 0);
assert(numProcessed == input.length * 8);
return output;
} | 1 | Java | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
public static byte[] shuffle(float[] input) throws IOException {
if (input.length * 4 < input.length) {
throw new SnappyError(SnappyErrorCode.TOO_LARGE_INPUT, "input array size is too large: " + input.length);
}
byte[] output = new byte[input.length * 4];
int numProcessed = impl.shuffle(input, 0, 4, input.length * 4, output, 0);
assert(numProcessed == input.length * 4);
return output;
} | 1 | Java | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
public static byte[] shuffle(int[] input) throws IOException {
if (input.length * 4 < input.length) {
throw new SnappyError(SnappyErrorCode.TOO_LARGE_INPUT, "input array size is too large: " + input.length);
}
byte[] output = new byte[input.length * 4];
int numProcessed = impl.shuffle(input, 0, 4, input.length * 4, output, 0);
assert(numProcessed == input.length * 4);
return output;
} | 1 | Java | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
public static byte[] shuffle(long[] input) throws IOException {
if (input.length * 8 < input.length) {
throw new SnappyError(SnappyErrorCode.TOO_LARGE_INPUT, "input array size is too large: " + input.length);
}
byte[] output = new byte[input.length * 8];
int numProcessed = impl.shuffle(input, 0, 8, input.length * 8, output, 0);
assert(numProcessed == input.length * 8);
return output;
} | 1 | Java | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
public static byte[] shuffle(short[] input) throws IOException {
if (input.length * 2 < input.length) {
throw new SnappyError(SnappyErrorCode.TOO_LARGE_INPUT, "input array size is too large: " + input.length);
}
byte[] output = new byte[input.length * 2];
int numProcessed = impl.shuffle(input, 0, 2, input.length * 2, output, 0);
assert(numProcessed == input.length * 2);
return output;
} | 1 | Java | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
public void isTooLargeIntArrayInputLengthForBitShuffleShuffle() throws Exception {
BitShuffle.shuffle(new float[Integer.MAX_VALUE / 4 + 1]);
} | 1 | Java | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
public void isValidArrayInputLengthForBitShuffleShuffle()
throws Exception
{
byte[] b = BitShuffle.shuffle(new double[0]);
byte[] c = BitShuffle.shuffle(new float[0]);
byte[] d = BitShuffle.shuffle(new int[0]);
byte[] e = BitShuffle.shuffle(new long[0]);
byte[] f = BitShuffle.shuffle(new short[0]);
byte[] n = BitShuffle.shuffle(new double[10]);
byte[] o = BitShuffle.shuffle(new float[10]);
byte[] p = BitShuffle.shuffle(new int[10]);
byte[] q = BitShuffle.shuffle(new long[10]);
byte[] r = BitShuffle.shuffle(new short[10]);
} | 1 | Java | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
public void isTooLargeDoubleArrayInputLengthForBitShuffleShuffle() throws Exception {
BitShuffle.shuffle(new double[Integer.MAX_VALUE / 8 + 1]);
} | 1 | Java | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
public void isTooLargeLongArrayInputLengthForBitShuffleShuffle() throws Exception {
BitShuffle.shuffle(new long[Integer.MAX_VALUE / 8 + 1]);
} | 1 | Java | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
public void isTooLargeFloatArrayInputLengthForBitShuffleShuffle() throws Exception {
BitShuffle.shuffle(new float[Integer.MAX_VALUE / 4 + 1]);
} | 1 | Java | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
public void isTooLargeShortArrayInputLengthForBitShuffleShuffle() throws Exception {
BitShuffle.shuffle(new short[Integer.MAX_VALUE / 2 + 1]);
} | 1 | Java | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
public void isTooLargeShortArrayInputLengthForBitShuffleShuffle() throws Exception {
BitShuffle.shuffle(new short[Integer.MAX_VALUE / 2 + 1]);
} | 1 | Java | CWE-770 | Allocation of Resources Without Limits or Throttling | The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor. | https://cwe.mitre.org/data/definitions/770.html | safe |
public void isValidChunkLengthForSnappyInputStreamIn()
throws Exception {
byte[] data = {0};
SnappyInputStream in = new SnappyInputStream(new ByteArrayInputStream(data));
byte[] out = new byte[50];
in.read(out);
} | 1 | Java | CWE-770 | Allocation of Resources Without Limits or Throttling | The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor. | https://cwe.mitre.org/data/definitions/770.html | safe |
public void isInvalidChunkLengthForSnappyInputStreamInNegative()
throws Exception {
byte[] data = {-126, 'S', 'N', 'A', 'P', 'P', 'Y', 0, 0, 0, 0, 0, 0, 0, 0, 0,(byte) 0x7f, (byte) 0xff, (byte) 0xff, (byte) 0xff};
SnappyInputStream in = new SnappyInputStream(new ByteArrayInputStream(data));
byte[] out = new byte[50];
in.read(out);
} | 1 | Java | CWE-770 | Allocation of Resources Without Limits or Throttling | The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor. | https://cwe.mitre.org/data/definitions/770.html | safe |
public void isInvalidChunkLengthForSnappyInputStreamOutOfMemory()
throws Exception {
byte[] data = {-126, 'S', 'N', 'A', 'P', 'P', 'Y', 0, 0, 0, 0, 0, 0, 0, 0, 0, (byte) 0x7f, (byte) 0xff, (byte) 0xff, (byte) 0xff};
SnappyInputStream in = new SnappyInputStream(new ByteArrayInputStream(data));
byte[] out = new byte[50];
try {
in.read(out);
} catch (Exception ignored) {
// Exception here will be catched
// But OutOfMemoryError will not be caught, and will still be thrown
}
} | 1 | Java | CWE-770 | Allocation of Resources Without Limits or Throttling | The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor. | https://cwe.mitre.org/data/definitions/770.html | safe |
public static byte[] compress(int[] input)
throws IOException
{
int byteSize = input.length * 4;
if (byteSize < input.length) {
throw new SnappyError(SnappyErrorCode.TOO_LARGE_INPUT, "input array size is too large: " + input.length);
}
return rawCompress(input, byteSize); // int uses 4 bytes
} | 1 | Java | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
public static byte[] compress(double[] input)
throws IOException
{
int byteSize = input.length * 8;
if (byteSize < input.length) {
throw new SnappyError(SnappyErrorCode.TOO_LARGE_INPUT, "input array size is too large: " + input.length);
}
return rawCompress(input, byteSize); // double uses 8 bytes
} | 1 | Java | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
public static byte[] compress(float[] input)
throws IOException
{
int byteSize = input.length * 4;
if (byteSize < input.length) {
throw new SnappyError(SnappyErrorCode.TOO_LARGE_INPUT, "input array size is too large: " + input.length);
}
return rawCompress(input, byteSize); // float uses 4 bytes
} | 1 | Java | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
public static byte[] compress(short[] input)
throws IOException
{
int byteSize = input.length * 2;
if (byteSize < input.length) {
throw new SnappyError(SnappyErrorCode.TOO_LARGE_INPUT, "input array size is too large: " + input.length);
}
return rawCompress(input, byteSize); // short uses 2 bytes
} | 1 | Java | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
public static byte[] compress(char[] input)
throws IOException
{
int byteSize = input.length * 2;
if (byteSize < input.length) {
throw new SnappyError(SnappyErrorCode.TOO_LARGE_INPUT, "input array size is too large: " + input.length);
}
return rawCompress(input, byteSize); // char uses 2 bytes
} | 1 | Java | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
public static byte[] compress(long[] input)
throws IOException
{
int byteSize = input.length * 8;
if (byteSize < input.length) {
throw new SnappyError(SnappyErrorCode.TOO_LARGE_INPUT, "input array size is too large: " + input.length);
}
return rawCompress(input, byteSize); // long uses 8 bytes
} | 1 | Java | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
public void isTooLargeShortArrayInputLengthForBitShuffleShuffle() throws Exception {
BitShuffle.shuffle(new short[Integer.MAX_VALUE / 2 + 1]);
} | 1 | Java | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
public void isTooLargeCharArrayInputLength() throws Exception {
Snappy.compress(new char[Integer.MAX_VALUE / 2 + 1]);
} | 1 | Java | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
public void isTooLargeFloatArrayInputLength() throws Exception {
Snappy.compress(new float[Integer.MAX_VALUE / 4 + 1]);
} | 1 | Java | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
public void isTooLargeIntArrayInputLength() throws Exception {
Snappy.compress(new int[Integer.MAX_VALUE / 4 + 1]);
} | 1 | Java | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
public void isTooLargeDoubleArrayInputLength() throws Exception {
Snappy.compress(new double[Integer.MAX_VALUE / 8 + 1]);
} | 1 | Java | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
public void isValidArrayInputLength()
throws Exception {
byte[] a = Snappy.compress(new char[0]);
byte[] b = Snappy.compress(new double[0]);
byte[] c = Snappy.compress(new float[0]);
byte[] d = Snappy.compress(new int[0]);
byte[] e = Snappy.compress(new long[0]);
byte[] f = Snappy.compress(new short[0]);
byte[] g = Snappy.compress(new char[10]);
byte[] h = Snappy.compress(new double[10]);
byte[] i = Snappy.compress(new float[10]);
byte[] j = Snappy.compress(new int[10]);
byte[] k = Snappy.compress(new long[10]);
byte[] l = Snappy.compress(new short[10]);
} | 1 | Java | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
public void isTooLargeLongArrayInputLength() throws Exception {
Snappy.compress(new long[Integer.MAX_VALUE / 8 + 1]);
} | 1 | Java | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
public void isTooLargeShortArrayInputLength() throws Exception {
Snappy.compress(new short[Integer.MAX_VALUE / 2 + 1]);
} | 1 | Java | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
public SnappyInputStream(InputStream input)
throws IOException
{
this(input, MAX_CHUNK_SIZE);
} | 1 | Java | CWE-770 | Allocation of Resources Without Limits or Throttling | The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor. | https://cwe.mitre.org/data/definitions/770.html | safe |
public SnappyInputStream(InputStream input, int maxChunkSize)
throws IOException
{
this.maxChunkSize = maxChunkSize;
this.in = input;
readHeader();
} | 1 | Java | CWE-770 | Allocation of Resources Without Limits or Throttling | The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor. | https://cwe.mitre.org/data/definitions/770.html | safe |
public SnappyOutputStream(OutputStream out, int blockSize, BufferAllocatorFactory bufferAllocatorFactory)
{
this.out = out;
this.blockSize = Math.max(MIN_BLOCK_SIZE, blockSize);
if (this.blockSize > MAX_BLOCK_SIZE){
throw new IllegalArgumentException(String.format("Provided chunk size %,d larger than max %,d", this.blockSize, MAX_BLOCK_SIZE));
}
int inputSize = blockSize;
int outputSize = SnappyCodec.HEADER_SIZE + 4 + Snappy.maxCompressedLength(blockSize);
this.inputBufferAllocator = bufferAllocatorFactory.getBufferAllocator(inputSize);
this.outputBufferAllocator = bufferAllocatorFactory.getBufferAllocator(outputSize);
inputBuffer = inputBufferAllocator.allocate(inputSize);
outputBuffer = outputBufferAllocator.allocate(outputSize);
} | 1 | Java | CWE-770 | Allocation of Resources Without Limits or Throttling | The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor. | https://cwe.mitre.org/data/definitions/770.html | safe |
public void invalidBlockSize()
throws Exception
{
// We rely on catch below, if there is no error this test will pass
// This can be done better with Assertions.assertThrows
Boolean exceptionThrown = false;
ByteArrayOutputStream b = new ByteArrayOutputStream();
SnappyOutputStream os = new SnappyOutputStream(b, 1024 * 1024 * 1024);
} | 1 | Java | CWE-770 | Allocation of Resources Without Limits or Throttling | The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor. | https://cwe.mitre.org/data/definitions/770.html | safe |
public void isInvalidChunkLengthForSnappyInputStream()
throws Exception {
byte[] data = {-126, 'S', 'N', 'A', 'P', 'P', 'Y', 0, 0, 0, 0, 0, 0, 0, 0, 0, (byte) 0x7f, (byte) 0xff, (byte) 0xff, (byte) 0xff};
SnappyInputStream in = new SnappyInputStream(new ByteArrayInputStream(data));
byte[] out = new byte[50];
try {
in.read(out);
} catch (SnappyError error) {
Assert.assertEquals(error.errorCode, SnappyErrorCode.FAILED_TO_UNCOMPRESS);
}
} | 1 | Java | CWE-770 | Allocation of Resources Without Limits or Throttling | The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor. | https://cwe.mitre.org/data/definitions/770.html | safe |
public AbstractSniHandler() {
this(0, 0L);
} | 1 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
protected AbstractSniHandler(int maxClientHelloLength, long handshakeTimeoutMillis) {
super(maxClientHelloLength);
this.handshakeTimeoutMillis = checkPositiveOrZero(handshakeTimeoutMillis, "handshakeTimeoutMillis");
} | 1 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
protected AbstractSniHandler(long handshakeTimeoutMillis) {
this(0, handshakeTimeoutMillis);
} | 1 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
public SniHandler(Mapping<? super String, ? extends SslContext> mapping,
int maxClientHelloLength, long handshakeTimeoutMillis) {
this(new AsyncMappingAdapter(mapping), maxClientHelloLength, handshakeTimeoutMillis);
} | 1 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
public SniHandler(AsyncMapping<? super String, ? extends SslContext> mapping) {
this(mapping, 0, 0L);
} | 1 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
public SniHandler(AsyncMapping<? super String, ? extends SslContext> mapping,
int maxClientHelloLength, long handshakeTimeoutMillis) {
super(maxClientHelloLength, handshakeTimeoutMillis);
this.mapping = (AsyncMapping<String, SslContext>) ObjectUtil.checkNotNull(mapping, "mapping");
} | 1 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
public SniHandler(Mapping<? super String, ? extends SslContext> mapping, long handshakeTimeoutMillis) {
this(new AsyncMappingAdapter(mapping), handshakeTimeoutMillis);
} | 1 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
public SniHandler(AsyncMapping<? super String, ? extends SslContext> mapping, long handshakeTimeoutMillis) {
this(mapping, 0, handshakeTimeoutMillis);
} | 1 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
protected SslClientHelloHandler(int maxClientHelloLength) {
// 16MB is the maximum as per RFC:
// See https://www.rfc-editor.org/rfc/rfc5246#section-6.2.1
this.maxClientHelloLength =
ObjectUtil.checkInRange(maxClientHelloLength, 0, MAX_CLIENT_HELLO_LENGTH, "maxClientHelloLength");
} | 1 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
public SslClientHelloHandler() {
this(MAX_CLIENT_HELLO_LENGTH);
} | 1 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
public void testSniHandlerFiresHandshakeTimeout() throws Exception {
SniHandler handler = new SniHandler(new Mapping<String, SslContext>() {
@Override
public SslContext map(String input) {
throw new UnsupportedOperationException("Should not be called");
}
}, 0, 10);
final AtomicReference<SniCompletionEvent> completionEventRef =
new AtomicReference<SniCompletionEvent>();
EmbeddedChannel ch = new EmbeddedChannel(handler, new ChannelInboundHandlerAdapter() {
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
if (evt instanceof SniCompletionEvent) {
completionEventRef.set((SniCompletionEvent) evt);
}
}
});
try {
while (completionEventRef.get() == null) {
Thread.sleep(100);
// We need to run all pending tasks as the handshake timeout is scheduled on the EventLoop.
ch.runPendingTasks();
}
SniCompletionEvent completionEvent = completionEventRef.get();
assertNotNull(completionEvent);
assertNotNull(completionEvent.cause());
assertEquals(SslHandshakeTimeoutException.class, completionEvent.cause().getClass());
} finally {
ch.finishAndReleaseAll();
}
} | 1 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
protected B decoderEnforceMaxRstFramesPerWindow(int maxRstFramesPerWindow, int secondsPerWindow) {
enforceNonCodecConstraints("decoderEnforceMaxRstFramesPerWindow");
this.maxRstFramesPerWindow = checkPositiveOrZero(
maxRstFramesPerWindow, "maxRstFramesPerWindow");
this.secondsPerWindow = checkPositiveOrZero(secondsPerWindow, "secondsPerWindow");
return self();
} | 1 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
private T buildFromCodec(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder) {
int maxConsecutiveEmptyDataFrames = decoderEnforceMaxConsecutiveEmptyDataFrames();
if (maxConsecutiveEmptyDataFrames > 0) {
decoder = new Http2EmptyDataFrameConnectionDecoder(decoder, maxConsecutiveEmptyDataFrames);
}
if (maxRstFramesPerWindow > 0 && secondsPerWindow > 0) {
decoder = new Http2MaxRstFrameDecoder(decoder, maxRstFramesPerWindow, secondsPerWindow);
}
final T handler;
try {
// Call the abstract build method
handler = build(decoder, encoder, initialSettings);
} catch (Throwable t) {
encoder.close();
decoder.close();
throw new IllegalStateException("failed to build an Http2ConnectionHandler", t);
}
// Setup post build options
handler.gracefulShutdownTimeoutMillis(gracefulShutdownTimeoutMillis);
if (handler.decoder().frameListener() == null) {
handler.decoder().frameListener(frameListener);
}
return handler;
} | 1 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
public Http2FrameCodecBuilder decoderEnforceMaxRstFramesPerWindow(
int maxConsecutiveEmptyFrames, int secondsPerWindow) {
return super.decoderEnforceMaxRstFramesPerWindow(maxConsecutiveEmptyFrames, secondsPerWindow);
} | 1 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
Http2FrameListener frameListener0() {
return super.frameListener();
} | 1 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
Http2MaxRstFrameDecoder(Http2ConnectionDecoder delegate, int maxRstFramesPerWindow, int secondsPerWindow) {
super(delegate);
this.maxRstFramesPerWindow = checkPositive(maxRstFramesPerWindow, "maxRstFramesPerWindow");
this.secondsPerWindow = checkPositive(secondsPerWindow, "secondsPerWindow");
} | 1 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
public Http2FrameListener frameListener() {
Http2FrameListener frameListener = frameListener0();
// Unwrap the original Http2FrameListener as we add this decoder under the hood.
if (frameListener instanceof Http2MaxRstFrameListener) {
return ((Http2MaxRstFrameListener) frameListener).listener;
}
return frameListener;
} | 1 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
public void frameListener(Http2FrameListener listener) {
if (listener != null) {
super.frameListener(new Http2MaxRstFrameListener(listener, maxRstFramesPerWindow, secondsPerWindow));
} else {
super.frameListener(null);
}
} | 1 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
Http2MaxRstFrameListener(Http2FrameListener listener, int maxRstFramesPerWindow, int secondsPerWindow) {
super(listener);
this.maxRstFramesPerWindow = maxRstFramesPerWindow;
this.nanosPerWindow = TimeUnit.SECONDS.toNanos(secondsPerWindow);
} | 1 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
public void onRstStreamRead(ChannelHandlerContext ctx, int streamId, long errorCode) throws Http2Exception {
long currentNano = System.nanoTime();
if (currentNano - lastRstFrameNano >= nanosPerWindow) {
lastRstFrameNano = currentNano;
receivedRstInWindow = 1;
} else {
receivedRstInWindow++;
if (receivedRstInWindow > maxRstFramesPerWindow) {
Http2Exception exception = Http2Exception.connectionError(Http2Error.ENHANCE_YOUR_CALM,
"Maximum number of RST frames reached");
logger.debug("{} Maximum number {} of RST frames reached within {} seconds, " +
"closing connection with {} error", ctx.channel(), maxRstFramesPerWindow,
TimeUnit.NANOSECONDS.toSeconds(nanosPerWindow), exception.error(), exception);
throw exception;
}
}
super.onRstStreamRead(ctx, streamId, errorCode);
} | 1 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
public Http2MultiplexCodecBuilder decoderEnforceMaxRstFramesPerWindow(
int maxConsecutiveEmptyFrames, int secondsPerWindow) {
return super.decoderEnforceMaxRstFramesPerWindow(maxConsecutiveEmptyFrames, secondsPerWindow);
} | 1 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
public void testDecoration() {
Http2ConnectionDecoder delegate = mock(Http2ConnectionDecoder.class);
final ArgumentCaptor<Http2FrameListener> listenerArgumentCaptor =
ArgumentCaptor.forClass(Http2FrameListener.class);
when(delegate.frameListener()).then(new Answer<Http2FrameListener>() {
@Override
public Http2FrameListener answer(InvocationOnMock invocationOnMock) {
return listenerArgumentCaptor.getValue();
}
});
Http2FrameListener listener = mock(Http2FrameListener.class);
DecoratingHttp2ConnectionDecoder decoder = newDecoder(delegate);
decoder.frameListener(listener);
verify(delegate).frameListener(listenerArgumentCaptor.capture());
assertThat(decoder.frameListener(),
CoreMatchers.not(CoreMatchers.instanceOf(delegatingFrameListenerType())));
} | 1 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
public void testDecorationWithNull() {
Http2ConnectionDecoder delegate = mock(Http2ConnectionDecoder.class);
DecoratingHttp2ConnectionDecoder decoder = newDecoder(delegate);
decoder.frameListener(null);
assertNull(decoder.frameListener());
} | 1 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
protected DecoratingHttp2ConnectionDecoder newDecoder(Http2ConnectionDecoder decoder) {
return new Http2EmptyDataFrameConnectionDecoder(decoder, 2);
} | 1 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
protected Class<? extends Http2FrameListener> delegatingFrameListenerType() {
return Http2EmptyDataFrameListener.class;
} | 1 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
protected Class<? extends Http2FrameListener> delegatingFrameListenerType() {
return Http2MaxRstFrameListener.class;
} | 1 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
protected DecoratingHttp2ConnectionDecoder newDecoder(Http2ConnectionDecoder decoder) {
return new Http2MaxRstFrameDecoder(decoder, 200, 30);
} | 1 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
public void testMaxRstFramesReached() throws Http2Exception {
listener = new Http2MaxRstFrameListener(frameListener, 1, 10);
listener.onRstStreamRead(ctx, 1, Http2Error.STREAM_CLOSED.code());
Http2Exception ex = assertThrows(Http2Exception.class, new Executable() {
@Override
public void execute() throws Throwable {
listener.onRstStreamRead(ctx, 2, Http2Error.STREAM_CLOSED.code());
}
});
assertEquals(Http2Error.ENHANCE_YOUR_CALM, ex.error());
verify(frameListener, times(1)).onRstStreamRead(eq(ctx), anyInt(), eq(Http2Error.STREAM_CLOSED.code()));
} | 1 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
public void setUp() {
initMocks(this);
} | 1 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
public void testRstFrames() throws Exception {
listener = new Http2MaxRstFrameListener(frameListener, 1, 1);
listener.onRstStreamRead(ctx, 1, Http2Error.STREAM_CLOSED.code());
Thread.sleep(1100);
listener.onRstStreamRead(ctx, 1, Http2Error.STREAM_CLOSED.code());
verify(frameListener, times(2)).onRstStreamRead(eq(ctx), anyInt(), eq(Http2Error.STREAM_CLOSED.code()));
} | 1 | Java | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
public static Value get(Object value) {
if (value == null) {
return NullValue.INSTANCE;
}
if (value instanceof Value) {
return (Value)value;
}
if (value instanceof byte[]) {
return new BytesValue((byte[])value);
}
if (value instanceof String) {
return new StringValue((String)value);
}
if (value instanceof Integer) {
return new IntegerValue((Integer)value);
}
if (value instanceof Long) {
return new LongValue((Long)value);
}
if (value instanceof List<?>) {
return new ListValue((List<?>)value);
}
if (value instanceof Map<?,?>) {
return new MapValue((Map<?,?>)value);
}
if (value instanceof Double) {
return new DoubleValue((Double)value);
}
if (value instanceof Float) {
return new FloatValue((Float)value);
}
if (value instanceof Short) {
return new ShortValue((Short)value);
}
if (value instanceof Boolean) {
if (UseBoolBin) {
return new BooleanValue((Boolean)value);
}
else {
return new BoolIntValue((Boolean)value);
}
}
if (value instanceof Byte) {
return new ByteValue((byte)value);
}
if (value instanceof Character) {
return Value.get(((Character)value).charValue());
}
if (value instanceof Enum) {
return new StringValue(value.toString());
}
if (value instanceof UUID) {
return new StringValue(value.toString());
}
if (value instanceof ByteBuffer) {
ByteBuffer bb = (ByteBuffer)value;
return new BytesValue(bb.array());
}
throw new AerospikeException("Unsupported type: " + value.getClass().getName());
} | 1 | Java | CWE-502 | Deserialization of Untrusted Data | The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid. | https://cwe.mitre.org/data/definitions/502.html | safe |
public void packObject(Object obj) {
if (obj == null) {
packNil();
return;
}
if (obj instanceof Value) {
Value value = (Value)obj;
value.pack(this);
return;
}
if (obj instanceof byte[]) {
packParticleBytes((byte[])obj);
return;
}
if (obj instanceof String) {
packParticleString((String)obj);
return;
}
if (obj instanceof Integer) {
packInt((Integer)obj);
return;
}
if (obj instanceof Long) {
packLong((Long)obj);
return;
}
if (obj instanceof List<?>) {
packList((List<?>)obj);
return;
}
if (obj instanceof Map<?,?>) {
packMap((Map<?,?>)obj);
return;
}
if (obj instanceof Double) {
packDouble((Double)obj);
return;
}
if (obj instanceof Float) {
packFloat((Float)obj);
return;
}
if (obj instanceof Short) {
packInt((Short)obj);
return;
}
if (obj instanceof Boolean) {
packBoolean((Boolean)obj);
return;
}
if (obj instanceof Byte) {
packInt(((Byte)obj) & 0xff);
return;
}
if (obj instanceof Character) {
packInt(((Character)obj).charValue());
return;
}
if (obj instanceof Enum) {
packString(obj.toString());
return;
}
if (obj instanceof UUID) {
packString(obj.toString());
return;
}
if (obj instanceof ByteBuffer) {
packByteBuffer((ByteBuffer) obj);
return;
}
throw new AerospikeException("Unsupported type: " + obj.getClass().getName());
} | 1 | Java | CWE-502 | Deserialization of Untrusted Data | The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid. | https://cwe.mitre.org/data/definitions/502.html | safe |
public void runListRangeExample(AerospikeClient client, Parameters params) {
Key key = new Key(params.namespace, params.set, "mapkey");
String binName = "mapbin";
// Delete record if it already exists.
client.delete(params.writePolicy, key);
List<Value> l1 = new ArrayList<Value>();
l1.add(Value.get(new GregorianCalendar(2018, 1, 1).getTimeInMillis()));
l1.add(Value.get(1));
List<Value> l2 = new ArrayList<Value>();
l2.add(Value.get(new GregorianCalendar(2018, 1, 2).getTimeInMillis()));
l2.add(Value.get(2));
List<Value> l3 = new ArrayList<Value>();
l3.add(Value.get(new GregorianCalendar(2018, 2, 1).getTimeInMillis()));
l3.add(Value.get(3));
List<Value> l4 = new ArrayList<Value>();
l4.add(Value.get(new GregorianCalendar(2018, 2, 2).getTimeInMillis()));
l4.add(Value.get(4));
List<Value> l5 = new ArrayList<Value>();
l5.add(Value.get(new GregorianCalendar(2018, 2, 5).getTimeInMillis()));
l5.add(Value.get(5));
Map<Value,Value> inputMap = new HashMap<Value,Value>();
inputMap.put(Value.get("Charlie"), Value.get(l1));
inputMap.put(Value.get("Jim"), Value.get(l2));
inputMap.put(Value.get("John"), Value.get(l3));
inputMap.put(Value.get("Harry"), Value.get(l4));
inputMap.put(Value.get("Bill"), Value.get(l5));
// Write values to empty map.
Record record = client.operate(params.writePolicy, key,
MapOperation.putItems(MapPolicy.Default, binName, inputMap)
);
console.info("Record: " + record);
List<Value> end = new ArrayList<Value>();
end.add(Value.get(new GregorianCalendar(2018, 2, 2).getTimeInMillis()));
end.add(Value.getAsNull());
// Delete values < end.
record = client.operate(params.writePolicy, key,
MapOperation.removeByValueRange(binName, null, Value.get(end), MapReturnType.COUNT)
);
console.info("Record: " + record);
} | 1 | Java | CWE-502 | Deserialization of Untrusted Data | The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid. | https://cwe.mitre.org/data/definitions/502.html | safe |
public void addNullValue() {
Version version = Version.getServerVersion(client, null);
// Do not run on servers < 3.6.1
if (version.isLess(3, 6, 1)) {
return;
}
Key key = new Key(args.namespace, args.set, "addkey");
String binName = "addbin";
// Delete record if it already exists.
client.delete(null, key);
Bin bin = new Bin(binName, Value.get((Object)null));
AerospikeException ae = assertThrows(AerospikeException.class, new ThrowingRunnable() {
public void run() {
client.add(null, key, bin);
}
});
assertEquals(ae.getResultCode(), ResultCode.PARAMETER_ERROR);
} | 1 | Java | CWE-502 | Deserialization of Untrusted Data | The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid. | https://cwe.mitre.org/data/definitions/502.html | safe |
public static void validateString(final String what, final String s, String specials) {
if (s == null) {
throw new BadRequestException("Invalid " + what + ": null");
} else if ("".equals(s)) {
throw new BadRequestException("Invalid " + what + ": empty string");
}
final int n = s.length();
for (int i = 0; i < n; i++) {
final char c = s.charAt(i);
if (!(('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')
|| ('0' <= c && c <= '9') || c == '-' || c == '_' || c == '.'
|| c == '/' || Character.isLetter(c) || specials.indexOf(c) != -1)) {
throw new BadRequestException("Invalid " + what
+ " (\"" + s + "\"): illegal character: " + c);
}
}
} | 1 | Java | CWE-74 | Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') | The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/74.html | safe |
static void validateString(final String what, final String s) {
validateString(what, s, "");
} | 1 | Java | CWE-74 | Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') | The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/74.html | safe |
static void setPlotDimensions(final HttpQuery query, final Plot plot) {
String wxh = query.getQueryStringParam("wxh");
if (wxh != null && !wxh.isEmpty()) {
wxh = URLDecoder.decode(wxh.trim());
validateString("wxh", wxh);
if (!WXH_VALIDATOR.matcher(wxh).find()) {
throw new IllegalArgumentException("'wxh' was invalid. "
+ "Must satisfy the pattern " + WXH_VALIDATOR.toString());
}
final int wxhlength = wxh.length();
if (wxhlength < 7) { // 100x100 minimum.
throw new BadRequestException("Parameter wxh too short: " + wxh);
}
final int x = wxh.indexOf('x', 3); // Start at 2 as min size is 100x100
if (x < 0) {
throw new BadRequestException("Invalid wxh parameter: " + wxh);
}
try {
final short width = Short.parseShort(wxh.substring(0, x));
final short height = Short.parseShort(wxh.substring(x + 1, wxhlength));
try {
plot.setDimensions(width, height);
} catch (IllegalArgumentException e) {
throw new BadRequestException("Invalid wxh parameter: " + wxh + ", "
+ e.getMessage());
}
} catch (NumberFormatException e) {
throw new BadRequestException("Can't parse wxh '" + wxh + "': "
+ e.getMessage());
}
}
} | 1 | Java | CWE-74 | Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') | The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/74.html | safe |
public void setColorParams() throws Exception {
assertPlotParam("bgcolor", "x000000");
assertPlotParam("bgcolor", "XDEADBE");
assertPlotParam("bgcolor", "%58DEADBE");
assertInvalidPlotParam("bgcolor", "XDEADBEF");
assertInvalidPlotParam("bgcolor", "%5BDEADBE");
assertInvalidPlotParam("bgcolor", "xBDE%0AAD");
assertPlotParam("fgcolor", "x000000");
assertPlotParam("fgcolor", "XDEADBE");
assertPlotParam("fgcolor", "%58DEADBE");
assertInvalidPlotParam("fgcolor", "XDEADBEF");
assertInvalidPlotParam("fgcolor", "%5BDEADBE");
assertInvalidPlotParam("fgcolor", "xBDE%0AAD");
} | 1 | Java | CWE-74 | Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') | The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/74.html | safe |
public void setWXH() throws Exception {
assertPlotDimension("wxh", "720x640");
assertInvalidPlotDimension("wxh", "720%0ax640");
} | 1 | Java | CWE-74 | Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') | The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/74.html | safe |
public void setKeyParams() throws Exception {
assertPlotParam("key", "out");
assertPlotParam("key", "left");
assertPlotParam("key", "top");
assertPlotParam("key", "center");
assertPlotParam("key", "right");
assertPlotParam("key", "horiz");
assertPlotParam("key", "box");
assertPlotParam("key", "bottom");
assertInvalidPlotParam("key", "out%20right%20top%0aset%20yrange%20[33:system(%20");
assertInvalidPlotParam("key", "%3Bsystem%20%22cat%20/home/ubuntuvm/secret.txt%20%3E/tmp/secret.txt%22%20%22");
} | 1 | Java | CWE-74 | Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') | The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/74.html | safe |
public void setLabelParams() throws Exception {
assertPlotParam("ylabel", "This is good");
assertPlotParam("ylabel", " and so Is this - _ yay");
assertInvalidPlotParam("ylabel", "system(%20no%0anewlines");
assertInvalidPlotParam("title", "system(%20no%0anewlines");
assertInvalidPlotParam("y2label", "system(%20no%0anewlines");
} | 1 | Java | CWE-74 | Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') | The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/74.html | safe |
public void setSmoothParams() throws Exception {
assertPlotParam("smooth", "unique");
assertPlotParam("smooth", "frequency");
assertPlotParam("smooth", "fnormal");
assertPlotParam("smooth", "cumulative");
assertPlotParam("smooth", "cnormal");
assertPlotParam("smooth", "bins");
assertPlotParam("smooth", "csplines");
assertPlotParam("smooth", "acsplines");
assertPlotParam("smooth", "mcsplines");
assertPlotParam("smooth", "bezier");
assertPlotParam("smooth", "sbezier");
assertPlotParam("smooth", "unwrap");
assertPlotParam("smooth", "zsort");
assertInvalidPlotParam("smooth", "bezier%20system(%20");
assertInvalidPlotParam("smooth", "fnormal%0asystem(%20");
} | 1 | Java | CWE-74 | Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') | The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/74.html | safe |
public void setFormatParams() throws Exception {
assertPlotParam("yformat", "%25.2f");
assertPlotParam("y2format", "%25.2f");
assertPlotParam("xformat", "%25.2f");
assertPlotParam("yformat", "%253.0em");
assertPlotParam("yformat", "%253.0em%25%25");
assertPlotParam("yformat", "%25.2f seconds");
assertPlotParam("yformat", "%25.0f ms");
assertInvalidPlotParam("yformat", "%252.system(%20");
assertInvalidPlotParam("yformat", "%252.%0asystem(%20");
} | 1 | Java | CWE-74 | Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') | The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/74.html | safe |
private static void assertPlotDimension(String param, String value) {
Plot plot = mock(Plot.class);
HttpQuery query = mock(HttpQuery.class);
when(query.getQueryStringParam(param)).thenReturn(value);
GraphHandler.setPlotParams(query, plot);
} | 1 | Java | CWE-74 | Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') | The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/74.html | safe |
public void setStyleParams() throws Exception {
assertPlotParam("style", "linespoint");
assertPlotParam("style", "points");
assertPlotParam("style", "circles");
assertPlotParam("style", "dots");
assertInvalidPlotParam("style", "dots%20%0a[33:system(%20");
assertInvalidPlotParam("style", "%3Bsystem%20%22cat%20/home/ubuntuvm/secret.txt%20%3E/tmp/secret.txt%22%20%22\"");
} | 1 | Java | CWE-74 | Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') | The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/74.html | safe |
private static void assertInvalidPlotDimension(String param, String value) {
Plot plot = mock(Plot.class);
HttpQuery query = mock(HttpQuery.class);
when(query.getQueryStringParam(param)).thenReturn(value);
try {
GraphHandler.setPlotDimensions(query, plot);
fail("Expected BadRequestException");
} catch (BadRequestException e) { }
} | 1 | Java | CWE-74 | Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') | The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/74.html | safe |
public void setYRangeParams() throws Exception {
assertPlotParam("yrange","[0:1]");
assertPlotParam("yrange", "[:]");
assertPlotParam("yrange", "[:0]");
assertPlotParam("yrange", "[:42]");
assertPlotParam("yrange", "[:-42]");
assertPlotParam("yrange", "[:0.8]");
assertPlotParam("yrange", "[:-0.8]");
assertPlotParam("yrange", "[:42.4]");
assertPlotParam("yrange", "[:-42.4]");
assertPlotParam("yrange", "[:4e4]");
assertPlotParam("yrange", "[:-4e4]");
assertPlotParam("yrange", "[:4e-4]");
assertPlotParam("yrange", "[:-4e-4]");
assertPlotParam("yrange", "[:4.2e4]");
assertPlotParam("yrange", "[:-4.2e4]");
assertPlotParam("yrange", "[0:]");
assertPlotParam("yrange", "[5:]");
assertPlotParam("yrange", "[-5:]");
assertPlotParam("yrange", "[0.5:]");
assertPlotParam("yrange", "[-0.5:]");
assertPlotParam("yrange", "[10.5:]");
assertPlotParam("yrange", "[-10.5:]");
assertPlotParam("yrange", "[10e5:]");
assertPlotParam("yrange", "[-10e5:]");
assertPlotParam("yrange", "[10e-5:]");
assertPlotParam("yrange", "[-10e-5:]");
assertPlotParam("yrange", "[10.1e-5:]");
assertPlotParam("yrange", "[-10.1e-5:]");
assertPlotParam("yrange", "[-10.1e-5:-10.1e-6]");
assertInvalidPlotParam("yrange", "[33:system('touch /tmp/poc.txt')]");
assertInvalidPlotParam("y2range", "[42:%0a[33:system('touch /tmp/poc.txt')]");
} | 1 | Java | CWE-74 | Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') | The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/74.html | safe |
public void badRequest(final BadRequestException exception) {
logWarn("Bad Request on " + request().getUri() + ": " + exception.getMessage());
if (this.api_version > 0) {
// always default to the latest version of the error formatter since we
// need to return something
switch (this.api_version) {
case 1:
default:
sendReply(exception.getStatus(), serializer.formatErrorV1(exception));
}
return;
}
if (hasQueryStringParam("json")) {
final StringBuilder buf = new StringBuilder(10 +
exception.getDetails().length());
buf.append("{\"err\":\"");
HttpQuery.escapeJson(exception.getMessage(), buf);
buf.append("\"}");
sendReply(HttpResponseStatus.BAD_REQUEST, buf);
} else {
String response = "";
if (exception.getMessage() != null) {
response = HtmlEscapers.htmlEscaper().escape(exception.getMessage());
}
sendReply(HttpResponseStatus.BAD_REQUEST,
makePage("Bad Request", "Looks like it's your fault this time",
"<blockquote>"
+ "<h1>Bad Request</h1>"
+ "Sorry but your request was rejected as being"
+ " invalid.<br/><br/>"
+ "The reason provided was:<blockquote>"
+ response
+ "</blockquote></blockquote>"));
}
} | 1 | Java | CWE-74 | Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') | The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/74.html | safe |
public void internalError(final Exception cause) {
logError("Internal Server Error on " + request().getUri(), cause);
if (this.api_version > 0) {
// always default to the latest version of the error formatter since we
// need to return something
switch (this.api_version) {
case 1:
default:
sendReply(HttpResponseStatus.INTERNAL_SERVER_ERROR,
serializer.formatErrorV1(cause));
}
return;
}
ThrowableProxy tp = new ThrowableProxy(cause);
tp.calculatePackagingData();
final String pretty_exc = ThrowableProxyUtil.asString(tp);
tp = null;
if (hasQueryStringParam("json")) {
// 32 = 10 + some extra space as exceptions always have \t's to escape.
final StringBuilder buf = new StringBuilder(32 + pretty_exc.length());
buf.append("{\"err\":\"");
HttpQuery.escapeJson(pretty_exc, buf);
buf.append("\"}");
sendReply(HttpResponseStatus.INTERNAL_SERVER_ERROR, buf);
} else {
String response = "";
if (pretty_exc != null) {
response = HtmlEscapers.htmlEscaper().escape(pretty_exc);
}
sendReply(HttpResponseStatus.INTERNAL_SERVER_ERROR,
makePage("Internal Server Error", "Houston, we have a problem",
"<blockquote>"
+ "<h1>Internal Server Error</h1>"
+ "Oops, sorry but your request failed due to a"
+ " server error.<br/><br/>"
+ "Please try again in 30 seconds.<pre>"
+ response
+ "</pre></blockquote>"));
}
} | 1 | Java | CWE-74 | Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') | The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/74.html | safe |
public void internalErrorDeprecatedHTMLEscaped() {
HttpQuery query = NettyMocks.getQuery(tsdb, "");
query.internalError(new Exception("<script>alert(document.cookie)</script>"));
assertEquals(HttpResponseStatus.INTERNAL_SERVER_ERROR,
query.response().getStatus());
assertTrue(query.response().getContent().toString(Charset.forName("UTF-8")).contains(
"<script>alert(document.cookie)</script>"
));
} | 1 | Java | CWE-74 | Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') | The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/74.html | safe |
public void badRequestDeprecatedHTMLEscaped() {
HttpQuery query = NettyMocks.getQuery(tsdb, "/");
query.badRequest(new BadRequestException("<script>alert(document.cookie)</script>"));
assertEquals(HttpResponseStatus.BAD_REQUEST, query.response().getStatus());
assertTrue(query.response().getContent().toString(Charset.forName("UTF-8")).contains(
"The reason provided was:<blockquote><script>alert(document.cookie)</script>"
));
} | 1 | Java | CWE-74 | Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') | The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/74.html | safe |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.