id
stringlengths 19
29
| content
stringlengths 384
8.43k
| max_stars_repo_path
stringlengths 38
48
|
|---|---|---|
vjbench_data_Ratpack-1
|
private void newRequest(ChannelHandlerContext ctx, HttpRequest nettyRequest) throws Exception {
if (!nettyRequest.decoderResult().isSuccess()) {
LOGGER.debug("Failed to decode HTTP request.", nettyRequest.decoderResult().cause());
sendError(ctx, HttpResponseStatus.BAD_REQUEST);
return;
}
Headers requestHeaders = new NettyHeadersBackedHeaders(nettyRequest.headers());
Long contentLength = HttpUtil.getContentLength(nettyRequest, -1L);
String transferEncoding = requestHeaders.get(HttpHeaderNames.TRANSFER_ENCODING);
boolean hasBody = (contentLength > 0) || (transferEncoding != null);
RequestBody requestBody = hasBody ? new RequestBody(contentLength, nettyRequest, ctx) : null;
Channel channel = ctx.channel();
if (requestBody != null) {
channel.attr(BODY_ACCUMULATOR_KEY).set(requestBody);
}
InetSocketAddress remoteAddress = (InetSocketAddress) channel.remoteAddress();
InetSocketAddress socketAddress = (InetSocketAddress) channel.localAddress();
ConnectionIdleTimeout connectionIdleTimeout = ConnectionIdleTimeout.of(channel);
DefaultRequest request = new DefaultRequest(
clock.instant(),
requestHeaders,
nettyRequest.method(),
nettyRequest.protocolVersion(),
nettyRequest.uri(),
remoteAddress,
socketAddress,
serverRegistry.get(ServerConfig.class),
requestBody,
connectionIdleTimeout,
channel.attr(CLIENT_CERT_KEY).get()
);
HttpHeaders nettyHeaders = new DefaultHttpHeaders(false);
MutableHeaders responseHeaders = new NettyHeadersBackedMutableHeaders(nettyHeaders);
AtomicBoolean transmitted = new AtomicBoolean(false);
DefaultResponseTransmitter responseTransmitter = new DefaultResponseTransmitter(transmitted, channel, clock, nettyRequest, request, nettyHeaders, requestBody);
ctx.channel().attr(DefaultResponseTransmitter.ATTRIBUTE_KEY).set(responseTransmitter);
Action<Action<Object>> subscribeHandler = thing -> {
transmitted.set(true);
ctx.channel().attr(CHANNEL_SUBSCRIBER_ATTRIBUTE_KEY).set(thing);
};
DefaultContext.RequestConstants requestConstants = new DefaultContext.RequestConstants(
applicationConstants,
request,
channel,
responseTransmitter,
subscribeHandler
);
Response response = new DefaultResponse(responseHeaders, ctx.alloc(), responseTransmitter);
requestConstants.response = response;
DefaultContext.start(channel.eventLoop(), requestConstants, serverRegistry, handlers, execution -> {
if (!transmitted.get()) {
Handler lastHandler = requestConstants.handler;
StringBuilder description = new StringBuilder();
description
.append("No response sent for ")
.append(request.getMethod().getName())
.append(" request to ")
.append(request.getUri());
if (lastHandler != null) {
description.append(" (last handler: ");
if (lastHandler instanceof DescribingHandler) {
((DescribingHandler) lastHandler).describeTo(description);
} else {
DescribingHandlers.describeTo(lastHandler, description);
}
description.append(")");
}
String message = description.toString();
LOGGER.warn(message);
response.getHeaders().clear();
ByteBuf body;
if (development) {
CharBuffer charBuffer = CharBuffer.wrap(message);
body = ByteBufUtil.encodeString(ctx.alloc(), charBuffer, CharsetUtil.UTF_8);
response.contentType(HttpHeaderConstants.PLAIN_TEXT_UTF8);
} else {
body = Unpooled.EMPTY_BUFFER;
}
response.getHeaders().set(HttpHeaderConstants.CONTENT_LENGTH, body.readableBytes());
responseTransmitter.transmit(HttpResponseStatus.INTERNAL_SERVER_ERROR, body);
}
});
}
private void newRequest(ChannelHandlerContext ctx, HttpRequest nettyRequest) throws Exception {
DecoderResult decoderResult = nettyRequest.decoderResult();
if (decoderResult.isSuccess()) {
HttpHeaders httpHeaders = nettyRequest.headers();
Headers requestHeaders = new NettyHeadersBackedHeaders(httpHeaders);
Long contentLength = HttpUtil.getContentLength(nettyRequest, -1L);
boolean hasBody = (contentLength > 0) || (requestHeaders.get(HttpHeaderNames.TRANSFER_ENCODING) != null);
RequestBody requestBody;
if(!hasBody){
requestBody = null;
}else{
requestBody = new RequestBody(contentLength, nettyRequest, ctx);
}
Channel channel = ctx.channel();
if (requestBody != null) {
channel.attr(BODY_ACCUMULATOR_KEY).set(requestBody);
}
X509Certificate clientCertificate = channel.attr(CLIENT_CERT_KEY).get();
Instant instant = clock.instant();
DefaultRequest request = new DefaultRequest(
instant,
requestHeaders,
nettyRequest.method(),
nettyRequest.protocolVersion(),
nettyRequest.uri(),
(InetSocketAddress) channel.remoteAddress(),
(InetSocketAddress) channel.localAddress(),
serverRegistry.get(ServerConfig.class),
requestBody,
ConnectionIdleTimeout.of(channel),
clientCertificate
);
HttpHeaders nettyHeaders = new DefaultHttpHeaders();
MutableHeaders responseHeaders = new NettyHeadersBackedMutableHeaders(nettyHeaders);
AtomicBoolean transmitted = new AtomicBoolean(false);
DefaultResponseTransmitter responseTransmitter = new DefaultResponseTransmitter(transmitted, channel, clock, nettyRequest, request, nettyHeaders, requestBody);
Channel ctxChannel = ctx.channel();
ctxChannel.attr(DefaultResponseTransmitter.ATTRIBUTE_KEY).set(responseTransmitter);
DefaultContext.RequestConstants requestConstants = new DefaultContext.RequestConstants(
applicationConstants,
request,
channel,
responseTransmitter,
thing -> {
transmitted.set(true);
ctx.channel().attr(CHANNEL_SUBSCRIBER_ATTRIBUTE_KEY).set(thing);
}
);
ByteBufAllocator byteBufAllocator = ctx.alloc();
Response response = new DefaultResponse(responseHeaders, byteBufAllocator, responseTransmitter);
requestConstants.response = response;
EventLoop eventLoop = channel.eventLoop();
DefaultContext.start(eventLoop, requestConstants, serverRegistry, handlers, execution -> {
if (!transmitted.get()) {
Handler lastHandler = requestConstants.handler;
StringBuilder description = new StringBuilder();
description.append("No response sent for ");
String name = request.getMethod().getName();
description.append(name);
description.append(" request to ");
String uri = request.getUri();
description.append(uri);
if (lastHandler != null) {
description.append(" (last handler: ");
if (!(lastHandler instanceof DescribingHandler)) {
DescribingHandlers.describeTo(lastHandler, description);
} else {
((DescribingHandler) lastHandler).describeTo(description);
}
description.append(")");
}
String message = description.toString();
LOGGER.warn(message);
response.getHeaders().clear();
ByteBuf body;
if (!development) {
body = Unpooled.EMPTY_BUFFER;
} else {
ByteBufAllocator byteBufAllocator2 = ctx.alloc();
CharBuffer charBuffer = CharBuffer.wrap(message);
body = ByteBufUtil.encodeString(byteBufAllocator2, charBuffer, CharsetUtil.UTF_8);
response.contentType(HttpHeaderConstants.PLAIN_TEXT_UTF8);
}
int num = body.readableBytes();
response.getHeaders().set(HttpHeaderConstants.CONTENT_LENGTH, num);
responseTransmitter.transmit(HttpResponseStatus.INTERNAL_SERVER_ERROR, body);
}
});
}else{
LOGGER.debug("Failed to decode HTTP request.", decoderResult.cause());
sendError(ctx, HttpResponseStatus.BAD_REQUEST);
return;
}
}
|
./VJBench/llm-vul/VJBench-trans/Ratpack-1
|
vjbench_data_Jenkins-3
|
@Override
public SearchIndexBuilder makeSearchIndex() {
return super.makeSearchIndex()
.add("configure", "config","configure")
.add("manage")
.add("log")
.add(new CollectionSearchIndex<TopLevelItem>() {
protected SearchItem get(String key) { return getItemByFullName(key, TopLevelItem.class); }
protected Collection<TopLevelItem> all() { return getAllItems(TopLevelItem.class); }
})
.add(getPrimaryView().makeSearchIndex())
.add(new CollectionSearchIndex() {
protected Computer get(String key) { return getComputer(key); }
protected Collection<Computer> all() { return computers.values(); }
})
.add(new CollectionSearchIndex() {
protected User get(String key) { return User.get(key,false); }
protected Collection<User> all() { return User.getAll(); }
})
.add(new CollectionSearchIndex() {
protected View get(String key) { return getView(key); }
protected Collection<View> all() { return views; }
});
}
@Override
public SearchIndexBuilder makeSearchIndex() {
SearchIndexBuilder searchIndexBuilder = super.makeSearchIndex();
CollectionSearchIndex<TopLevelItem> collectionSearchIndexItem=new CollectionSearchIndex<TopLevelItem>() {
protected SearchItem get(String key) {
return getItemByFullName(key, TopLevelItem.class);
}
protected Collection<TopLevelItem> all() {
return getAllItems(TopLevelItem.class);
}
};
CollectionSearchIndex collectionSearchIndexComputer = new CollectionSearchIndex() {
protected Collection<Computer> all() {
return computers.values();
}
protected Computer get(String key) {
return getComputer(key);
}
};
searchIndexBuilder.add(collectionSearchIndexItem);
searchIndexBuilder.add("configure", "config","configure");
View primaryView_ = getPrimaryView();
SearchIndexBuilder primaryViewSearchIndexBuilder = primaryView_.makeSearchIndex();
searchIndexBuilder.add(primaryViewSearchIndexBuilder);
searchIndexBuilder.add(collectionSearchIndexComputer);
searchIndexBuilder.add("manage");
searchIndexBuilder.add("log");
CollectionSearchIndex collectionSearchIndexView = new CollectionSearchIndex() {
protected Collection<View> all() {
return getViews();
}
protected View get(String key) {
return getView(key);
}
};
CollectionSearchIndex collectionSearchIndexUser = new CollectionSearchIndex() {
protected Collection<User> all() {
return User.getAll();
}
protected User get(String key) {
return User.get(key,false);
}
};
searchIndexBuilder.add(collectionSearchIndexUser);
searchIndexBuilder.add(collectionSearchIndexView);
return searchIndexBuilder;
}
|
./VJBench/llm-vul/VJBench-trans/Jenkins-3
|
vjbench_data_Pulsar-1
|
protected void internalGetMessageById(AsyncResponse asyncResponse, long ledgerId, long entryId,
boolean authoritative) {
try {
validateTopicOwnership(topicName, authoritative);
validateTopicOperation(topicName, TopicOperation.PEEK_MESSAGES);
if (topicName.isGlobal()) {
validateGlobalNamespaceOwnership(namespaceName);
}
PersistentTopic topic = (PersistentTopic) getTopicReference(topicName);
ManagedLedgerImpl ledger = (ManagedLedgerImpl) topic.getManagedLedger();
ledger.asyncReadEntry(new PositionImpl(ledgerId, entryId), new AsyncCallbacks.ReadEntryCallback() {
@Override
public void readEntryFailed(ManagedLedgerException exception, Object ctx) {
asyncResponse.resume(new RestException(exception));
}
@Override
public void readEntryComplete(Entry entry, Object ctx) {
try {
asyncResponse.resume(generateResponseWithEntry(entry));
} catch (IOException exception) {
asyncResponse.resume(new RestException(exception));
} finally {
if (entry != null) {
entry.release();
}
}
}
}, null);
} catch (NullPointerException npe) {
asyncResponse.resume(new RestException(Status.NOT_FOUND, "Message not found"));
} catch (Exception exception) {
log.error("[{}] Failed to get message with ledgerId {} entryId {} from {}",
clientAppId(), ledgerId, entryId, topicName, exception);
asyncResponse.resume(new RestException(exception));
}
}
protected void internalGetMessageById(AsyncResponse asyncResponse, long ledgerId, long entryId,
boolean authoritative) {
try {
validateTopicOwnership(topicName, authoritative);
validateTopicOperation(topicName, TopicOperation.PEEK_MESSAGES);
if (topicName.isGlobal()) {
validateGlobalNamespaceOwnership(namespaceName);
}
AsyncCallbacks.ReadEntryCallback readEntryCallback = new AsyncCallbacks.ReadEntryCallback() {
@Override
public void readEntryComplete(Entry entry, Object ctx) {
try {
Response response = generateResponseWithEntry(entry);
asyncResponse.resume(response);
} catch (IOException exception) {
RestException restException = new RestException(exception);
asyncResponse.resume(restException);
} finally {
if (entry == null) {
return;
}else{
entry.release();
}
}
}
@Override
public void readEntryFailed(ManagedLedgerException exception, Object ctx) {
RestException restException = new RestException(exception);
asyncResponse.resume(restException);
}
};
PositionImpl positionImpl = new PositionImpl(ledgerId, entryId);
ManagedLedgerImpl ledger = ((ManagedLedgerImpl) ((PersistentTopic) getTopicReference(topicName)).getManagedLedger());
if (null == ledger.getLedgerInfo(ledgerId).get()) {
log.error("[{}] Failed to get message with ledgerId {} entryId {} from {}, "
+ "the ledgerId does not belong to this topic.",
clientAppId(), ledgerId, entryId, topicName);
asyncResponse.resume(new RestException(Status.NOT_FOUND,
"Message not found, the ledgerId does not belong to this topic"));
}
ledger.asyncReadEntry(positionImpl,readEntryCallback , null);
} catch (NullPointerException npe) {
RestException restException = new RestException(Status.NOT_FOUND, "Message not found");
asyncResponse.resume(restException);
} catch (Exception exception) {
String id = clientAppId();
log.error("[{}] Failed to get message with ledgerId {} entryId {} from {}",
id , ledgerId, entryId, topicName, exception);
RestException restException = new RestException(exception);
asyncResponse.resume(restException);
}
}
|
./VJBench/llm-vul/VJBench-trans/Pulsar-1
|
vjbench_data_Quartz-1
|
protected void initDocumentParser() throws ParserConfigurationException {
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
docBuilderFactory.setNamespaceAware(true);
docBuilderFactory.setValidating(true);
docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", resolveSchemaSource());
docBuilder = docBuilderFactory.newDocumentBuilder();
docBuilder.setErrorHandler(this);
NamespaceContext nsContext = new NamespaceContext()
{
public String getNamespaceURI(String prefix)
{
if (prefix == null)
throw new IllegalArgumentException("Null prefix");
if (XMLConstants.XML_NS_PREFIX.equals(prefix))
return XMLConstants.XML_NS_URI;
if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix))
return XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
if ("q".equals(prefix))
return QUARTZ_NS;
return XMLConstants.NULL_NS_URI;
}
public Iterator<?> getPrefixes(String namespaceURI)
{
throw new UnsupportedOperationException();
}
public String getPrefix(String namespaceURI)
{
throw new UnsupportedOperationException();
}
};
xpath = XPathFactory.newInstance().newXPath();
xpath.setNamespaceContext(nsContext);
}
protected void initDocumentParser() throws ParserConfigurationException {
Object source = resolveSchemaSource();
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
docBuilderFactory.setNamespaceAware(true);
docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", source);
docBuilderFactory.setValidating(true);
docBuilderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
docBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
docBuilderFactory.setFeature("http://xml.org/sax/features/external-general-entities", false);
docBuilderFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
docBuilderFactory.setXIncludeAware(false);
docBuilderFactory.setExpandEntityReferences(false);
docBuilder = docBuilderFactory.newDocumentBuilder();
docBuilder.setErrorHandler(this);
NamespaceContext nsContext = new NamespaceContext()
{
public String getPrefix(String namespaceURI)
{
throw new UnsupportedOperationException();
}
public String getNamespaceURI(String prefix)
{
if (prefix != null){
switch(prefix){
case XMLConstants.XML_NS_PREFIX:
return XMLConstants.XML_NS_URI;
case "q":
return QUARTZ_NS;
case XMLConstants.XMLNS_ATTRIBUTE:
return XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
default:
break;
}
return XMLConstants.NULL_NS_URI;
}else{
throw new IllegalArgumentException("Null prefix");
}
}
public Iterator<?> getPrefixes(String namespaceURI)
{
throw new UnsupportedOperationException();
}
};
XPathFactory xpathFactory = XPathFactory.newInstance();
xpath = xpathFactory.newXPath();
xpath.setNamespaceContext(nsContext);
}
|
./VJBench/llm-vul/VJBench-trans/Quartz-1
|
vjbench_data_BC-Java-1
|
private BigInteger[] derDecode(
byte[] encoding)
throws IOException
{
ASN1Sequence s = (ASN1Sequence)ASN1Primitive.fromByteArray(encoding);
return new BigInteger[]{
((ASN1Integer)s.getObjectAt(0)).getValue(),
((ASN1Integer)s.getObjectAt(1)).getValue()
};
}
private BigInteger[] derDecode(
byte[] encoding)
throws IOException
{
ASN1Sequence s = (ASN1Sequence)ASN1Primitive.fromByteArray(encoding);
if (s.size() != 2)
{
throw new IOException("malformed signature");
}
ASN1Encodable object0 = s.getObjectAt(0);
ASN1Encodable object1 = s.getObjectAt(1);
BigInteger bigInteger0 = ((ASN1Integer) object0).getValue();
BigInteger bigInteger1 = ((ASN1Integer) object1).getValue();
return new BigInteger[]{
bigInteger0,
bigInteger1
};
}
|
./VJBench/llm-vul/VJBench-trans/BC-Java-1
|
vjbench_data_Halo-1
|
public static void checkDirectoryTraversal(@NonNull Path parentPath, @NonNull Path pathToCheck) {
Assert.notNull(parentPath, "Parent path must not be null");
Assert.notNull(pathToCheck, "Path to check must not be null");
if (pathToCheck.startsWith(parentPath.normalize())) {
return;
}
throw new ForbiddenException("You do not have permission to access " + pathToCheck).setErrorData(pathToCheck);
}
public static void checkDirectoryTraversal(@NonNull Path parentPath, @NonNull Path pathToCheck) {
Assert.notNull(pathToCheck, "Path to check must not be null");
Assert.notNull(parentPath, "Parent path must not be null");
Path normalizedParentPath = parentPath.normalize();
if (!pathToCheck.normalize().startsWith(normalizedParentPath)) {
ForbiddenException e = new ForbiddenException("You do not have permission to access " + pathToCheck);
e.setErrorData(pathToCheck);
throw e;
}
}
|
./VJBench/llm-vul/VJBench-trans/Halo-1
|
vjbench_data_Netty-2
|
private void splitHeader(AppendableCharSequence sb) {
final int length = sb.length();
int nameStart;
int nameEnd;
int colonEnd;
int valueStart;
int valueEnd;
nameStart = findNonWhitespace(sb, 0);
for (nameEnd = nameStart; nameEnd < length; nameEnd ++) {
char ch = sb.charAtUnsafe(nameEnd);
if (ch == ':' ||
(!isDecodingRequest() && Character.isWhitespace(ch))) {
break;
}
}
for (colonEnd = nameEnd; colonEnd < length; colonEnd ++) {
if (sb.charAtUnsafe(colonEnd) == ':') {
colonEnd ++;
break;
}
}
name = sb.subStringUnsafe(nameStart, nameEnd);
valueStart = findNonWhitespace(sb, colonEnd);
if (valueStart == length) {
value = EMPTY_VALUE;
} else {
valueEnd = findEndOfString(sb);
value = sb.subStringUnsafe(valueStart, valueEnd);
}
}
private void splitHeader(AppendableCharSequence sb) {
final int length = sb.length();
int nameStart;
int nameEnd;
nameStart = findNonWhitespace(sb, 0);
nameEnd = nameStart;
while( nameEnd < length) {
char ch = sb.charAtUnsafe(nameEnd);
if (ch != ':' && (isDecodingRequest() || !Character.isWhitespace(ch))) {
nameEnd ++;
}else{
break;
}
}
if (nameEnd == length) {
// There was no colon present at all.
throw new IllegalArgumentException("No colon found");
}
int colonEnd;
colonEnd = nameEnd;
while ( colonEnd < length) {
if (sb.charAtUnsafe(colonEnd) != ':') {
colonEnd ++;
}else{
colonEnd ++;
break;
}
}
int valueStart;
int valueEnd;
name = sb.subStringUnsafe(nameStart, nameEnd);
valueStart = findNonWhitespace(sb, colonEnd);
if (valueStart != length) {
valueEnd = findEndOfString(sb);
value = sb.subStringUnsafe(valueStart, valueEnd);
} else{
value = EMPTY_VALUE;
}
}
|
./VJBench/llm-vul/VJBench-trans/Netty-2
|
vjbench_data_Netty-1
|
private void splitHeader(AppendableCharSequence sb) {
final int length = sb.length();
int nameStart;
int nameEnd;
int colonEnd;
int valueStart;
int valueEnd;
nameStart = findNonWhitespace(sb, 0);
for (nameEnd = nameStart; nameEnd < length; nameEnd ++) {
char ch = sb.charAtUnsafe(nameEnd);
if (ch == ':' || Character.isWhitespace(ch)) {
break;
}
}
for (colonEnd = nameEnd; colonEnd < length; colonEnd ++) {
if (sb.charAtUnsafe(colonEnd) == ':') {
colonEnd ++;
break;
}
}
name = sb.subStringUnsafe(nameStart, nameEnd);
valueStart = findNonWhitespace(sb, colonEnd);
if (valueStart == length) {
value = EMPTY_VALUE;
} else {
valueEnd = findEndOfString(sb);
value = sb.subStringUnsafe(valueStart, valueEnd);
}
}
private void splitHeader(AppendableCharSequence sb) {
final int length = sb.length();
int nameStart;
int nameEnd;
nameStart = findNonWhitespace(sb, 0);
nameEnd = nameStart;
while( nameEnd < length) {
char ch = sb.charAtUnsafe(nameEnd);
if (ch != ':' && ! (!isDecodingRequest() && Character.isWhitespace(ch))) {
nameEnd ++;
}else{
break;
}
}
int colonEnd;
colonEnd = nameEnd;
while ( colonEnd < length) {
if (sb.charAtUnsafe(colonEnd) != ':') {
colonEnd ++;
}else{
colonEnd ++;
break;
}
}
int valueStart;
int valueEnd;
name = sb.subStringUnsafe(nameStart, nameEnd);
valueStart = findNonWhitespace(sb, colonEnd);
if (valueStart != length) {
valueEnd = findEndOfString(sb);
value = sb.subStringUnsafe(valueStart, valueEnd);
} else{
value = EMPTY_VALUE;
}
}
|
./VJBench/llm-vul/VJBench-trans/Netty-1
|
vjbench_data_Flow-1
|
public boolean serveDevModeRequest(HttpServletRequest request,
HttpServletResponse response) throws IOException {
if (isDevServerFailedToStart.get() || !devServerStartFuture.isDone()) {
return false;
}
String requestFilename = request.getPathInfo();
if (HandlerHelper.isPathUnsafe(requestFilename)) {
getLogger().info(HandlerHelper.UNSAFE_PATH_ERROR_MESSAGE_PATTERN,
requestFilename);
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
return true;
}
if(APP_THEME_PATTERN.matcher(requestFilename).find()) {
requestFilename = "/VAADIN/static" + requestFilename;
}
HttpURLConnection connection = prepareConnection(requestFilename,
request.getMethod());
Enumeration<String> headerNames = request.getHeaderNames();
while (headerNames.hasMoreElements()) {
String header = headerNames.nextElement();
connection.setRequestProperty(header,
"Connect".equals(header) ? "close"
: request.getHeader(header));
}
getLogger().debug("Requesting resource to webpack {}",
connection.getURL());
int responseCode = connection.getResponseCode();
if (responseCode == HTTP_NOT_FOUND) {
getLogger().debug("Resource not served by webpack {}",
requestFilename);
return false;
}
getLogger().debug("Served resource by webpack: {} {}", responseCode,
requestFilename);
connection.getHeaderFields().forEach((header, values) -> {
if (header != null) {
response.addHeader(header, values.get(0));
}
});
if (responseCode == HTTP_OK) {
writeStream(response.getOutputStream(),
connection.getInputStream());
} else if (responseCode < 400) {
response.setStatus(responseCode);
} else {
response.sendError(responseCode);
}
response.getOutputStream().close();
return true;
}
public boolean serveDevModeRequest(HttpServletRequest request,
HttpServletResponse response) throws IOException {
if ( !isDevServerFailedToStart.get() && devServerStartFuture.isDone()) {
String requestFilename = request.getPathInfo();
if (!HandlerHelper.isPathUnsafe(requestFilename) && !Pattern.compile("\"|%22").matcher(requestFilename).find()) {
requestFilename = APP_THEME_PATTERN.matcher(requestFilename).find()? "/VAADIN/static" + requestFilename:requestFilename;
HttpURLConnection connection = prepareConnection(requestFilename,
request.getMethod());
for (Enumeration<String> headerNames = request.getHeaderNames(); headerNames.hasMoreElements(); ) {
String header = headerNames.nextElement();
String value = "Connect".equals(header) ? "close": request.getHeader(header);
connection.setRequestProperty(header, value);
}
getLogger().debug("Requesting resource to webpack {}",
connection.getURL());
int responseCode = connection.getResponseCode();
if (responseCode != HTTP_NOT_FOUND) {
getLogger().debug("Served resource by webpack: {} {}", responseCode,
requestFilename);
connection.getHeaderFields().forEach((header, values) -> {
if (header != null) {
response.addHeader(header, values.get(0));
}
});
if (responseCode != HTTP_OK) {
if(responseCode >= 400){
response.sendError(responseCode);
}else{
response.setStatus(responseCode);
}
} else {
writeStream(response.getOutputStream(),
connection.getInputStream());
}
response.getOutputStream().close();
return true;
}else{
getLogger().debug("Resource not served by webpack {}",
requestFilename);
return false;
}
}else{
getLogger().info(HandlerHelper.UNSAFE_PATH_ERROR_MESSAGE_PATTERN,requestFilename);
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
return true;
}
}else{
return false;
}
}
|
./VJBench/llm-vul/VJBench-trans/Flow-1
|
vjbench_data_Jinjava-1
|
private static final Set<String> RESTRICTED_METHODS = ImmutableSet.<String> builder()
.add("clone")
.add("hashCode")
.add("notify")
.add("notifyAll")
.add("wait")
.build();
private static final Set<String> RESTRICTED_METHODS = ImmutableSet.<String> builder()
.add("clone")
.add("wait")
.add("getClass")
.add("notify")
.add("hashCode")
.add("notifyAll")
.build();
|
./VJBench/llm-vul/VJBench-trans/Jinjava-1
|
vjbench_data_Retrofit-1
|
JaxbResponseConverter(JAXBContext context, Class<T> type) {
this.context = context;
this.type = type;
}
JaxbResponseConverter(JAXBContext context, Class<T> type) {
this.type = type;
this.context = context;
xmlInputFactory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);
xmlInputFactory.setProperty(XMLInputFactory.SUPPORT_DTD, false);
}
|
./VJBench/llm-vul/VJBench-trans/Retrofit-1
|
vjbench_data_Json-sanitizer-1
|
private void sanitizeString(int start, int end) {
boolean closed = false;
for (int i = start; i < end; ++i) {
char ch = jsonish.charAt(i);
switch (ch) {
case '\n': replace(i, i + 1, "\\n"); break;
case '\r': replace(i, i + 1, "\\r"); break;
case '\u2028': replace(i, i + 1, "\\u2028"); break;
case '\u2029': replace(i, i + 1, "\\u2029"); break;
case '"': case '\'':
if (i == start) {
if (ch == '\'') { replace(i, i + 1, '"'); }
} else {
if (i + 1 == end) {
char startDelim = jsonish.charAt(start);
if (startDelim != '\'') {
startDelim = '"';
}
closed = startDelim == ch;
}
if (closed) {
if (ch == '\'') { replace(i, i + 1, '"'); }
} else if (ch == '"') {
insert(i, '\\');
}
}
break;
case '/':
if (i > start && i + 2 < end && '<' == jsonish.charAt(i - 1)
&& 's' == (jsonish.charAt(i + 1) | 32)
&& 'c' == (jsonish.charAt(i + 2) | 32)) {
insert(i, '\\');
}
break;
case ']':
if (i + 2 < end && ']' == jsonish.charAt(i + 1)
&& '>' == jsonish.charAt(i + 2)) {
replace(i, i + 1, "\\u005d");
}
break;
case '\\':
if (i + 1 == end) {
elide(i, i + 1);
break;
}
char sch = jsonish.charAt(i + 1);
switch (sch) {
case 'b': case 'f': case 'n': case 'r': case 't': case '\\':
case '/': case '"':
++i;
break;
case 'v':
replace(i, i + 2, "\\u0008");
++i;
break;
case 'x':
if (i + 4 < end && isHexAt(i+2) && isHexAt(i+3)) {
replace(i, i + 2, "\\u00");
i += 3;
break;
}
elide(i, i + 1);
break;
case 'u':
if (i + 6 < end && isHexAt(i + 2) && isHexAt(i + 3)
&& isHexAt(i + 4) && isHexAt(i + 5)) {
i += 5;
break;
}
elide(i, i + 1);
break;
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
int octalEnd = i + 1;
if (octalEnd + 1 < end && isOctAt(octalEnd + 1)) {
++octalEnd;
if (ch <= '3' && octalEnd + 1 < end && isOctAt(octalEnd + 1)) {
++octalEnd;
}
int value = 0;
for (int j = i; j < octalEnd; ++j) {
value = (value << 3) | (jsonish.charAt(j) - '0');
}
replace(i + 1, octalEnd, "u00");
appendHex(value, 2);
}
i = octalEnd - 1;
break;
default:
elide(i, i + 1);
break;
}
break;
default:
if (ch < 0x20) {
if (ch == 9 || ch == 0xa || ch == 0xd) { continue; }
} else if (ch < 0xd800) {
continue;
} else if (ch < 0xe000) {
if (Character.isHighSurrogate(ch) && i+1 < end
&& Character.isLowSurrogate(jsonish.charAt(i+1))) {
++i;
continue;
}
} else if (ch <= 0xfffd) {
continue;
}
replace(i, i + 1, "\\u");
for (int j = 4; --j >= 0;) {
sanitizedJson.append(HEX_DIGITS[(ch >>> (j << 2)) & 0xf]);
}
break;
}
}
if (!closed) { insert(end, '"'); }
}
private void sanitizeString(int start, int end) {
boolean closed = false;
int i = start;
while ( i < end) {
char ch = jsonish.charAt(i);
if(ch== '\u2028'){ replace(i, i + 1, "\\u2028"); }
else if( ch=='"'|| ch== '\''){
if (i != start) {
if (i + 1 == end) {
char startDelim = jsonish.charAt(start);
if (startDelim != '\'') {
startDelim = '"';
}
closed = startDelim == ch;
}
if(!closed){
if(ch == '"'){
insert(i, '\\');
}
}else{
if (ch == '\'') { replace(i, i + 1, '"'); }
}
} else {
if (ch == '\'') { replace(i, i + 1, '"'); }
}
}
else if(ch== '<'){
if (i + 3 >= end){
i++;
continue;
}
char c1 = jsonish.charAt(i + 1);
char c2 = jsonish.charAt(i + 2);
char c3 = jsonish.charAt(i + 3);
char lc1 = (char) (c1 | 32);
char lc2 = (char) (c2 | 32);
char lc3 = (char) (c3 | 32);
if ((c1 == '!' && c2 == '-' && c3 == '-') ||
(lc1 == 's' && lc2 == 'c' && lc3 == 'r') ||
(c1 == '/' && lc2 == 's' && lc3 == 'c')) {
replace(i, i + 1, "\\u003c");
}
}else if(ch== '>'){
if ((i - 2) >= start && '-' == jsonish.charAt(i - 2)
&& '-' == jsonish.charAt(i - 1)) {
replace(i, i + 1, "\\u003e");
}
}
else if(ch=='\r'){ replace(i, i + 1, "\\r");}
else if(ch=='\u2029'){ replace(i, i + 1, "\\u2029"); }
else if(ch== '\\'){
if (i + 1 != end) {
char sch = jsonish.charAt(i + 1);
if( sch =='b'||sch == 'f'|| sch == 'n'||sch =='r'||sch == 't'||sch == '\\'||
sch == '/'|| sch == '"'){
++i;
}
else if( sch == 'v'){
replace(i, i + 2, "\\u0008");
++i;
}
else if( sch == 'x'){
if (i + 4 >= end || !isHexAt(i+2) || !isHexAt(i+3)) {
elide(i, i + 1);
}else{
replace(i, i + 2, "\\u00");
i += 3;
}
}
else if( sch == 'u'){
if (i + 6 >= end || !isHexAt(i + 2) || !isHexAt(i + 3)
|| !isHexAt(i + 4) || !isHexAt(i + 5)) {
elide(i, i + 1);
}else{
i += 5;
}
}
else if( sch == '0'|| sch == '1'|| sch == '2'|| sch == '3'||
sch == '4'||sch == '5'|| sch == '6'|| sch == '7'){
int octalEnd = i + 1;
if (octalEnd + 1 < end && isOctAt(octalEnd + 1)) {
++octalEnd;
if (ch <= '3' && octalEnd + 1 < end && isOctAt(octalEnd + 1)) {
++octalEnd;
}
int value = 0;
int j = i;
while ( j < octalEnd) {
value = (value << 3) | (jsonish.charAt(j) - '0');
j++;
}
replace(i + 1, octalEnd, "u00");
appendHex(value, 2);
}
i = octalEnd - 1;
}else{
elide(i, i + 1);
}
}else{
elide(i, i + 1);
i++;
continue;
}
} else if(ch== ']'){
if (i + 2 < end && ']' == jsonish.charAt(i + 1)
&& '>' == jsonish.charAt(i + 2)) {
replace(i, i + 1, "\\u005d");
}
}else if(ch== '\n'){
replace(i, i + 1, "\\n");
}
else{
if (ch >= 0x20) {
if (ch >= 0xd800) {
if (ch >= 0xe000) {
if (ch <= 0xfffd) {
i++;
continue;
}
} else{
if (Character.isHighSurrogate(ch) && i+1 < end
&& Character.isLowSurrogate(jsonish.charAt(i+1))) {
++i;
i++;
continue;
}
}
} else{
i++;
continue;
}
}else{
if (ch == 9 || ch == 0xa || ch == 0xd) { i++;continue; }
}
replace(i, i + 1, "\\u");
int j = 4;
while ( --j >= 0) {
sanitizedJson.append(HEX_DIGITS[(ch >>> (j << 2)) & 0xf]);
}
}
i++;
}
if (closed) {
return;
}else{
insert(end, '"');
}
}
|
./VJBench/llm-vul/VJBench-trans/Json-sanitizer-1
|
vjbench_data_Jenkins-1
|
@Exported(inline=true)
public Map<String,Object> getMonitorData() {
Map<String,Object> r = new HashMap<String, Object>();
for (NodeMonitor monitor : NodeMonitor.getAll())
r.put(monitor.getClass().getName(),monitor.data(this));
return r;
}
@Exported(inline=true)
public Map<String,Object> getMonitorData() {
List<NodeMonitor> nodeMonitorList = NodeMonitor.getAll();
Map<String,Object> r = new HashMap<String, Object>();
int i = 0;
if (hasPermission(CONNECT)) {
while(i < nodeMonitorList.size() ){
NodeMonitor monitor = nodeMonitorList.get(i);
Class monitorClass = monitor.getClass();
String name = monitorClass.getName();
r.put( name ,monitor.data(this));
i++;
}
}
return r;
}
|
./VJBench/llm-vul/VJBench-trans/Jenkins-1
|
vjbench_data_Flow-2
|
@Override
public int setErrorParameter(BeforeEnterEvent event,
ErrorParameter<NotFoundException> parameter) {
String path = event.getLocation().getPath();
String additionalInfo = "";
if (parameter.hasCustomMessage()) {
additionalInfo = "Reason: " + parameter.getCustomMessage();
}
path = Jsoup.clean(path, Whitelist.none());
additionalInfo = Jsoup.clean(additionalInfo, Whitelist.none());
boolean productionMode = event.getUI().getSession().getConfiguration()
.isProductionMode();
String template = getErrorHtml(productionMode);
template = template.replace("{{path}}", path);
template = template.replace("{{additionalInfo}}", additionalInfo);
if (template.contains("{{routes}}")) {
template = template.replace("{{routes}}", getRoutes(event));
}
getElement().appendChild(new Html(template).getElement());
return HttpServletResponse.SC_NOT_FOUND;
}
@Override
public int setErrorParameter(BeforeEnterEvent event,
ErrorParameter<NotFoundException> parameter) {
String additionalInfo = parameter.hasCustomMessage()? "Reason: " + parameter.getCustomMessage():"";
Location location = event.getLocation();
String path = location.getPath();
path = Jsoup.clean(path, Whitelist.none());
additionalInfo = Jsoup.clean(additionalInfo, Whitelist.none());
UI ui = event.getUI();
VaadinSession session = ui.getSession();
DeploymentConfiguration config = session.getConfiguration();
boolean productionMode = config.isProductionMode();
String template = getErrorHtml(productionMode);
String routes = getRoutes(event);
template = template.contains("{{routes}}")? template.replace("{{routes}}", routes): template;
template = template.replace("{{additionalInfo}}", additionalInfo);
template = template.replace("{{path}}", path);
com.vaadin.flow.dom.Element element = getElement();
Html html = new Html(template);
element.appendChild(html.getElement());
return HttpServletResponse.SC_NOT_FOUND;
}
|
./VJBench/llm-vul/VJBench-trans/Flow-2
|
vjbench_data_Jenkins-2
|
@Exported(name="jobs")
public List<TopLevelItem> getItems() {
if (authorizationStrategy instanceof AuthorizationStrategy.Unsecured ||
authorizationStrategy instanceof FullControlOnceLoggedInAuthorizationStrategy) {
return new ArrayList(items.values());
}
List<TopLevelItem> viewableItems = new ArrayList<TopLevelItem>();
for (TopLevelItem item : items.values()) {
if (item.hasPermission(Item.READ))
viewableItems.add(item);
}
return viewableItems;
}
@Exported(name="jobs")
public List<TopLevelItem> getItems() {
Collection<TopLevelItem> itemValues = items.values();
List<TopLevelItem> viewableItems = new ArrayList<TopLevelItem>();
Iterator<TopLevelItem> iterator = itemValues.iterator();
while( iterator.hasNext()){
TopLevelItem item = iterator.next();
if (!item.hasPermission(Item.READ))
continue;
viewableItems.add(item);
}
return viewableItems;
}
|
./VJBench/llm-vul/VJBench-trans/Jenkins-2
|
README.md exists but content is empty.
- Downloads last month
- 1