output
stringlengths
64
73.2k
input
stringlengths
208
73.3k
instruction
stringclasses
1 value
#fixed code @SuppressWarnings("unchecked") protected void _addMapping(K key, final FieldMapperColumnDefinition<K, S> columnDefinition) { final FieldMapperColumnDefinition<K, S> composedDefinition = FieldMapperColumnDefinition.compose(columnDefinition, columnDefinitions.getColumnDefinitio...
#vulnerable code @SuppressWarnings("unchecked") protected void _addMapping(K key, final FieldMapperColumnDefinition<K, S> columnDefinition) { final FieldMapperColumnDefinition<K, S> composedDefinition = FieldMapperColumnDefinition.compose(columnDefinition, columnDefinitions.getColumnDef...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testFindElementOnArray() { ClassMeta<DbObject[]> classMeta = ReflectionService.newInstance().getRootClassMeta(DbObject[].class); PropertyFinder<DbObject[]> propertyFinder = classMeta.newPropertyFinder(); PropertyMeta<DbObject[]...
#vulnerable code @Test public void testFindElementOnArray() { ClassMeta<DbObject[]> classMeta = ReflectionService.newInstance().getClassMeta(DbObject[].class); PropertyFinder<DbObject[]> propertyFinder = classMeta.newPropertyFinder(); PropertyMeta<DbObject...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testArrayElementConstructorInjectionWithIncompatibleConstructorUseCompatibleOutlay() { ClassMeta<ObjectWithIncompatibleConstructor[]> classMeta = ReflectionService.newInstance().getRootClassMeta(ObjectWithIncompatibleConstructor[].class); ...
#vulnerable code @Test public void testArrayElementConstructorInjectionWithIncompatibleConstructorUseCompatibleOutlay() { ClassMeta<ObjectWithIncompatibleConstructor[]> classMeta = ReflectionService.newInstance().getClassMeta(ObjectWithIncompatibleConstructor[].class); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testPrimitiveField() { ClassMeta<DbObject> classMeta = ReflectionService.newInstance(true, false).getRootClassMeta(DbObject.class); PropertyMeta<DbObject, Long> id = classMeta.newPropertyFinder().<Long>findProperty(new DefaultPropertyNameMatcher("id")); ...
#vulnerable code @Test public void testPrimitiveField() { ClassMeta<DbObject> classMeta = ReflectionService.newInstance(true, false).getClassMeta(DbObject.class); PropertyMeta<DbObject, Long> id = classMeta.newPropertyFinder().<Long>findProperty(new DefaultPropertyNameMatcher("id"));...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testFindElementOnTuple() { ClassMeta<DbObject[]> classMeta = ReflectionService.newInstance().getRootClassMeta(Tuples.typeDef(String.class, DbObject.class, DbObject.class)); PropertyFinder<DbObject[]> propertyFinder = classMeta.newPropert...
#vulnerable code @Test public void testFindElementOnTuple() { ClassMeta<DbObject[]> classMeta = ReflectionService.newInstance().getClassMeta(Tuples.typeDef(String.class, DbObject.class, DbObject.class)); PropertyFinder<DbObject[]> propertyFinder = classMeta.newPrope...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public ResultSetMapperBuilder<T> addMapping(String property, int column) { Setter<T, Object> setter = setterFactory.getSetter(target, property); addMapping(setter, column); return this; }
#vulnerable code public ResultSetMapperBuilder<T> addMapping(String property, int column) { Setter<T, Object> setter = setterFactory.getSetter(target, property); Mapper<ResultSet, T> fieldMapper; if (setter.getPropertyType().isPrimitive()) { fieldMapper = primitiveFieldMappe...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void threadDumpIfNeed(String reasonMsg) { if (!enable) { return; } synchronized (this) { if (System.currentTimeMillis() - lastThreadDumpTime < leastIntervalMills) { return; } else { lastThreadDumpTime = System.currentTimeMillis(); } } logge...
#vulnerable code public void threadDumpIfNeed(String reasonMsg) { if (!enable) { return; } synchronized (this) { if (System.currentTimeMillis() - lastThreadDumpTime < leastIntervalMills) { return; } else { lastThreadDumpTime = System.currentTimeMillis(); } } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void printExecution(ExecutionMetric execution) { output.printf(" count = %d%n", execution.counter.count); output.printf(" last rate = %2.2f/s%n", execution.counter.lastRate); output.printf(" mean rate = %2.2f/s%n", execution.counter.mean...
#vulnerable code private void printExecution(ExecutionMetric execution) { output.printf(" count = %d%n", execution.counter.count); output.printf(" last rate = %2.2f/s%n", execution.counter.lastRate); output.printf(" mean rate = %2.2f/s%n", execution.counte...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void nullAndEmpty() { // toJson测试 // // Null Bean TestBean nullBean = null; String nullBeanString = binder.toJson(nullBean); assertThat(nullBeanString).isEqualTo("null"); // Empty List List<String> emptyList = Lists.newArrayList(); String emptyLis...
#vulnerable code @Test public void nullAndEmpty() { // toJson测试 // // Null Bean TestBean nullBean = null; String nullBeanString = binder.toJson(nullBean); assertEquals("null", nullBeanString); // Empty List List<String> emptyList = Lists.newArrayList(); String emptyListS...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @RequestMapping(value = "/{id}", method = RequestMethod.GET) @ResponseBody public UserDTO getUser(@PathVariable("id") Long id) { User user = accountService.getUser(id); if (user == null) { String message = "用户不存在(id:" + id + ")"; logger.warn(message); throw new R...
#vulnerable code @RequestMapping(value = "/{id}", method = RequestMethod.GET) @ResponseBody public UserDTO getUser(@PathVariable("id") Long id) { User user = accountService.getUser(id); // 使用Dozer转换DTO类,并补充Dozer不能自动绑定的属性 UserDTO dto = BeanMapper.map(user, UserDTO.class); dto.set...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void threadDumpIfNeed(String reasonMsg) { if (!enable) { return; } synchronized (this) { if (System.currentTimeMillis() - lastThreadDumpTime < leastIntervalMills) { return; } else { lastThreadDumpTime = System.currentTimeMillis(); } } logge...
#vulnerable code public void threadDumpIfNeed(String reasonMsg) { if (!enable) { return; } synchronized (this) { if (System.currentTimeMillis() - lastThreadDumpTime < leastIntervalMills) { return; } else { lastThreadDumpTime = System.currentTimeMillis(); } } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void reportExecution(String name, ExecutionMetric execution, long timestamp) throws IOException { send(MetricRegistry.name(prefix, name, "count"), format(execution.counterMetric.lastCount), timestamp); send(MetricRegistry.name(prefix, name, "min"), format(execution....
#vulnerable code private void reportExecution(String name, ExecutionMetric execution, long timestamp) throws IOException { send(MetricRegistry.name(prefix, name, "count"), format(execution.counter.count), timestamp); send(MetricRegistry.name(prefix, name, "min"), format(execution.hist...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public HistogramMetric calculateMetric() { // 快照当前的数据,在计算时不阻塞新的metrics update. List<Long> snapshotList = measurements; measurements = new LinkedList(); if (snapshotList.isEmpty()) { return createEmptyMetric(); } // 按数值大小排序,以快速支持百分比过滤 Collections.sort(snapshot...
#vulnerable code public HistogramMetric calculateMetric() { // 快照当前的数据,在计算时不阻塞新的metrics update. List<Long> snapshotList = null; synchronized (lock) { snapshotList = measurements; measurements = new LinkedList(); } if (snapshotList.isEmpty()) { return createEmptyMetric(...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static InetAddress findLocalAddressViaNetworkInterface() { // 如果hostname +/etc/hosts 得到的是127.0.0.1, 则首选这块网卡 String preferNamePrefix = SystemPropertiesUtil.getString("localhost.prefer.nic.prefix", "LOCALHOST_PREFER_NIC_PREFIX", "bond0."); // 如果hostname +/etc/hos...
#vulnerable code private static InetAddress findLocalAddressViaNetworkInterface() { // 如果hostname +/etc/hosts 得到的是127.0.0.1, 则首选这块网卡 String preferNamePrefix = SystemPropertiesUtil.getString("localhost.prefer.nic.prefix", "LOCALHOST_PREFER_NIC_PREFIX", "bond0."); // 如果hostname +/e...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void printCounter(CounterMetric counter) { output.printf(" last count = %d%n", counter.lastCount); output.printf(" total count = %d%n", counter.totalCount); output.printf(" last rate = %d%n", counter.lastRate); output.printf(" mean ra...
#vulnerable code private void printCounter(CounterMetric counter) { output.printf(" last count = %d%n", counter.lastCount); output.printf(" total count = %d%n", counter.totalCount); output.printf(" last rate = %2.2f/s%n", counter.lastRate); output.printf(" ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void printTimer(TimerMetric timer) { output.printf(" count = %d%n", timer.counterMetric.totalCount); output.printf(" last rate = %d%n", timer.counterMetric.lastRate); output.printf(" mean rate = %d%n", timer.counterMetric.meanRate); ou...
#vulnerable code private void printTimer(TimerMetric timer) { output.printf(" count = %d%n", timer.counterMetric.totalCount); output.printf(" last rate = %2.2f/s%n", timer.counterMetric.lastRate); output.printf(" mean rate = %2.2f/s%n", timer.counterMetric...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void printCounter(CounterMetric counter) { output.printf(" last count = %d%n", counter.lastCount); output.printf(" total count = %d%n", counter.totalCount); output.printf(" last rate = %d%n", counter.lastRate); output.printf(" mean ra...
#vulnerable code private void printCounter(CounterMetric counter) { output.printf(" last count = %d%n", counter.lastCount); output.printf(" total count = %d%n", counter.totalCount); output.printf(" last rate = %2.2f/s%n", counter.lastRate); output.printf(" ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void printTimer(TimerMetric timer) { output.printf(" count = %d%n", timer.counterMetric.totalCount); output.printf(" last rate = %d%n", timer.counterMetric.lastRate); output.printf(" mean rate = %d%n", timer.counterMetric.meanRate); ou...
#vulnerable code private void printTimer(TimerMetric timer) { output.printf(" count = %d%n", timer.counterMetric.totalCount); output.printf(" last rate = %2.2f/s%n", timer.counterMetric.lastRate); output.printf(" mean rate = %2.2f/s%n", timer.counterMetric...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void printHistogram(HistogramMetric histogram) { output.printf(" min = %d%n", histogram.min); output.printf(" max = %d%n", histogram.max); output.printf(" mean = %2.2f%n", histogram.mean); for (Entry<Double, Long> pct : hi...
#vulnerable code private void printHistogram(HistogramMetric histogram) { output.printf(" min = %d%n", histogram.min); output.printf(" max = %d%n", histogram.max); output.printf(" mean = %2.2f%n", histogram.mean); for (Entry<Double, Long> pc...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static VideoInfo getVideoInfo(File input) { VideoInfo vi = new VideoInfo(); if (input != null && input.exists()) { List<String> commands = Lists.newArrayList(BaseCommandOption.getFFprobeBinary()); commands.add(input.getAbsolutePa...
#vulnerable code public static VideoInfo getVideoInfo(File input) { if (input != null && input.exists()) { List<String> commands = Lists.newArrayList(BaseCommandOption.getFFprobeBinary()); commands.add(input.getAbsolutePath()); // if (log.isIn...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static VideoInfo getVideoInfo(File input) { if (input != null && input.exists()) { List<String> commands = Lists.newArrayList(BaseCommandOption.getFFprobeBinary()); commands.add(input.getAbsolutePath()); // if (log.isInfoEnabl...
#vulnerable code public static VideoInfo getVideoInfo(File input) { if (input != null && input.exists()) { List<String> commands = Lists.newArrayList(BaseCommandOption.getFfmpegBinary()); commands.addAll(BaseCommandOption.toInputCommonsCmdArrays(input.get...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public String handler(InputStream errorStream) throws IOException { FileChannel inputChannel =null; if (errorStream instanceof FileInputStream) { inputChannel = ((FileInputStream) errorStream).getChannel(); } else{ return ""; } ByteArrayOutput...
#vulnerable code public String handler(InputStream errorStream) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(errorStream,BaseCommandOption.UTF8)); StringBuffer sb = new StringBuffer(); String line; try { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static VideoInfo getVideoInfo(File input) { if (input != null && input.exists()) { List<String> commands = Lists.newArrayList(BaseCommandOption.getFFprobeBinary()); commands.add(input.getAbsolutePath()); // if (log.isInfoEnab...
#vulnerable code public static VideoInfo getVideoInfo(File input) { if (input != null && input.exists()) { List<String> commands = Lists.newArrayList(BaseCommandOption.getFFprobeBinary()); commands.add(input.getAbsolutePath()); // if (log.isInf...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void agglomerate(LinkageStrategy linkageStrategy) { Collections.sort(distances); if (distances.size() > 0) { ClusterPair minDistLink = distances.remove(0); clusters.remove(minDistLink.getrCluster()); clusters.remove(minDistLink.getlCluster()); Cluster old...
#vulnerable code public void agglomerate(LinkageStrategy linkageStrategy) { Collections.sort(distances); if (distances.size() > 0) { ClusterPair minDistLink = distances.remove(0); clusters.remove(minDistLink.getrCluster()); clusters.remove(minDistLink.getlCluster()); Clust...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void imageTest06() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest06.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest06.pdf"; FileOutputStream file = new FileOutputStream(outFile...
#vulnerable code @Test public void imageTest06() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest06.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest06.pdf"; FileOutputStream file = new FileOutputStream(o...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public PdfObject getDestinationPage(final HashMap<Object, PdfObject> names) throws PdfException { PdfArray array = (PdfArray) names.get(getPdfObject()); return array != null ? array.get(0, false) : null; }
#vulnerable code @Override public PdfObject getDestinationPage(final HashMap<Object, PdfObject> names) throws PdfException { PdfArray array = (PdfArray) names.get(getPdfObject()); return array.get(0, false); } #location 5 ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public OutputStream writeFloat(float value) throws IOException { int intPart = (int) value; int fractalPart = (int) (value - (int) value) * 1000; writeInteger(intPart, 8).writeByte((byte) '.').writeInteger(fractalPart, 4); return this; }
#vulnerable code public OutputStream writeFloat(float value) throws IOException { write(getIsoBytes(String.valueOf(value))); return this; } #location 2 #vulnerability type NULL_DEREFERENCE
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public OutputStream writeBoolean(boolean value) throws IOException { write(value ? booleanTrue : booleanFalse); return this; }
#vulnerable code public OutputStream writeBoolean(boolean value) throws IOException { write(getIsoBytes(String.valueOf(value))); return this; } #location 2 #vulnerability type NULL_DEREFERENCE
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected int writeXRefTable() throws IOException, PdfException { int strtxref = currentPos; if (fullCompression) { PdfStream stream = new PdfStream(pdfDocument); stream.put(PdfName.Type, PdfName.XRef); stream.put(PdfName.Si...
#vulnerable code protected int writeXRefTable() throws IOException, PdfException { int strtxref = currentPos; if (fullCompression) { PdfStream stream = new PdfStream(pdfDocument); stream.put(PdfName.Type, PdfName.XRef); stream.put(PdfN...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void outlinesTest() throws IOException, PdfException { PdfReader reader = new PdfReader(new FileInputStream(sourceFolder+"iphone_user_guide.pdf")); PdfDocument pdfDoc = new PdfDocument(reader); PdfOutline outlines = pdfDoc.getOutlines...
#vulnerable code @Test public void outlinesTest() throws IOException, PdfException { PdfReader reader = new PdfReader(new FileInputStream(sourceFolder+"iphone_user_guide.pdf")); PdfDocument pdfDoc = new PdfDocument(reader); PdfOutline outlines = pdfDoc.getCa...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void imageTest01() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest01.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest01.pdf"; FileOutputStream file = new FileOutputStream(outFile...
#vulnerable code @Test public void imageTest01() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest01.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest01.pdf"; FileOutputStream file = new FileOutputStream(o...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void flatFields() { if (document.isAppendMode()) { throw new PdfException(PdfException.FieldFlatteningIsNotSupportedInAppendMode); } Map<String, PdfFormField> fields = getFormFields(); PdfPage page = null; for (Map.En...
#vulnerable code public void flatFields() { if (document.isAppendMode()) { throw new PdfException(PdfException.FieldFlatteningIsNotSupportedInAppendMode); } List<PdfFormField> fields = getFormFields(); PdfPage page = null; for (PdfForm...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public OutputStream writeDouble(double value) throws IOException { return writeFloat((float)value); }
#vulnerable code public OutputStream writeDouble(double value) throws IOException { write(getIsoBytes(String.valueOf(value))); return this; } #location 2 #vulnerability type NULL_DEREFERENCE
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void taggingTest05() throws Exception { FileInputStream fis = new FileInputStream(sourceFolder + "iphone_user_guide.pdf"); PdfReader reader = new PdfReader(fis); PdfDocument source = new PdfDocument(reader); PdfWriter writer =...
#vulnerable code @Test public void taggingTest05() throws Exception { FileInputStream fis = new FileInputStream(sourceFolder + "iphone_user_guide.pdf"); PdfReader reader = new PdfReader(fis); PdfDocument document = new PdfDocument(reader); Assert.ass...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void imageTest03() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest03.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest03.pdf"; FileOutputStream file = new FileOutputStream(outFile...
#vulnerable code @Test public void imageTest03() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest03.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest03.pdf"; FileOutputStream file = new FileOutputStream(o...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void imageTest04() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest04.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest04.pdf"; FileOutputStream file = new FileOutputStream(outFile...
#vulnerable code @Test public void imageTest04() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest04.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest04.pdf"; FileOutputStream file = new FileOutputStream(o...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public PdfObject getDestinationPage(HashMap<Object, PdfObject> names) throws PdfException { PdfArray array = (PdfArray) names.get(getPdfObject().toUnicodeString()); return array != null ? array.get(0, false) : null; }
#vulnerable code @Override public PdfObject getDestinationPage(HashMap<Object, PdfObject> names) throws PdfException { PdfArray array = (PdfArray) names.get(getPdfObject().toUnicodeString()); return array.get(0, false); } #location 5...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void formFieldTest01() throws IOException { PdfReader reader = new PdfReader(sourceFolder + "formFieldFile.pdf"); PdfDocument pdfDoc = new PdfDocument(reader); PdfAcroForm form = PdfAcroForm.getAcroForm(pdfDoc, false); Map<St...
#vulnerable code @Test public void formFieldTest01() throws IOException { PdfReader reader = new PdfReader(sourceFolder + "formFieldFile.pdf"); PdfDocument pdfDoc = new PdfDocument(reader); PdfAcroForm form = PdfAcroForm.getAcroForm(pdfDoc, false); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public PdfFormXObject createFormXObjectWithBarcode(Color barColor, Color textColor) { PdfFormXObject xObject = new PdfFormXObject(document, null); Rectangle rect = placeBarcode(new PdfCanvas(xObject), barColor, textColor); xObject.setBBox(rect.toPdfArr...
#vulnerable code public PdfFormXObject createFormXObjectWithBarcode(Color barColor, Color textColor) { PdfStream stream = new PdfStream(document); PdfCanvas canvas = new PdfCanvas(stream, new PdfResources()); Rectangle rect = placeBarcode(canvas, barColor, textCo...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void justify(float width) { float ratio = getPropertyAsFloat(Property.SPACING_RATIO); float freeWidth = occupiedArea.getBBox().getX() + width - getLastChildRenderer().getOccupiedArea().getBBox().getX() - getLastChildRenderer().getOccu...
#vulnerable code protected void justify(float width) { float ratio = .5f; float freeWidth = occupiedArea.getBBox().getX() + width - getLastChildRenderer().getOccupiedArea().getBBox().getX() - getLastChildRenderer().getOccupiedArea().getBBox().getWidth(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void imageTest02() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest02.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest02.pdf"; FileOutputStream file = new FileOutputStream(outFile...
#vulnerable code @Test public void imageTest02() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest02.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest02.pdf"; FileOutputStream file = new FileOutputStream(o...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void create1000PagesDocumentWithFullCompression() throws IOException, PdfException { final String author = "Alexander Chingarev"; final String creator = "iText 6"; final String title = "Empty iText 6 Document"; FileOutputStre...
#vulnerable code @Test public void create1000PagesDocumentWithFullCompression() throws IOException, PdfException { final String author = "Alexander Chingarev"; final String creator = "iText 6"; final String title = "Empty iText 6 Document"; FileOutp...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public LayoutResult layout(LayoutContext layoutContext) { LayoutArea area = layoutContext.getArea(); Rectangle layoutBox = area.getBBox(); occupiedArea = new LayoutArea(area.getPageNumber(), new Rectangle(layoutBox.getX(), layoutBox.getY(...
#vulnerable code @Override public LayoutResult layout(LayoutContext layoutContext) { LayoutArea area = layoutContext.getArea(); Rectangle layoutBox = area.getBBox(); occupiedArea = new LayoutArea(area.getPageNumber(), new Rectangle(layoutBox.getX(), layoutBox...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void imageTest05() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest05.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest05.pdf"; FileOutputStream file = new FileOutputStream(outFile...
#vulnerable code @Test public void imageTest05() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest05.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest05.pdf"; FileOutputStream file = new FileOutputStream(o...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void buildResources(PdfDictionary dictionary) throws PdfException { for (PdfName resourceType : dictionary.keySet()) { if (nameToResource.get(resourceType) == null) { nameToResource.put(resourceType, new HashMap<PdfName, PdfObject...
#vulnerable code protected void buildResources(PdfDictionary dictionary) throws PdfException { for (PdfName resourceType : dictionary.keySet()) { if (nameToResource.get(resourceType) == null) { nameToResource.put(resourceType, new HashMap<PdfName, Pdf...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public LayoutResult layout(LayoutContext layoutContext) { LayoutArea area = layoutContext.getArea(); Rectangle layoutBox = area.getBBox(); occupiedArea = new LayoutArea(area.getPageNumber(), new Rectangle(layoutBox.getX(), layoutBox.getY(...
#vulnerable code @Override public LayoutResult layout(LayoutContext layoutContext) { LayoutArea area = layoutContext.getArea(); Rectangle layoutBox = area.getBBox(); occupiedArea = new LayoutArea(area.getPageNumber(), new Rectangle(layoutBox.getX(), layoutBox...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void imageTest02() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest02.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest02.pdf"; FileOutputStream file = new FileOutputStream(outFile...
#vulnerable code @Test public void imageTest02() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest02.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest02.pdf"; FileOutputStream file = new FileOutputStream(o...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected int writeXRefTable() throws IOException, PdfException { int strtxref = currentPos; if (fullCompression) { PdfStream stream = new PdfStream(pdfDocument); stream.put(PdfName.Type, PdfName.XRef); stream.put(PdfName.Si...
#vulnerable code protected int writeXRefTable() throws IOException, PdfException { int strtxref = currentPos; if (fullCompression) { PdfStream stream = new PdfStream(pdfDocument); stream.put(PdfName.Type, PdfName.XRef); stream.put(PdfN...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public LayoutResult layout(LayoutContext layoutContext) { LayoutArea area = layoutContext.getArea(); Rectangle layoutBox = area.getBBox(); occupiedArea = new LayoutArea(area.getPageNumber(), new Rectangle(layoutBox.getX(), layoutBox.getY(...
#vulnerable code @Override public LayoutResult layout(LayoutContext layoutContext) { LayoutArea area = layoutContext.getArea(); Rectangle layoutBox = area.getBBox(); occupiedArea = new LayoutArea(area.getPageNumber(), new Rectangle(layoutBox.getX(), layoutBox...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public PdfFormXObject createFormXObjectWithBarcode(Color barColor, Color textColor) { PdfFormXObject xObject = new PdfFormXObject(document, null); Rectangle rect = placeBarcode(new PdfCanvas(xObject), barColor, textColor); xObject.setBBox(rect.toPdfArr...
#vulnerable code public PdfFormXObject createFormXObjectWithBarcode(Color barColor, Color textColor) { PdfStream stream = new PdfStream(document); PdfCanvas canvas = new PdfCanvas(stream, new PdfResources()); Rectangle rect = placeBarcode(canvas, barColor, textCo...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void create1000PagesDocument() throws IOException, PdfException { final String author = "Alexander Chingarev"; final String creator = "iText 6"; final String title = "Empty iText 6 Document"; FileOutputStream fos = new FileOu...
#vulnerable code @Test public void create1000PagesDocument() throws IOException, PdfException { final String author = "Alexander Chingarev"; final String creator = "iText 6"; final String title = "Empty iText 6 Document"; FileOutputStream fos = new ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void imageTest04() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest04.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest04.pdf"; FileOutputStream file = new FileOutputStream(outFile...
#vulnerable code @Test public void imageTest04() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest04.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest04.pdf"; FileOutputStream file = new FileOutputStream(o...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void imageTest01() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest01.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest01.pdf"; FileOutputStream file = new FileOutputStream(outFile...
#vulnerable code @Test public void imageTest01() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest01.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest01.pdf"; FileOutputStream file = new FileOutputStream(o...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public PdfObjectStream getObjectStream() throws IOException, PdfException { if (!fullCompression) return null; if (objectStream == null) { objectStream = new PdfObjectStream(pdfDocument); } if (objectStream.getSize() == ...
#vulnerable code public PdfObjectStream getObjectStream() throws IOException, PdfException { if (!fullCompression) return null; if (objectStream == null) { objectStream = new PdfObjectStream(pdfDocument); } if (objectStream.getSize...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void imageTest05() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest05.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest05.pdf"; FileOutputStream file = new FileOutputStream(outFile...
#vulnerable code @Test public void imageTest05() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest05.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest05.pdf"; FileOutputStream file = new FileOutputStream(o...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void imageTest04() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest04.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest04.pdf"; FileOutputStream file = new FileOutputStream(outFile...
#vulnerable code @Test public void imageTest04() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest04.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest04.pdf"; FileOutputStream file = new FileOutputStream(o...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void addChild(IRenderer renderer) { super.addChild(renderer); if (currentArea == null) { currentArea = getNextArea(); // try { // new PdfCanvas(document.getPdfDocument().getPage(currentArea.getPageNum...
#vulnerable code @Override public void addChild(IRenderer renderer) { super.addChild(renderer); if (currentArea == null) { currentArea = getNextArea(); // try { // new PdfCanvas(document.getPdfDocument().getPage(currentArea.getP...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public OutputStream writeInteger(int value) throws IOException { writeInteger(value, 8); return this; }
#vulnerable code public OutputStream writeInteger(int value) throws IOException { write(getIsoBytes(String.valueOf(value))); return this; } #location 2 #vulnerability type NULL_DEREFERENCE
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public LayoutResult layout(LayoutContext layoutContext) { LayoutArea area = layoutContext.getArea(); Rectangle layoutBox = area.getBBox(); occupiedArea = new LayoutArea(area.getPageNumber(), new Rectangle(layoutBox.getX(), layoutBox.getY(...
#vulnerable code @Override public LayoutResult layout(LayoutContext layoutContext) { LayoutArea area = layoutContext.getArea(); Rectangle layoutBox = area.getBBox(); occupiedArea = new LayoutArea(area.getPageNumber(), new Rectangle(layoutBox.getX(), layoutBox...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void imageTest06() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest06.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest06.pdf"; FileOutputStream file = new FileOutputStream(outFile...
#vulnerable code @Test public void imageTest06() throws IOException, InterruptedException { String outFileName = destinationFolder + "imageTest06.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest06.pdf"; FileOutputStream file = new FileOutputStream(o...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static Boolean isProjectPermsPassByProjectId(Integer projectId) { List<Integer> projectIDList = ShiroUtils.getProjectIdForRoles(); Boolean result = false; /*超级管理员权限*/ if("admin".equals(ShiroUtils.getLoginName())){ return true; } ...
#vulnerable code public static Boolean isProjectPermsPassByProjectId(Integer projectId) { List<Integer> projectIDList = ShiroUtils.getSysUser().getProjectIdForRoles(); Boolean result = false; /*超级管理员权限*/ if("admin".equals(ShiroUtils.getLoginName())){ return...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static Boolean isProjectPermsPassByProjectId(Integer projectId) { List<Integer> projectIDList = ShiroUtils.getProjectIdForRoles(); Boolean result = false; /*超级管理员权限*/ if("admin".equals(ShiroUtils.getLoginName())){ return true; } ...
#vulnerable code public static Boolean isProjectPermsPassByProjectId(Integer projectId) { List<Integer> projectIDList = ShiroUtils.getSysUser().getProjectIdForRoles(); Boolean result = false; /*超级管理员权限*/ if("admin".equals(ShiroUtils.getLoginName())){ return...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void execute(JobExecutionContext context) throws JobExecutionException { try { String name = context.getJobDetail().getName(); if(name.indexOf(PublicConst.JOBTASKNAMETYPE)>-1){ TestJobs job = new TestJobs(); String id=name.substring(0,nam...
#vulnerable code @Override public void execute(JobExecutionContext context) throws JobExecutionException { try { String name = context.getJobDetail().getName(); if(name.indexOf(PublicConst.JOBTASKNAMETYPE)>-1){ TestJobs job = new TestJobs(); String id=name.substring...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void login() { try { //1 uuid String uuid = wechatHttpService.getUUID(); cacheService.setUuid(uuid); logger.info("[1] uuid completed"); //2 qr byte[] qrData = wechatHttpService.getQR(uuid);...
#vulnerable code public void login() { try { //1 uuid String uuid = wechatHttpService.getUUID(); cacheService.setUuid(uuid); logger.info("[1] uuid completed"); //2 qr byte[] qrData = wechatHttpService.getQR(...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void login() { try { //1 uuid String uuid = wechatHttpService.getUUID(); cacheService.setUuid(uuid); logger.info("[1] uuid completed"); //2 qr byte[] qrData = wechatHttpService.getQR(uuid);...
#vulnerable code public void login() { try { //1 uuid String uuid = wechatHttpService.getUUID(); cacheService.setUuid(uuid); logger.info("[1] uuid completed"); //2 qr byte[] qrData = wechatHttpService.getQR(...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static NSObject parse(final byte[] bytes) throws Exception { ByteArrayInputStream bis = new ByteArrayInputStream(bytes); return parse(bis); }
#vulnerable code public static NSObject parse(final byte[] bytes) throws Exception { InputStream is = new InputStream() { private int pos = 0; @Override public int read() throws IOException { if (pos >= bytes.length) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void saveAsXML(NSObject root, File out) throws IOException { OutputStreamWriter w = new OutputStreamWriter(new FileOutputStream(out), "UTF-8"); w.write(root.toXMLPropertyList()); w.close(); }
#vulnerable code public static void saveAsXML(NSObject root, File out) throws IOException { FileWriter fw = new FileWriter(out); fw.write(root.toXMLPropertyList()); fw.close(); } #location 5 #vulnerabi...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static NSObject parse(File f) throws Exception { FileInputStream fis = new FileInputStream(f); String magicString = new String(readAll(fis, 8), 0, 8); fis.close(); if (magicString.startsWith("bplist00")) { return BinaryProper...
#vulnerable code public static NSObject parse(File f) throws Exception { FileInputStream fis = new FileInputStream(f); return parse(fis); } #location 3 #vulnerability type RESOURCE_LEAK
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static NSObject parse(File f) throws Exception { FileInputStream fis = new FileInputStream(f); return parse(fis); }
#vulnerable code public static NSObject parse(File f) throws Exception { FileInputStream fis = new FileInputStream(f); byte[] magic = new byte[8]; fis.read(magic); String magic_string = new String(magic); fis.close(); if (magic_string.star...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void runTagger() throws IOException, ClassNotFoundException { tagger = new Tagger(); if (!justTokenize) { tagger.loadModel(modelFilename); } if (inputFormat.equals("conll")) { runTaggerInEvalMode(); return; } assert (inputFormat.equals("json...
#vulnerable code public void runTagger() throws IOException, ClassNotFoundException { tagger = new Tagger(); if (!justTokenize) { tagger.loadModel(modelFilename); } if (inputFormat.equals("conll")) { runTaggerInEvalMode(); return; } assert (inputFormat.equals...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static ArrayList<Sentence> readFile(String filename) throws IOException { BufferedReader reader = BasicFileIO.openFileToReadUTF8(filename); ArrayList sentences = new ArrayList<String>(); ArrayList<String> curLines = new ArrayList<String>(); String line; while (...
#vulnerable code public static ArrayList<Sentence> readFile(String filename) throws IOException { BufferedReader reader = BasicFileIO.openFileToRead(filename); ArrayList sentences = new ArrayList<String>(); ArrayList<String> curLines = new ArrayList<String>(); String line; while...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Transactional(readOnly = true) public MiddlewarePage list(Long apiId, MiddlewareDTO middlewareDTO, PageableDTO pageableDTO) { Api api = apiRepository.findOne(apiId); HeimdallException.checkThrow(isBlank(api), GLOBAL_RESOURCE_NOT_FOUND); ...
#vulnerable code @Transactional(readOnly = true) public MiddlewarePage list(Long apiId, MiddlewareDTO middlewareDTO, PageableDTO pageableDTO) { Api api = apiRepository.findOne(apiId); HeimdallException.checkThrow(isBlank(api), GLOBAL_RESOURCE_NOT_FOUND); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected HeimdallRoute getMatchingHeimdallRoute(String requestURI, String method, RequestContext ctx) { boolean auxMatch = false; for (Entry<String, ZuulRoute> entry : routeLocator.getAtomicRoutes().get().entrySet()) { if (entry.getKey() != null)...
#vulnerable code protected HeimdallRoute getMatchingHeimdallRoute(String requestURI, String method, RequestContext ctx) { boolean auxMatch = false; for (Entry<String, ZuulRoute> entry : routeLocator.getAtomicRoutes().get().entrySet()) { if (entry.getKey() !=...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected HeimdallRoute getMatchingHeimdallRoute(String requestURI, String method, RequestContext ctx) { boolean auxMatch = false; for (Entry<String, ZuulRoute> entry : routeLocator.getAtomicRoutes().get().entrySet()) { if (Objeto.notBlank...
#vulnerable code protected HeimdallRoute getMatchingHeimdallRoute(String requestURI, String method, RequestContext ctx) { boolean auxMatch = false; for (Entry<String, ZuulRoute> entry : routeLocator.getAtomicRoutes().get().entrySet()) { if (Objeto.no...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public Object run() { long startTime = System.currentTimeMillis(); RequestContext context = RequestContext.getCurrentContext(); HttpServletRequest request = context.getRequest(); HttpHost httpHost = new HttpHost( context.getRouteHost().getHost(), cont...
#vulnerable code @Override public Object run() { long startTime = System.currentTimeMillis(); RequestContext context = RequestContext.getCurrentContext(); HttpServletRequest request = context.getRequest(); String verb = getVerb(request); String uri = this.helper.buildZuulReques...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void execute() throws Throwable { RequestContext ctx = RequestContext.getCurrentContext(); RequestResponseParser r = new RequestResponseParser(); r.setUri(UrlUtil.getCurrentUrl(ctx.getRequest())); Map<String, String> headers = Respons...
#vulnerable code private void execute() throws Throwable { RequestContext ctx = RequestContext.getCurrentContext(); RequestResponseParser r = new RequestResponseParser(); r.setUri(UrlUtil.getCurrentUrl(ctx.getRequest())); Map<String, String> headers = ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void execute() { RequestContext ctx = RequestContext.getCurrentContext(); HttpServletRequest request = ctx.getRequest(); RequestResponseParser r = new RequestResponseParser(); r.setHeaders(getRequestHeadersInfo(request)); ...
#vulnerable code private void execute() { Helper helper = new HelperImpl(); RequestContext ctx = RequestContext.getCurrentContext(); HttpServletRequest request = ctx.getRequest(); RequestResponseParser r = new RequestResponseParser(); r.setHeade...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void execute(Integer status, String body) { RequestContext ctx = RequestContext.getCurrentContext(); String response; if (helper.json().isJson(body)) { response = helper.json().parse(body); helper.call().response().hea...
#vulnerable code public void execute(Integer status, String body) { Helper helper = new HelperImpl(); RequestContext ctx = RequestContext.getCurrentContext(); String response; if (helper.json().isJson(body)) { response = helper.json().parse(...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private MongoDatabase database() { return this.mongoClient.getDatabase(databaseName); }
#vulnerable code private MongoDatabase database() { return createMongoClient().getDatabase(databaseName); } #location 3 #vulnerability type RESOURCE_LEAK
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void cacheInterceptor(String cacheName, Long timeToLive, List<String> headers, List<String> queryParams) { RedissonClient redisson = (RedissonClient) BeanManager.getBean(RedissonClient.class); RequestContext context = RequestContext.getCurrentContext(...
#vulnerable code public void cacheInterceptor(String cacheName, Long timeToLive, List<String> headers, List<String> queryParams) { Helper helper = new HelperImpl(); RedissonClient redisson = (RedissonClient) BeanManager.getBean(RedissonClient.class); RequestCo...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Transactional(readOnly = true) public MiddlewarePage list(Long apiId, MiddlewareDTO middlewareDTO, PageableDTO pageableDTO) { Api api = apiRepository.findOne(apiId); HeimdallException.checkThrow(isBlank(api), GLOBAL_RESOURCE_NOT_FOUND); ...
#vulnerable code @Transactional(readOnly = true) public MiddlewarePage list(Long apiId, MiddlewareDTO middlewareDTO, PageableDTO pageableDTO) { Api api = apiRepository.findOne(apiId); HeimdallException.checkThrow(isBlank(api), GLOBAL_RESOURCE_NOT_FOUND); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void stop() { try { this.lock.writeLock().lock(); this.stop = true; this.torrentFileProvider.unRegisterListener(this); this.thread.interrupt(); try { this.thread.join(); ...
#vulnerable code @Override public void stop() { this.stop = true; this.torrentFileProvider.unRegisterListener(this); this.thread.interrupt(); try { this.thread.join(); } catch (final InterruptedException ignored) { } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void shouldHandleNullConfig() throws Throwable { // Given try( Driver driver = GraphDatabase.driver( neo4j.address(), AuthTokens.none(), null ) ) { Session session = driver.session(); // When se...
#vulnerable code @Test public void shouldHandleNullConfig() throws Throwable { // Given Driver driver = GraphDatabase.driver( neo4j.address(), AuthTokens.none(), null ); Session session = driver.session(); // When session.close(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void shouldNotBeAbleToUseSessionWhileOngoingTransaction() throws Throwable { // Given when( mock.isOpen() ).thenReturn( true ); sess.beginTransaction(); // Expect exception.expect( ClientException.class ); ...
#vulnerable code @Test public void shouldNotBeAbleToUseSessionWhileOngoingTransaction() throws Throwable { // Given Connection mock = mock( Connection.class ); when( mock.isOpen() ).thenReturn( true ); InternalSession sess = new InternalSession( m...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void saveTrustedHost( String fingerprint ) throws IOException { this.fingerprint = fingerprint; logger.info( "Adding %s as known and trusted certificate for %s.", fingerprint, serverId ); createKnownCertFileIfNotExists(); assertKn...
#vulnerable code private void saveTrustedHost( String fingerprint ) throws IOException { this.fingerprint = fingerprint; logger.info( "Adding %s as known and trusted certificate for %s.", fingerprint, serverId ); createKnownCertFileIfNotExists(); as...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void shouldEstablishTLSConnection() throws Throwable { ConfigTest.deleteDefaultKnownCertFileIfExists(); Config config = Config.build().withTlsEnabled( true ).toConfig(); Driver driver = GraphDatabase.driver( URI.cr...
#vulnerable code @Test public void shouldEstablishTLSConnection() throws Throwable { ConfigTest.deleteDefaultKnownCertFileIfExists(); Config config = Config.build().withTlsEnabled( true ).toConfig(); Driver driver = GraphDatabase.driver( ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testFields() throws Exception { // GIVEN ResultBuilder builder = new ResultBuilder( "<unknown>", ParameterSupport.NO_PARAMETERS ); builder.keys( new String[]{"k1"} ); builder.record( new Value[]{value(42)} ); R...
#vulnerable code @Test public void testFields() throws Exception { // GIVEN ResultBuilder builder = new ResultBuilder( "<unknown>", ParameterSupport.NO_PARAMETERS ); builder.keys( new String[]{"k1"} ); builder.record( new Value[]{value(42)} ); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private boolean serverResponds() throws IOException, InterruptedException { try { URI uri = URI.create( DEFAULT_URL ); SocketClient client = new SocketClient( uri.getHost(), uri.getPort() ); client.start(); c...
#vulnerable code private boolean serverResponds() throws IOException, InterruptedException { try { URI uri = URI.create( DEFAULT_URL ); SocketClient client = new SocketClient( uri.getHost(), uri.getPort(), new DevNullLogger() ); cl...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void shouldNotBeAbleToUseSessionWhileOngoingTransaction() throws Throwable { // Given when( mock.isOpen() ).thenReturn( true ); sess.beginTransaction(); // Expect exception.expect( ClientException.class ); ...
#vulnerable code @Test public void shouldNotBeAbleToUseSessionWhileOngoingTransaction() throws Throwable { // Given Connection mock = mock( Connection.class ); when( mock.isOpen() ).thenReturn( true ); InternalSession sess = new InternalSession( m...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public final Connection connect( BoltServerAddress address ) { Connection connection = createConnection( address, securityPlan, logging ); // Because SocketConnection is not thread safe, wrap it in this guard // to ensure concurrent ...
#vulnerable code @Override public final Connection connect( BoltServerAddress address ) { Connection connection = createConnection( address, securityPlan, logging ); // Because SocketConnection is not thread safe, wrap it in this guard // to ensure concu...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @BeforeEach void setUp() { System.setProperty( DRIVER_METRICS_ENABLED_KEY, "true" ); logging = new LoggerNameTrackingLogging(); Config.ConfigBuilder builder = Config.builder() .withLogging( logging ) .withMaxCon...
#vulnerable code @BeforeEach void setUp() { System.setProperty( DRIVER_METRICS_ENABLED_KEY, "true" ); logging = new LoggerNameTrackingLogging(); Config config = Config.builder() .withoutEncryption() .withLogging( logging )...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static String resource( String fileName ) { File resource = new File( TestNeo4j.TEST_RESOURCE_FOLDER_PATH, fileName ); if ( !resource.exists() ) { fail( fileName + " does not exists" ); } return resource.getAbsol...
#vulnerable code private static String resource( String fileName ) { URL resource = StubServer.class.getClassLoader().getResource( fileName ); if ( resource == null ) { fail( fileName + " does not exists" ); } return resource.getFi...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void load() throws IOException { if ( !knownHosts.exists() ) { return; } assertKnownHostFileReadable(); try ( BufferedReader reader = new BufferedReader( new FileReader( knownHosts ) ) ) { S...
#vulnerable code private void load() throws IOException { if ( !knownHosts.exists() ) { return; } assertKnownHostFileReadable(); BufferedReader reader = new BufferedReader( new FileReader( knownHosts ) ); String line; ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static Driver driver( URI uri, AuthToken authToken, Config config ) { // Make sure we have some configuration to play with config = config == null ? Config.defaultConfig() : config; return new DriverFactory().newInstance( uri, authToken, co...
#vulnerable code public static Driver driver( URI uri, AuthToken authToken, Config config ) { // Break down the URI into its constituent parts String scheme = uri.getScheme(); BoltServerAddress address = BoltServerAddress.from( uri ); // Make sure we...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void shouldEstablishTLSConnection() throws Throwable { ConfigTest.deleteDefaultKnownCertFileIfExists(); Config config = Config.build().withTlsEnabled( true ).toConfig(); Driver driver = GraphDatabase.driver( URI.cr...
#vulnerable code @Test public void shouldEstablishTLSConnection() throws Throwable { ConfigTest.deleteDefaultKnownCertFileIfExists(); Config config = Config.build().withTlsEnabled( true ).toConfig(); Driver driver = GraphDatabase.driver( ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test void shouldSaveNewCert() throws Throwable { // Given int newPort = 200; BoltServerAddress address = new BoltServerAddress( knownServerIp, newPort ); Logger logger = mock(Logger.class); TrustOnFirstUseTrustManager manager =...
#vulnerable code @Test void shouldSaveNewCert() throws Throwable { // Given int newPort = 200; BoltServerAddress address = new BoltServerAddress( knownServerIp, newPort ); Logger logger = mock(Logger.class); TrustOnFirstUseTrustManager man...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void shouldBeAbleToOpenTxAfterPreviousIsClosed() throws Throwable { // Given when( mock.isOpen() ).thenReturn( true ); sess.beginTransaction().close(); // When Transaction tx = sess.beginTransaction(); // ...
#vulnerable code @Test public void shouldBeAbleToOpenTxAfterPreviousIsClosed() throws Throwable { // Given Connection mock = mock( Connection.class ); when( mock.isOpen() ).thenReturn( true ); InternalSession sess = new InternalSession( mock ); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void shouldGetHelpfulErrorWhenTryingToConnectToHttpPort() throws Throwable { // Given //the http server needs some time to start up Thread.sleep( 2000 ); try( Driver driver = GraphDatabase.driver( "bolt://localhost:7474", ...
#vulnerable code @Test public void shouldGetHelpfulErrorWhenTryingToConnectToHttpPort() throws Throwable { // Given //the http server needs some time to start up Thread.sleep( 2000 ); Driver driver = GraphDatabase.driver( "bolt://localhost:7474", ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public final Connection connect( BoltServerAddress address ) { Connection connection = createConnection( address, securityPlan, logging ); // Because SocketConnection is not thread safe, wrap it in this guard // to ensure concurrent ...
#vulnerable code @Override public final Connection connect( BoltServerAddress address ) { Connection connection = createConnection( address, securityPlan, logging ); // Because SocketConnection is not thread safe, wrap it in this guard // to ensure concu...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void shouldEstablishTLSConnection() throws Throwable { Config config = Config.build().withEncryptionLevel( Config.EncryptionLevel.REQUIRED ).toConfig(); try( Driver driver = GraphDatabase.driver( URI.create( Neo4jRunner.DEFAULT_URL ), co...
#vulnerable code @Test public void shouldEstablishTLSConnection() throws Throwable { Config config = Config.build().withEncryptionLevel( Config.EncryptionLevel.REQUIRED ).toConfig(); Driver driver = GraphDatabase.driver( URI.create( Neo4jRunner....
Below is the vulnerable code, please generate the patch based on the following information.