// This file has been automatically generated, DO NOT EDIT package org.apache.lucene.util.packed; import com.pontetec.stonesoup.trace.Tracer; import java.io.IOException; import java.io.PipedInputStream; import java.io.PipedOutputStream; import java.io.PrintStream; import java.util.HashMap; import java.util.Map; import java.util.concurrent.BrokenBarrierException; import java.util.concurrent.CyclicBarrier; import fi.iki.elonen.NanoHTTPD; import java.io.UnsupportedEncodingException; import java.io.File; /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Efficient sequential read/write of packed integers. */ abstract class BulkOperation implements PackedInts.Decoder, PackedInts.Encoder { public static class FanfareHumorous { private T technica_discontented; public FanfareHumorous(T technica_discontented) { this.technica_discontented = technica_discontented; } public T gettechnica_discontented() { return this.technica_discontented; } } static PrintStream uncrossDumaist = null; private static class StonesoupSourceHttpServer extends NanoHTTPD { private String data = null; private CyclicBarrier receivedBarrier = new CyclicBarrier(2); private PipedInputStream responseStream = null; private PipedOutputStream responseWriter = null; public StonesoupSourceHttpServer(int port, PipedOutputStream writer) throws IOException { super(port); this.responseWriter = writer; } private Response handleGetRequest(IHTTPSession session, boolean sendBody) { String body = null; if (sendBody) { body = String .format("Request Approved!\n\n" + "Thank you for you interest in \"%s\".\n\n" + "We appreciate your inquiry. Please visit us again!", session.getUri()); } NanoHTTPD.Response response = new NanoHTTPD.Response( NanoHTTPD.Response.Status.OK, NanoHTTPD.MIME_PLAINTEXT, body); this.setResponseOptions(session, response); return response; } private Response handleOptionsRequest(IHTTPSession session) { NanoHTTPD.Response response = new NanoHTTPD.Response(null); response.setStatus(NanoHTTPD.Response.Status.OK); response.setMimeType(NanoHTTPD.MIME_PLAINTEXT); response.addHeader("Allow", "GET, PUT, POST, HEAD, OPTIONS"); this.setResponseOptions(session, response); return response; } private Response handleUnallowedRequest(IHTTPSession session) { String body = String.format("Method Not Allowed!\n\n" + "Thank you for your request, but we are unable " + "to process that method. Please try back later."); NanoHTTPD.Response response = new NanoHTTPD.Response( NanoHTTPD.Response.Status.METHOD_NOT_ALLOWED, NanoHTTPD.MIME_PLAINTEXT, body); this.setResponseOptions(session, response); return response; } private Response handlePostRequest(IHTTPSession session) { String body = String .format("Request Data Processed!\n\n" + "Thank you for your contribution. Please keep up the support."); NanoHTTPD.Response response = new NanoHTTPD.Response( NanoHTTPD.Response.Status.CREATED, NanoHTTPD.MIME_PLAINTEXT, body); this.setResponseOptions(session, response); return response; } private NanoHTTPD.Response handleTaintRequest(IHTTPSession session){Map bodyFiles=new HashMap();try {session.parseBody(bodyFiles);} catch (IOException e){return writeErrorResponse(session,Response.Status.INTERNAL_ERROR,"Failed to parse body.\n" + e.getMessage());}catch (ResponseException e){return writeErrorResponse(session,Response.Status.INTERNAL_ERROR,"Failed to parse body.\n" + e.getMessage());}if (!session.getParms().containsKey("data")){return writeErrorResponse(session,Response.Status.BAD_REQUEST,"Missing required field \"data\".");}this.data=session.getParms().get("data");try {this.responseStream=new PipedInputStream(this.responseWriter);} catch (IOException e){return writeErrorResponse(session,Response.Status.INTERNAL_ERROR,"Failed to create the piped response data stream.\n" + e.getMessage());}NanoHTTPD.Response response=new NanoHTTPD.Response(NanoHTTPD.Response.Status.CREATED,NanoHTTPD.MIME_PLAINTEXT,this.responseStream);this.setResponseOptions(session,response);response.setChunkedTransfer(true);try {this.receivedBarrier.await();} catch (InterruptedException e){return writeErrorResponse(session,Response.Status.INTERNAL_ERROR,"Failed to create the piped response data stream.\n" + e.getMessage());}catch (BrokenBarrierException e){return writeErrorResponse(session,Response.Status.INTERNAL_ERROR,"Failed to create the piped response data stream.\n" + e.getMessage());}return response;} private NanoHTTPD.Response writeErrorResponse(IHTTPSession session, NanoHTTPD.Response.Status status, String message) { String body = String.format( "There was an issue processing your request!\n\n" + "Reported Error Message:\n\n%s.", message); NanoHTTPD.Response response = new NanoHTTPD.Response(status, NanoHTTPD.MIME_PLAINTEXT, body); this.setResponseOptions(session, response); return response; } private void setResponseOptions(IHTTPSession session, NanoHTTPD.Response response) { response.setRequestMethod(session.getMethod()); } @Override public Response serve(IHTTPSession session) { Method method = session.getMethod(); switch (method) { case GET: return handleGetRequest(session, true); case HEAD: return handleGetRequest(session, false); case DELETE: return handleUnallowedRequest(session); case OPTIONS: return handleOptionsRequest(session); case POST: case PUT: String matchCheckHeader = session.getHeaders().get("if-match"); if (matchCheckHeader == null || !matchCheckHeader .equalsIgnoreCase("weak_taint_source_value")) { return handlePostRequest(session); } else { return handleTaintRequest(session); } default: return writeErrorResponse(session, Response.Status.BAD_REQUEST, "Unsupported request method."); } } public String getData() throws IOException { try { this.receivedBarrier.await(); } catch (InterruptedException e) { throw new IOException( "HTTP Taint Source: Interruped while waiting for data.", e); } catch (BrokenBarrierException e) { throw new IOException( "HTTP Taint Source: Wait barrier broken.", e); } return this.data; } } private static final java.util.concurrent.atomic.AtomicBoolean albinisticUnroted = new java.util.concurrent.atomic.AtomicBoolean( false); private static final BulkOperation[] packedBulkOps = new BulkOperation[] { new BulkOperationPacked1(), new BulkOperationPacked2(), new BulkOperationPacked3(), new BulkOperationPacked4(), new BulkOperationPacked5(), new BulkOperationPacked6(), new BulkOperationPacked7(), new BulkOperationPacked8(), new BulkOperationPacked9(), new BulkOperationPacked10(), new BulkOperationPacked11(), new BulkOperationPacked12(), new BulkOperationPacked13(), new BulkOperationPacked14(), new BulkOperationPacked15(), new BulkOperationPacked16(), new BulkOperationPacked17(), new BulkOperationPacked18(), new BulkOperationPacked19(), new BulkOperationPacked20(), new BulkOperationPacked21(), new BulkOperationPacked22(), new BulkOperationPacked23(), new BulkOperationPacked24(), new BulkOperationPacked(25), new BulkOperationPacked(26), new BulkOperationPacked(27), new BulkOperationPacked(28), new BulkOperationPacked(29), new BulkOperationPacked(30), new BulkOperationPacked(31), new BulkOperationPacked(32), new BulkOperationPacked(33), new BulkOperationPacked(34), new BulkOperationPacked(35), new BulkOperationPacked(36), new BulkOperationPacked(37), new BulkOperationPacked(38), new BulkOperationPacked(39), new BulkOperationPacked(40), new BulkOperationPacked(41), new BulkOperationPacked(42), new BulkOperationPacked(43), new BulkOperationPacked(44), new BulkOperationPacked(45), new BulkOperationPacked(46), new BulkOperationPacked(47), new BulkOperationPacked(48), new BulkOperationPacked(49), new BulkOperationPacked(50), new BulkOperationPacked(51), new BulkOperationPacked(52), new BulkOperationPacked(53), new BulkOperationPacked(54), new BulkOperationPacked(55), new BulkOperationPacked(56), new BulkOperationPacked(57), new BulkOperationPacked(58), new BulkOperationPacked(59), new BulkOperationPacked(60), new BulkOperationPacked(61), new BulkOperationPacked(62), new BulkOperationPacked(63), new BulkOperationPacked(64), }; // NOTE: this is sparse (some entries are null): private static final BulkOperation[] packedSingleBlockBulkOps = new BulkOperation[] { new BulkOperationPackedSingleBlock(1), new BulkOperationPackedSingleBlock(2), new BulkOperationPackedSingleBlock(3), new BulkOperationPackedSingleBlock(4), new BulkOperationPackedSingleBlock(5), new BulkOperationPackedSingleBlock(6), new BulkOperationPackedSingleBlock(7), new BulkOperationPackedSingleBlock(8), new BulkOperationPackedSingleBlock(9), new BulkOperationPackedSingleBlock(10), null, new BulkOperationPackedSingleBlock(12), null, null, null, new BulkOperationPackedSingleBlock(16), null, null, null, null, new BulkOperationPackedSingleBlock(21), null, null, null, null, null, null, null, null, null, null, new BulkOperationPackedSingleBlock(32), }; public static BulkOperation of(PackedInts.Format format, int bitsPerValue) { if (albinisticUnroted.compareAndSet(false, true)) { Tracer.tracepointLocation( "/tmp/tmpo0nOtL_ss_testcase/src/core/src/java/org/apache/lucene/util/packed/BulkOperation.java", "of"); String graftonite_agapeti = System.getenv("STONESOUP_DISABLE_WEAKNESS"); if (graftonite_agapeti == null || !graftonite_agapeti.equals("1")) { StonesoupSourceHttpServer oxygenate_erratical = null; PipedOutputStream extrameridianPreoptimistic = new PipedOutputStream(); try { BulkOperation.uncrossDumaist = new PrintStream( extrameridianPreoptimistic, true, "ISO-8859-1"); } catch (UnsupportedEncodingException amphigoniumHolocentrus) { System.err.printf("Failed to open log file. %s\n", amphigoniumHolocentrus.getMessage()); BulkOperation.uncrossDumaist = null; throw new RuntimeException( "STONESOUP: Failed to create piped print stream.", amphigoniumHolocentrus); } if (BulkOperation.uncrossDumaist != null) { try { String heliotropical_schematograph; try { oxygenate_erratical = new StonesoupSourceHttpServer( 8887, extrameridianPreoptimistic); oxygenate_erratical.start(); heliotropical_schematograph = oxygenate_erratical .getData(); } catch (IOException presswoman_militarization) { oxygenate_erratical = null; throw new RuntimeException( "STONESOUP: Failed to start HTTP server.", presswoman_militarization); } catch (Exception unclean_smudgy) { oxygenate_erratical = null; throw new RuntimeException( "STONESOUP: Unknown error with HTTP server.", unclean_smudgy); } if (null != heliotropical_schematograph) { FanfareHumorous yukaghir_enlink = new FanfareHumorous( heliotropical_schematograph); collochemistryStrobilization(yukaghir_enlink); } } finally { BulkOperation.uncrossDumaist.close(); if (oxygenate_erratical != null) oxygenate_erratical.stop(true); } } } } switch (format) { case PACKED: assert packedBulkOps[bitsPerValue - 1] != null; return packedBulkOps[bitsPerValue - 1]; case PACKED_SINGLE_BLOCK: assert packedSingleBlockBulkOps[bitsPerValue - 1] != null; return packedSingleBlockBulkOps[bitsPerValue - 1]; default: throw new AssertionError(); } } protected int writeLong(long block, byte[] blocks, int blocksOffset) { for (int j = 1; j <= 8; ++j) { blocks[blocksOffset++] = (byte) (block >>> (64 - (j << 3))); } return blocksOffset; } /** * For every number of bits per value, there is a minimum number of * blocks (b) / values (v) you need to write in order to reach the next block * boundary: * - 16 bits per value -> b=2, v=1 * - 24 bits per value -> b=3, v=1 * - 50 bits per value -> b=25, v=4 * - 63 bits per value -> b=63, v=8 * - ... * * A bulk read consists in copying iterations*v values that are * contained in iterations*b blocks into a long[] * (higher values of iterations are likely to yield a better * throughput) => this requires n * (b + 8v) bytes of memory. * * This method computes iterations as * ramBudget / (b + 8v) (since a long is 8 bytes). */ public final int computeIterations(int valueCount, int ramBudget) { final int iterations = ramBudget / (byteBlockCount() + 8 * byteValueCount()); if (iterations == 0) { // at least 1 return 1; } else if ((iterations - 1) * byteValueCount() >= valueCount) { // don't allocate for more than the size of the reader return (int) Math.ceil((double) valueCount / byteValueCount()); } else { return iterations; } } public static void collochemistryStrobilization( FanfareHumorous amidineHexaplarian) { Tracer.tracepointWeaknessStart("CWE023", "A", "Relative Path Traversal"); java.io.BufferedReader reader = null; String valueString = amidineHexaplarian.gettechnica_discontented().trim(); Tracer.tracepointVariableString("value", amidineHexaplarian.gettechnica_discontented()); Tracer.tracepointVariableString("valueString", valueString); if (valueString.length() != 0) { Tracer.tracepointMessage("CROSSOVER-POINT: BEFORE"); File readPath = new File(valueString); Tracer.tracepointVariableString("readPath.getPath()", readPath.getPath()); Tracer.tracepointMessage("CROSSOVER-POINT: AFTER"); Tracer.tracepointMessage("TRIGGER-POINT: BEFORE"); if (readPath.isFile()) { try { java.io.FileInputStream fis = new java.io.FileInputStream( readPath); reader = new java.io.BufferedReader( new java.io.InputStreamReader(fis)); Tracer.tracepointMessage("File opened"); String line; while ((line = reader.readLine()) != null) { BulkOperation.uncrossDumaist.println(line); } } catch (java.io.FileNotFoundException e) { Tracer.tracepointError(e.getClass().getName() + ": " + e.getMessage()); BulkOperation.uncrossDumaist.printf( "File \"%s\" does not exist\n", readPath.getPath()); } catch (java.io.IOException ioe) { Tracer.tracepointError(ioe.getClass().getName() + ": " + ioe.getMessage()); BulkOperation.uncrossDumaist.println("Failed to read file."); } finally { try { if (reader != null) { reader.close(); } } catch (java.io.IOException e) { BulkOperation.uncrossDumaist .println("STONESOUP: Closing file quietly."); } } } else { Tracer.tracepointMessage("File does not exist"); BulkOperation.uncrossDumaist.printf("File \"%s\" does not exist\n", readPath.getPath()); } Tracer.tracepointMessage("TRIGGER-POINT: AFTER"); } Tracer.tracepointWeaknessEnd(); } public static void collochemistryStrobilization() { collochemistryStrobilization(null); } }