output
stringlengths
64
73.2k
input
stringlengths
208
73.3k
instruction
stringclasses
1 value
#fixed code public void testHierarchicConfigRoundTrip() throws Exception { ConfigAlternate input = new ConfigAlternate(123, "Joe", 42); String json = MAPPER.writeValueAsString(input); ConfigAlternate root = MAPPER.readValue(json, ConfigAlternate.class); ...
#vulnerable code public void testHierarchicConfigRoundTrip() throws Exception { ConfigAlternate input = new ConfigAlternate(123, "Joe", 42); String json = mapper.writeValueAsString(input); ConfigAlternate root = mapper.readValue(json, ConfigAlternate.class);...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void testSimpleMapImitation() throws Exception { MapImitator mapHolder = MAPPER.readValue ("{ \"a\" : 3, \"b\" : true, \"c\":[1,2,3] }", MapImitator.class); Map<String,Object> result = mapHolder._map; assertEquals(3, result.size(...
#vulnerable code public void testSimpleMapImitation() throws Exception { MapImitator mapHolder = MAPPER.readValue ("{ \"a\" : 3, \"b\" : true }", MapImitator.class); Map<String,Object> result = mapHolder._map; assertEquals(2, result.size()); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void testHierarchicConfigDeserialize() throws Exception { ConfigRoot root = MAPPER.readValue("{\"general.names.name\":\"Bob\",\"misc.value\":3}", ConfigRoot.class); assertNotNull(root.general); assertNotNull(root.general.name...
#vulnerable code public void testHierarchicConfigDeserialize() throws Exception { ConfigRoot root = mapper.readValue("{\"general.names.name\":\"Bob\",\"misc.value\":3}", ConfigRoot.class); assertNotNull(root.general); assertNotNull(root.genera...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void testAtomicReference() throws Exception { AtomicReference<long[]> value = MAPPER.readValue("[1,2]", new com.fasterxml.jackson.core.type.TypeReference<AtomicReference<long[]>>() { }); Object ob = value.get(); assertNotNull...
#vulnerable code public void testAtomicReference() throws Exception { ObjectMapper mapper = new ObjectMapper(); AtomicReference<long[]> value = mapper.readValue("[1,2]", new com.fasterxml.jackson.core.type.TypeReference<AtomicReference<long[]>>() { })...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public <T> MappingIterator<T> readValues(File src) throws IOException, JsonProcessingException { if (_dataFormatReaders != null) { return _detectBindAndReadValues( _dataFormatReaders.findFormat(_inputStream(src)), false); ...
#vulnerable code public <T> MappingIterator<T> readValues(File src) throws IOException, JsonProcessingException { if (_dataFormatReaders != null) { return _detectBindAndReadValues( _dataFormatReaders.findFormat(_inputStream(src)), fals...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @SuppressWarnings("resource") public <T> MappingIterator<T> readValues(Reader src) throws IOException, JsonProcessingException { if (_dataFormatReaders != null) { _reportUndetectableSource(src); } JsonParser p = _considerFil...
#vulnerable code @SuppressWarnings("resource") public <T> MappingIterator<T> readValues(Reader src) throws IOException, JsonProcessingException { if (_dataFormatReaders != null) { _reportUndetectableSource(src); } JsonParser p = consid...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void testAtomicBoolean() throws Exception { AtomicBoolean b = MAPPER.readValue("true", AtomicBoolean.class); assertTrue(b.get()); }
#vulnerable code public void testAtomicBoolean() throws Exception { ObjectMapper mapper = new ObjectMapper(); AtomicBoolean b = mapper.readValue("true", AtomicBoolean.class); assertTrue(b.get()); } #location 5 ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public PropertyMetadata getMetadata() { final Boolean b = _findRequired(); final String desc = _findDescription(); final Integer idx = _findIndex(); final String def = _findDefaultValue(); if (b == null && idx == null && d...
#vulnerable code @Override public PropertyMetadata getMetadata() { final Boolean b = _findRequired(); final String desc = _findDescription(); final Integer idx = _findIndex(); final String def = _findDefaultValue(); if (b == null && idx == nul...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public String idFromValue(Object value) { return idFromClass(value.getClass()); }
#vulnerable code @Override public String idFromValue(Object value) { Class<?> cls = _typeFactory.constructType(value.getClass()).getRawClass(); final String key = cls.getName(); String name; synchronized (_typeToId) { name = _typeToId....
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void testMapUnwrapDeserialize() throws Exception { MapUnwrap root = MAPPER.readValue("{\"map.test\": 6}", MapUnwrap.class); assertEquals(1, root.map.size()); assertEquals(6, ((Number)root.map.get("test")).intValue()); }
#vulnerable code public void testMapUnwrapDeserialize() throws Exception { MapUnwrap root = mapper.readValue("{\"map.test\": 6}", MapUnwrap.class); assertEquals(1, root.map.size()); assertEquals(6, ((Number)root.map.get("test")).intValue()); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void withTree749() throws Exception { ObjectMapper mapper = new ObjectMapper().registerModule(new TestEnumModule()); Map<KeyEnum, Object> inputMap = new LinkedHashMap<KeyEnum, Object>(); Map<TestEnum, Map<String, String>> replacements = new...
#vulnerable code public void withTree749() throws Exception { Map<KeyEnum, Object> inputMap = new LinkedHashMap<KeyEnum, Object>(); Map<TestEnum, Map<String, String>> replacements = new LinkedHashMap<TestEnum, Map<String, String>>(); Map<String, String> reps ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public <T> MappingIterator<T> readValues(InputStream src) throws IOException, JsonProcessingException { if (_dataFormatReaders != null) { return _detectBindAndReadValues(_dataFormatReaders.findFormat(src), false); } ret...
#vulnerable code public <T> MappingIterator<T> readValues(InputStream src) throws IOException, JsonProcessingException { if (_dataFormatReaders != null) { return _detectBindAndReadValues(_dataFormatReaders.findFormat(src), false); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void testAtomicInt() throws Exception { AtomicInteger value = MAPPER.readValue("13", AtomicInteger.class); assertEquals(13, value.get()); }
#vulnerable code public void testAtomicInt() throws Exception { ObjectMapper mapper = new ObjectMapper(); AtomicInteger value = mapper.readValue("13", AtomicInteger.class); assertEquals(13, value.get()); } #location 5 ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public <T> MappingIterator<T> readValues(URL src) throws IOException, JsonProcessingException { if (_dataFormatReaders != null) { return _detectBindAndReadValues( _dataFormatReaders.findFormat(_inputStream(src)), true); ...
#vulnerable code public <T> MappingIterator<T> readValues(URL src) throws IOException, JsonProcessingException { if (_dataFormatReaders != null) { return _detectBindAndReadValues( _dataFormatReaders.findFormat(_inputStream(src)), true)...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void testPrefixedUnwrapping() throws Exception { PrefixUnwrap bean = MAPPER.readValue("{\"name\":\"Axel\",\"_x\":4,\"_y\":7}", PrefixUnwrap.class); assertNotNull(bean); assertEquals("Axel", bean.name); assertNotNull(bean.location); ...
#vulnerable code public void testPrefixedUnwrapping() throws Exception { PrefixUnwrap bean = mapper.readValue("{\"name\":\"Axel\",\"_x\":4,\"_y\":7}", PrefixUnwrap.class); assertNotNull(bean); assertEquals("Axel", bean.name); assertNotNull(bean.locati...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected SiteMap processText(String sitemapUrl, byte[] content) throws IOException { LOG.debug("Processing textual Sitemap"); SiteMap textSiteMap = new SiteMap(sitemapUrl); textSiteMap.setType(SitemapType.TEXT); BOMInputStream bomIs = new BO...
#vulnerable code protected SiteMap processText(String sitemapUrl, byte[] content) throws IOException { LOG.debug("Processing textual Sitemap"); SiteMap textSiteMap = new SiteMap(sitemapUrl); textSiteMap.setType(SitemapType.TEXT); BOMInputStream bomIs = ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testVideosSitemap() throws UnknownFormatException, IOException { SiteMapParser parser = new SiteMapParser(); parser.enableExtension(Extension.VIDEO); String contentType = "text/xml"; byte[] content = SiteMapParserTest.get...
#vulnerable code @Test public void testVideosSitemap() throws UnknownFormatException, IOException { SiteMapParser parser = new SiteMapParser(); parser.enableExtension(Extension.VIDEO); String contentType = "text/xml"; byte[] content = SiteMapParserTe...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected AbstractSiteMap processXml(URL sitemapUrl, byte[] xmlContent) throws UnknownFormatException { BOMInputStream bomIs = new BOMInputStream(new ByteArrayInputStream(xmlContent)); InputSource is = new InputSource(); is.setCharacterStream(new Buff...
#vulnerable code protected AbstractSiteMap processXml(URL sitemapUrl, byte[] xmlContent) throws UnknownFormatException { BOMInputStream bomIs = new BOMInputStream(new ByteArrayInputStream(xmlContent)); InputSource is = new InputSource(); try { is.set...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public boolean validate(UserPersonalInfo info) { validator.validate(info); if(validator.hasErrors()){ return false; } if (info.getUser() == null) { validator.add(new ValidationMessage("user.errors.wrong", "error")); } if (!info.getUser().getEmail...
#vulnerable code public boolean validate(UserPersonalInfo info) { validator.validate(info); if(validator.hasErrors()){ return false; } if (info.getUser() == null) { validator.add(new ValidationMessage("user.errors.wrong", "error")); } if(!info.getUser().get...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void moderator_should_approve_question_information() throws Exception { Information approvedInfo = new QuestionInformation("edited title", "edited desc", new LoggedUser(otherUser, null), new ArrayList<Tag>(), "comment"); ...
#vulnerable code @Test public void moderator_should_approve_question_information() throws Exception { Question question = question("question title", "question description", author); Information approvedInfo = new QuestionInformation("edited title", "edited desc", ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public boolean validate(UserPersonalInfo info) { validator.validate(info); if (info.getUser() == null) { validator.add(new ValidationMessage("user.errors.wrong", "error")); } if(!info.getUser().getName().equals(info.getName())){ userNameValidator.valida...
#vulnerable code public boolean validate(UserPersonalInfo info) { validator.validate(info); if (info.getUser() == null) { validator.add(new ValidationMessage("error","user.errors.wrong")); } if(!info.getUser().getName().equals(info.getName())){ userNameValidator.v...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void testAlternateDefaultEncoding(final String cT, final String bomEnc, final String streamEnc, final String prologEnc, final String alternateEnc) throws Exception { XmlReader xmlReader = null; try { final InputStream is; ...
#vulnerable code public void testAlternateDefaultEncoding(final String cT, final String bomEnc, final String streamEnc, final String prologEnc, final String alternateEnc) throws Exception { try { final InputStream is; if (prologEnc == null) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void testRawNoBomValid(final String encoding) throws Exception { checkEncoding(XML1, encoding, "UTF-8"); checkEncoding(XML2, encoding, "UTF-8"); checkEncoding(XML3, encoding, encoding); checkEncoding(XML4, encoding, encoding); ...
#vulnerable code protected void testRawNoBomValid(final String encoding) throws Exception { InputStream is = getXmlStream("no-bom", XML1, encoding, encoding); XmlReader xmlReader = new XmlReader(is, false); assertEquals(xmlReader.getEncoding(), "UTF-8"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static Date parseUsingMask(final String[] masks, String sDate) { if (sDate != null) { sDate = sDate.trim(); } ParsePosition pp = null; Date d = null; for (int i = 0; d == null && i < masks.length; i++) { ...
#vulnerable code private static Date parseUsingMask(final String[] masks, String sDate) { sDate = sDate != null ? sDate.trim() : null; ParsePosition pp = null; Date d = null; for (int i = 0; d == null && i < masks.length; i++) { final DateForm...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void testAlternateDefaultEncoding(final String cT, final String bomEnc, final String streamEnc, final String prologEnc, final String alternateEnc) throws Exception { XmlReader xmlReader = null; try { final InputStream is; ...
#vulnerable code public void testAlternateDefaultEncoding(final String cT, final String bomEnc, final String streamEnc, final String prologEnc, final String alternateEnc) throws Exception { try { final InputStream is; if (prologEnc == null) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void testRawNoBomValid(final String encoding) throws Exception { checkEncoding(XML1, encoding, "UTF-8"); checkEncoding(XML2, encoding, "UTF-8"); checkEncoding(XML3, encoding, encoding); checkEncoding(XML4, encoding, encoding); ...
#vulnerable code protected void testRawNoBomValid(final String encoding) throws Exception { InputStream is = getXmlStream("no-bom", XML1, encoding, encoding); XmlReader xmlReader = new XmlReader(is, false); assertEquals(xmlReader.getEncoding(), "UTF-8"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void testRawBomInvalid(final String bomEnc, final String streamEnc, final String prologEnc) throws Exception { final InputStream is = getXmlStream(bomEnc, XML3, streamEnc, prologEnc); try { final XmlReader xmlReader = new XmlReader(is, fa...
#vulnerable code protected void testRawBomInvalid(final String bomEnc, final String streamEnc, final String prologEnc) throws Exception { final InputStream is = getXmlStream(bomEnc, XML3, streamEnc, prologEnc); try { final XmlReader xmlReader = new XmlReader(...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public SyndFeedInfo remove(final URL url) { SyndFeedInfo info = null; final String fileName = cachePath + File.separator + "feed_" + replaceNonAlphanumeric(url.toString(), '_').trim(); FileInputStream fis = null; ObjectInputStream...
#vulnerable code @Override public SyndFeedInfo remove(final URL url) { SyndFeedInfo info = null; final String fileName = cachePath + File.separator + "feed_" + replaceNonAlphanumeric(url.toString(), '_').trim(); FileInputStream fis; try { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void testHttpValid(final String cT, final String bomEnc, final String streamEnc, final String prologEnc) throws Exception { final InputStream is; if (prologEnc == null) { is = getXmlStream(bomEnc, XML1, streamEnc, prologEnc); } else ...
#vulnerable code public void testHttpValid(final String cT, final String bomEnc, final String streamEnc, final String prologEnc) throws Exception { final InputStream is; if (prologEnc == null) { is = getXmlStream(bomEnc, XML1, streamEnc, prologEnc); }...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void testRawNoBomInvalid(final String encoding) throws Exception { InputStream is = null; XmlReader xmlReader = null; try { is = getXmlStream("no-bom", XML3, encoding, encoding); xmlReader = new XmlReader(is, false); ...
#vulnerable code protected void testRawNoBomInvalid(final String encoding) throws Exception { final InputStream is = getXmlStream("no-bom", XML3, encoding, encoding); try { final XmlReader xmlReader = new XmlReader(is, false); fail("It should have...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void testHttpValid(final String cT, final String bomEnc, final String streamEnc, final String prologEnc) throws Exception { final InputStream is; if (prologEnc == null) { is = getXmlStream(bomEnc, XML1, streamEnc, prologEnc); } else ...
#vulnerable code public void testHttpValid(final String cT, final String bomEnc, final String streamEnc, final String prologEnc) throws Exception { final InputStream is; if (prologEnc == null) { is = getXmlStream(bomEnc, XML1, streamEnc, prologEnc); }...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public SyndFeedInfo getFeedInfo(final URL url) { SyndFeedInfo info = null; final String fileName = cachePath + File.separator + "feed_" + replaceNonAlphanumeric(url.toString(), '_').trim(); FileInputStream fis = null; ObjectInputS...
#vulnerable code @Override public SyndFeedInfo getFeedInfo(final URL url) { SyndFeedInfo info = null; final String fileName = cachePath + File.separator + "feed_" + replaceNonAlphanumeric(url.toString(), '_').trim(); FileInputStream fis; try { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void testRawBomValid(final String encoding) throws Exception { final InputStream is = getXmlStream(encoding + "-bom", XML3, encoding, encoding); final XmlReader xmlReader = new XmlReader(is, false); if (!encoding.equals("UTF-16")) { ...
#vulnerable code protected void testRawBomValid(final String encoding) throws Exception { final InputStream is = getXmlStream(encoding + "-bom", XML3, encoding, encoding); final XmlReader xmlReader = new XmlReader(is, false); if (!encoding.equals("UTF-16")) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void testRawNoBomValid(final String encoding) throws Exception { checkEncoding(XML1, encoding, "UTF-8"); checkEncoding(XML2, encoding, "UTF-8"); checkEncoding(XML3, encoding, encoding); checkEncoding(XML4, encoding, encoding); ...
#vulnerable code protected void testRawNoBomValid(final String encoding) throws Exception { InputStream is = getXmlStream("no-bom", XML1, encoding, encoding); XmlReader xmlReader = new XmlReader(is, false); assertEquals(xmlReader.getEncoding(), "UTF-8"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void testParse() { final Calendar cal = new GregorianCalendar(); cal.setTimeZone(TimeZone.getTimeZone("GMT")); // four-digit year String sDate = "Tue, 19 Jul 2005 23:00:51 GMT"; cal.setTime(DateParser.parseRFC822(sDate, Locale.U...
#vulnerable code public void testParse() { final Calendar cal = new GregorianCalendar(); cal.setTimeZone(TimeZone.getTimeZone("GMT")); // four-digit year String sDate = "Tue, 19 Jul 2005 23:00:51 GMT"; cal.setTime(DateParser.parseRFC822(sDate)); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void testHttpLenient(final String cT, final String bomEnc, final String streamEnc, final String prologEnc, final String shouldbe) throws Exception { final InputStream is; if (prologEnc == null) { is = getXmlStream(bomEnc, XML2...
#vulnerable code protected void testHttpLenient(final String cT, final String bomEnc, final String streamEnc, final String prologEnc, final String shouldbe) throws Exception { final InputStream is; if (prologEnc == null) { is = getXmlStream(bomEnc...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void testParse() { final Calendar cal = new GregorianCalendar(); cal.setTimeZone(TimeZone.getTimeZone("GMT")); // four-digit year String sDate = "Tue, 19 Jul 2005 23:00:51 GMT"; cal.setTime(DateParser.parseRFC822(sDate, Locale.U...
#vulnerable code public void testParse() { final Calendar cal = new GregorianCalendar(); cal.setTimeZone(TimeZone.getTimeZone("GMT")); // four-digit year String sDate = "Tue, 19 Jul 2005 23:00:51 GMT"; cal.setTime(DateParser.parseRFC822(sDate)); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void testRawNoBomValid(final String encoding) throws Exception { checkEncoding(XML1, encoding, "UTF-8"); checkEncoding(XML2, encoding, "UTF-8"); checkEncoding(XML3, encoding, encoding); checkEncoding(XML4, encoding, encoding); ...
#vulnerable code protected void testRawNoBomValid(final String encoding) throws Exception { InputStream is = getXmlStream("no-bom", XML1, encoding, encoding); XmlReader xmlReader = new XmlReader(is, false); assertEquals(xmlReader.getEncoding(), "UTF-8"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code HtmlTreeBuilder() {}
#vulnerable code Element pop() { // todo - dev, remove validation check if (stack.peekLast().nodeName().equals("td") && !state.name().equals("InCell")) Validate.isFalse(true, "pop td not in cell"); if (stack.peekLast().nodeName().equals("html")) ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static String readInputStream(InputStream inStream, String charsetName) throws IOException { byte[] buffer = new byte[bufferSize]; ByteArrayOutputStream outStream = new ByteArrayOutputStream(bufferSize); int read; while(true) { ...
#vulnerable code private static String readInputStream(InputStream inStream, String charsetName) throws IOException { char[] buffer = new char[0x20000]; // ~ 130K StringBuilder data = new StringBuilder(0x20000); Reader inReader = new InputStreamReader(inStream, c...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code static String load(File in, String charsetName) throws IOException { InputStream inStream = new FileInputStream(in); String data = readInputStream(inStream, charsetName); inStream.close(); return data; }
#vulnerable code static String load(File in, String charsetName) throws IOException { char[] buffer = new char[0x20000]; // ~ 130K StringBuilder data = new StringBuilder(0x20000); InputStream inStream = new FileInputStream(in); Reader inReader = n...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public Document normalise() { if (select("html").isEmpty()) appendElement("html"); if (head() == null) select("html").first().prependElement("head"); if (body() == null) select("html").first().appendElement("body"); ...
#vulnerable code public Document normalise() { if (select("html").isEmpty()) appendElement("html"); if (head() == null) select("html").first().prependElement("head"); if (body() == null) select("html").first().appendElement("bo...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public Document parse() { // TODO: figure out implicit head & body elements Document doc = new Document(); stack.add(doc); StringBuilder commentAccum = null; while (tokenStream.hasNext()) { Token token = tokenStream.next()...
#vulnerable code public Document parse() { // TODO: figure out implicit head & body elements Document doc = new Document(); stack.add(doc); while (tokenStream.hasNext()) { Token token = tokenStream.next(); if (token.isStartTag())...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public Node previousSibling() { List<Node> siblings = parentNode.childNodes; Integer index = siblingIndex(); Validate.notNull(index); if (index > 0) return siblings.get(index-1); else return null; }
#vulnerable code public Node previousSibling() { List<Node> siblings = parentNode.childNodes; Integer index = indexInList(this, siblings); Validate.notNull(index); if (index > 0) return siblings.get(index-1); else return nu...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code ParseSettings defaultSettings() { return ParseSettings.htmlDefault; }
#vulnerable code void insert(Token.Character characterToken) { Node node; // characters in script and style go in as datanodes, not text nodes final String tagName = currentElement().tagName(); final String data = characterToken.getData(); if (ch...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testPreviousElementSiblings() { Document doc = Jsoup.parse("<ul id='ul'>" + "<li id='a'>a</li>" + "<li id='b'>b</li>" + "<li id='c'>c</li>" + "</ul>" + "<div id='div'>" + "<l...
#vulnerable code @Test public void testPreviousElementSiblings() { Document doc = Jsoup.parse("<li id='a'>a</li>" + "<li id='b'>b</li>" + "<li id='c'>c</li>"); Element element = doc.getElementById("b"); List<Element> elementSiblings = ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void forms() { Document doc = Jsoup.parse("<form id=1><input name=q></form><div /><form id=2><input name=f></form>"); Elements els = doc.select("*"); assertEquals(9, els.size()); List<FormElement> forms = els.forms(); asse...
#vulnerable code @Test public void forms() { Document doc = Jsoup.parse("<form id=1><input name=q></form><div /><form id=2><input name=f></form>"); Elements els = doc.select("*"); assertEquals(9, els.size()); List<FormElement> forms = els.forms(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code static String load(File in, String charsetName) throws IOException { InputStream inStream = new FileInputStream(in); String data = readInputStream(inStream, charsetName); inStream.close(); return data; }
#vulnerable code static String load(File in, String charsetName) throws IOException { char[] buffer = new char[0x20000]; // ~ 130K StringBuilder data = new StringBuilder(0x20000); InputStream inStream = new FileInputStream(in); Reader inReader = n...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public Node nextSibling() { if (parentNode == null) return null; // root List<Node> siblings = parentNode.childNodes; Integer index = siblingIndex(); Validate.notNull(index); if (siblings.size() > index+1) ...
#vulnerable code public Node nextSibling() { if (parentNode == null) return null; // root List<Node> siblings = parentNode.childNodes; Integer index = indexInList(this, siblings); Validate.notNull(index); if (siblings.size() >...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public Document normalise() { Element htmlEl = findFirstElementByTagName("html", this); if (htmlEl == null) htmlEl = appendElement("html"); if (head() == null) htmlEl.prependElement("head"); if (body() == null) ...
#vulnerable code public Document normalise() { if (select("html").isEmpty()) appendElement("html"); if (head() == null) select("html").first().prependElement("head"); if (body() == null) select("html").first().appendElement("bo...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code ParseSettings defaultSettings() { return ParseSettings.htmlDefault; }
#vulnerable code void insert(Token.Character characterToken) { Node node; // characters in script and style go in as datanodes, not text nodes final String tagName = currentElement().tagName(); final String data = characterToken.getData(); if (ch...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public boolean matchesWhitespace() { return !isEmpty() && Character.isWhitespace(queue.charAt(pos)); }
#vulnerable code public boolean matchesWhitespace() { return !isEmpty() && Character.isWhitespace(peek()); } #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 testAppendTo() { String parentHtml = "<div class='a'></div>"; String childHtml = "<div class='b'></div><p>Two</p>"; Document parentDoc = Jsoup.parse(parentHtml); Element parent = parentDoc.body(); Document childDoc = Jsoup.parse(childHtml); ...
#vulnerable code @Test public void testAppendTo() { String parentHtml = "<div class='a'></div>"; String childHtml = "<div class='b'></div>"; Element parentElement = Jsoup.parse(parentHtml).getElementsByClass("a").first(); Element childElement = Jsoup.parse(childHtml).getElementsB...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code HtmlTreeBuilder() {}
#vulnerable code Element pop() { // todo - dev, remove validation check if (stack.peekLast().nodeName().equals("td") && !state.name().equals("InCell")) Validate.isFalse(true, "pop td not in cell"); if (stack.peekLast().nodeName().equals("html")) ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static void load(EscapeMode e, String file, int size) { e.nameKeys = new String[size]; e.codeVals = new int[size]; e.codeKeys = new int[size]; e.nameVals = new String[size]; InputStream stream = Entities.class.getResourceAsStre...
#vulnerable code private static void load(EscapeMode e, String file, int size) { e.nameKeys = new String[size]; e.codeVals = new int[size]; e.codeKeys = new int[size]; e.nameVals = new String[size]; InputStream stream = Entities.class.getResource...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void outerHtml(StringBuilder accum) { new NodeTraversor(new OuterHtmlVisitor(accum, getOutputSettings())).traverse(this); }
#vulnerable code protected void outerHtml(StringBuilder accum) { new NodeTraversor(new OuterHtmlVisitor(accum, ownerDocument().outputSettings())).traverse(this); } #location 2 #vulnerability type NULL_DEREFERENCE
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public boolean matchesWord() { return !isEmpty() && Character.isLetterOrDigit(queue.charAt(pos)); }
#vulnerable code public boolean matchesWord() { return !isEmpty() && Character.isLetterOrDigit(peek()); } #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 testNextElementSiblings() { Document doc = Jsoup.parse("<ul id='ul'>" + "<li id='a'>a</li>" + "<li id='b'>b</li>" + "<li id='c'>c</li>" + "</ul>" + "<div id='div'>" + "<li id...
#vulnerable code @Test public void testNextElementSiblings() { Document doc = Jsoup.parse("<li id='a'>a</li>" + "<li id='b'>b</li>" + "<li id='c'>c</li>"); Element element = doc.getElementById("a"); List<Element> elementSiblings = elem...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testNextElementSiblings() { Document doc = Jsoup.parse("<ul id='ul'>" + "<li id='a'>a</li>" + "<li id='b'>b</li>" + "<li id='c'>c</li>" + "</ul>" + "<div id='div'>" + "<li id...
#vulnerable code @Test public void testNextElementSiblings() { Document doc = Jsoup.parse("<li id='a'>a</li>" + "<li id='b'>b</li>" + "<li id='c'>c</li>"); Element element = doc.getElementById("a"); List<Element> elementSiblings = elem...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static void load(EscapeMode e, String file, int size) { e.nameKeys = new String[size]; e.codeVals = new int[size]; e.codeKeys = new int[size]; e.nameVals = new String[size]; InputStream stream = Entities.class.getResourceAsStre...
#vulnerable code private static void load(EscapeMode e, String file, int size) { e.nameKeys = new String[size]; e.codeVals = new int[size]; e.codeKeys = new int[size]; e.nameVals = new String[size]; InputStream stream = Entities.class.getResource...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code void outerHtmlHead(StringBuilder accum, int depth) { String html = StringEscapeUtils.escapeHtml(getWholeText()); if (parent() instanceof Element && !((Element) parent()).preserveWhitespace()) { html = normaliseWhitespace(html); } i...
#vulnerable code void outerHtml(StringBuilder accum) { String html = StringEscapeUtils.escapeHtml(getWholeText()); if (parent() instanceof Element && !((Element) parent()).preserveWhitespace()) { html = normaliseWhitespace(html); } if (siblin...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static Document load(File in, String charsetName, String baseUri) throws IOException { InputStream inStream = null; try { inStream = new FileInputStream(in); ByteBuffer byteData = readToByteBuffer(inStream); return pa...
#vulnerable code public static Document load(File in, String charsetName, String baseUri) throws IOException { InputStream inStream = new FileInputStream(in); ByteBuffer byteData = readToByteBuffer(inStream); Document doc = parseByteData(byteData, charsetName, ba...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public String consumeCssIdentifier() { int start = pos; while (!isEmpty() && (matchesWord() || matchesAny('-', '_'))) pos++; return queue.substring(start, pos); }
#vulnerable code public String consumeCssIdentifier() { StringBuilder accum = new StringBuilder(); Character c = peek(); while (!isEmpty() && (Character.isLetterOrDigit(c) || c.equals('-') || c.equals('_'))) { accum.append(consume()); c = ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void addChildren(int index, Node... children) { Validate.notNull(children); if (children.length == 0) { return; } final List<Node> nodes = ensureChildNodes(); // fast path - if used as a wrap (index=0, children = ...
#vulnerable code protected void addChildren(int index, Node... children) { Validate.noNullElements(children); final List<Node> nodes = ensureChildNodes(); for (Node child : children) { reparentChild(child); } nodes.addAll(index, Array...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code static String unescape(String string) { if (!string.contains("&")) return string; Matcher m = unescapePattern.matcher(string); // &(#(x|X)?([0-9a-fA-F]+)|[a-zA-Z]+);? StringBuffer accum = new StringBuffer(string.length()); // pity matcher ...
#vulnerable code static String unescape(String string) { if (!string.contains("&")) return string; Matcher m = unescapePattern.matcher(string); // &(#(x|X)?([0-9a-fA-F]+)|[a-zA-Z]+);? StringBuffer accum = new StringBuffer(string.length()); // pity ma...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static void load(EscapeMode e, String file, int size) { e.nameKeys = new String[size]; e.codeVals = new int[size]; e.codeKeys = new int[size]; e.nameVals = new String[size]; InputStream stream = Entities.class.getResourceAsStre...
#vulnerable code private static void load(EscapeMode e, String file, int size) { e.nameKeys = new String[size]; e.codeVals = new int[size]; e.codeKeys = new int[size]; e.nameVals = new String[size]; InputStream stream = Entities.class.getResource...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void parseStartTag() { tq.consume("<"); Attributes attributes = new Attributes(); String tagName = tq.consumeWord(); while (!tq.matchesAny("<", "/>", ">") && !tq.isEmpty()) { Attribute attribute = parseAttribute(); ...
#vulnerable code private void parseStartTag() { tq.consume("<"); Attributes attributes = new Attributes(); String tagName = tq.consumeWord(); while (!tq.matches("<") && !tq.matches("/>") && !tq.matches(">") && !tq.isEmpty()) { Attribute attri...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static String ihVal(String key, Document doc) { final Element first = doc.select("th:contains(" + key + ") + td").first(); return first != null ? first.text() : null; }
#vulnerable code private static String ihVal(String key, Document doc) { return doc.select("th:contains(" + key + ") + td").first().text(); } #location 2 #vulnerability type NULL_DEREFERENCE
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code void outerHtmlHead(Appendable accum, int depth, Document.OutputSettings out) throws IOException { final boolean prettyPrint = out.prettyPrint(); if (prettyPrint && ((siblingIndex() == 0 && parentNode instanceof Element && ((Element) parentNode).tag().formatAsBloc...
#vulnerable code void outerHtmlHead(Appendable accum, int depth, Document.OutputSettings out) throws IOException { if (out.prettyPrint() && ((siblingIndex() == 0 && parentNode instanceof Element && ((Element) parentNode).tag().formatAsBlock() && !isBlank()) || (out.outline() && sib...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testNamespace() throws Exception { final String namespace = "TestNamespace"; CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder(); CuratorFramework client = builder.connectString(server...
#vulnerable code @Test public void testNamespace() throws Exception { final String namespace = "TestNamespace"; CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder(); CuratorFramework client = builder.connectString(...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testNamespaceInBackground() throws Exception { CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder(); CuratorFramework client = builder.connectString(server.getConnectString()).namespace("aisa").retryPolicy(n...
#vulnerable code @Test public void testNamespaceInBackground() throws Exception { CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder(); CuratorFramework client = builder.connectString(server.getConnectString()).namespace("aisa").retryPo...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testNamespaceWithWatcher() throws Exception { CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder(); CuratorFramework client = builder.connectString(server.getConnectString()).namespace("aisa").retryPolicy(ne...
#vulnerable code @Test public void testNamespaceWithWatcher() throws Exception { CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder(); CuratorFramework client = builder.connectString(server.getConnectString()).namespace("aisa").retryPol...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void transactionObject(final String trytes) { if (StringUtils.isEmpty(trytes)) { log.warn("Warning: empty trytes in input for transactionObject"); return; } // validity check for (int i = 2279; i < 2295; i++) { ...
#vulnerable code public void transactionObject(final String trytes) { if (StringUtils.isEmpty(trytes)) { log.warn("Warning: empty trytes in input for transactionObject"); return; } // validity check for (int i = 2279; i < 2295; i...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void transactionObject(final String trytes) { if (StringUtils.isEmpty(trytes)) { log.warn("Warning: empty trytes in input for transactionObject"); return; } // validity check for (int i = 2279; i < 2295; i++) { ...
#vulnerable code public void transactionObject(final String trytes) { if (StringUtils.isEmpty(trytes)) { log.warn("Warning: empty trytes in input for transactionObject"); return; } // validity check for (int i = 2279; i < 2295; i...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public GetTransferResponse getTransfers(String seed, Integer start, Integer end, Boolean inclusionStates) throws ArgumentException, InvalidBundleException, InvalidSignatureException { // validate & if needed pad seed if ( (seed = InputValidator.validateSeed(se...
#vulnerable code public GetTransferResponse getTransfers(String seed, Integer start, Integer end, Boolean inclusionStates) throws ArgumentException, InvalidBundleException, InvalidSignatureException { start = start != null ? 0 : start; end = end == null ? null : end; ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private synchronized boolean send(byte[] bytes) { // buffering if (pendings.position() + bytes.length > pendings.capacity()) { LOG.severe("Cannot send logs to " + server.toString()); return false; } pendings.put(bytes); ...
#vulnerable code private synchronized boolean send(byte[] bytes) { // buffering if (pendings.position() + bytes.length > pendings.capacity()) { LOG.severe("Cannot send logs to " + server.toString()); return false; } pendings.put(by...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testClose() throws Exception { // use NullSender Properties props = System.getProperties(); props.setProperty(Config.FLUENT_SENDER_CLASS, NullSender.class.getName()); // create logger objects FluentLogger.getLogge...
#vulnerable code @Test public void testClose() throws Exception { // use NullSender Properties props = System.getProperties(); props.setProperty(Config.FLUENT_SENDER_CLASS, NullSender.class.getName()); // create logger objects FluentLogger.ge...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void run() { try { final Socket socket = serverSocket.accept(); Thread th = new Thread() { public void run() { try { process.process(msgpack, socket); } catch (IOException e) { // ignore } } }; th.start(); } catch (IOExcep...
#vulnerable code public void run() throws IOException { Socket socket = serverSock.accept(); BufferedInputStream in = new BufferedInputStream(socket.getInputStream()); // TODO } #location 3 #vulnerability type RESOURCE_LEA...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testClose() throws Exception { // use NullSender Properties props = System.getProperties(); props.setProperty(Config.FLUENT_SENDER_CLASS, NullSender.class.getName()); // create logger objects FluentLogger.getLogge...
#vulnerable code @Test public void testClose() throws Exception { // use NullSender Properties props = System.getProperties(); props.setProperty(Config.FLUENT_SENDER_CLASS, NullSender.class.getName()); // create logger objects FluentLogger.ge...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private synchronized boolean send(byte[] bytes) { // buffering if (pendings.position() + bytes.length > pendings.capacity()) { LOG.severe("Cannot send logs to " + server.toString()); return false; } pendings.put(bytes); ...
#vulnerable code private synchronized boolean send(byte[] bytes) { // buffering if (pendings.position() + bytes.length > pendings.capacity()) { LOG.severe("Cannot send logs to " + server.toString()); return false; } pendings.put(by...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testClose() throws Exception { // use NullSender Properties props = System.getProperties(); props.setProperty(Config.FLUENT_SENDER_CLASS, NullSender.class.getName()); // create logger objects FluentLogger.getLogge...
#vulnerable code @Test public void testClose() throws Exception { // use NullSender Properties props = System.getProperties(); props.setProperty(Config.FLUENT_SENDER_CLASS, NullSender.class.getName()); // create logger objects FluentLogger.ge...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void run() { try { final Socket socket = serverSocket.accept(); Thread th = new Thread() { public void run() { try { process.process(msgpack, socket); } catch (IOException e) { // ignore } } }; th.start(); } catch (IOExcep...
#vulnerable code public void run() throws IOException { Socket socket = serverSock.accept(); BufferedInputStream in = new BufferedInputStream(socket.getInputStream()); // TODO } #location 3 #vulnerability type RESOURCE_LEA...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testRenderMultipleObjects() { TestObject testObject = new TestObject(); // step 1: add one object. Result result = new Result(200); result.render(testObject); assertEquals(test...
#vulnerable code @Test public void testRenderMultipleObjects() { TestObject testObject = new TestObject(); // step 1: add one object. Result result = new Result(200); result.render(testObject); assertEqual...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testRenderingOfStringObjectPairsWorks() { String object1 = new String("stringy1"); String object2 = new String("stringy2"); // step 1: add one object. Result result = new Result(200); result.render("obje...
#vulnerable code @Test public void testRenderingOfStringObjectPairsWorks() { String object1 = new String("stringy1"); String object2 = new String("stringy2"); // step 1: add one object. Result result = new Result(200); result.render...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static String makeJsonRequest(String url) { Map<String, String> headers = Maps.newHashMap(); headers.put("accept", "application/json"); return makeRequest(url, headers); }
#vulnerable code public static String makeJsonRequest(String url) { StringBuffer sb = new StringBuffer(); try { DefaultHttpClient httpClient = new DefaultHttpClient(); HttpGet getRequest = new HttpGet(url); getRequest.addHeader("accept", "application/json"); HttpResponse...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testRenderEntryAndMakeSureMapIsCreated() { String stringy = new String("stringy"); // step 1: add one object. Result result = new Result(200); result.render("stringy", stringy); Map<String, Object> resul...
#vulnerable code @Test public void testRenderEntryAndMakeSureMapIsCreated() { String stringy = new String("stringy"); Entry<String, Object> entry = new SimpleImmutableEntry("stringy", stringy); // step 1: add one object. ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code static private SourceSnippet readFromInputStream(InputStream is, URI source, int lineFrom, int lineTo) throw...
#vulnerable code static private SourceSnippet readFromInputStream(InputStream is, URI source, int lineFrom, int lineTo)...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public String makeRequest(String url, Map<String, String> headers) { StringBuffer sb = new StringBuffer(); BufferedReader br = null; try { HttpGet getRequest = new HttpGet(url); if (headers != null) { // add a...
#vulnerable code public String makeRequest(String url, Map<String, String> headers) { StringBuffer sb = new StringBuffer(); try { HttpGet getRequest = new HttpGet(url); if (headers != null) { // add all headers f...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void handleTemplateException(TemplateException te, Environment env, Writer out) throws TemplateException { if (!ninjaProperties.isProd()) { // print out full stacktrace...
#vulnerable code public void handleTemplateException(TemplateException te, Environment env, Writer out) { if (ninjaProperties.isProd()) { PrintWriter pw = (out instanceof Pr...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public Object invoke(MethodInvocation invocation) throws Throwable { if (null == didWeStartWork.get()) { unitOfWork.begin(); didWeStartWork.set(Boolean.TRUE); } else { // If u...
#vulnerable code @Override public Object invoke(MethodInvocation invocation) throws Throwable { final UnitOfWork unitOfWork; // Only start a new unit of work if the entitymanager is empty // otherwise someone else has started the unit of wor...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public String makePostRequestWithFormParameters(String url, Map<String, String> headers, Map<String, String> formParameters) { StringBuffer sb = new StringBuffer()...
#vulnerable code public String makePostRequestWithFormParameters(String url, Map<String, String> headers, Map<String, String> formParameters) { StringBuffer sb = new StringBu...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testAllConstants() { Configuration configuration = SwissKnife.loadConfigurationInUtf8("conf/all_constants.conf"); assertEquals("LANGUAGES", configuration.getString(NinjaConstant.applicationLanguages)); ...
#vulnerable code @Test public void testAllConstants() { Configuration configuration = SwissKnife.loadConfigurationFromClasspathInUtf8("conf/all_constants.conf", this .getClass()); assertEquals("LANGUAGES", configurat...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public boolean runSteps(FlowSpec scenario, FlowStepStatusNotifier flowStepStatusNotifier) { LOGGER.info("\n-------------------------- Scenario:{} -------------------------\n", scenario.getFlowName()); ScenarioExecutionState scenarioExecutionSta...
#vulnerable code @Override public boolean runSteps(FlowSpec scenario, FlowStepStatusNotifier flowStepStatusNotifier) { ScenarioExecutionState scenarioExecutionState = new ScenarioExecutionState(); for(Step thisStep : scenario.getSteps()){ // Another way...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testRawRecordingSpeed() throws Exception { testRawRecordingSpeedAtExpectedInterval(1000000000); testRawRecordingSpeedAtExpectedInterval(10000); }
#vulnerable code @Test public void testRawRecordingSpeed() throws Exception { Histogram histogram = new Histogram(highestTrackableValue, numberOfSignificantValueDigits); // Warm up: long startTime = System.nanoTime(); recordLoop(histogram, warmupLoopL...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static synchronized List<Menu> loadJson() throws IOException { InputStream inStream = MenuJsonUtils.class.getResourceAsStream(config); BufferedReader reader = new BufferedReader(new InputStreamReader(inStream, Charset.forName("UTF-8"))); Strin...
#vulnerable code private static synchronized List<Menu> loadJson() throws IOException { InputStream inStream = MenuJsonUtils.class.getResourceAsStream(config); BufferedReader reader = new BufferedReader(new InputStreamReader(inStream, Charset.forName("UTF-8"))); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void postHandle(HttpServletRequest request, HttpServletResponse response, HandlerMethod handler, ModelAndView modelAndView) throws Exception { PostVO ret = (PostVO) modelAndView.getModelMap().get("view"); Object editing = modelAndView.getM...
#vulnerable code @Override public void postHandle(HttpServletRequest request, HttpServletResponse response, HandlerMethod handler, ModelAndView modelAndView) throws Exception { PostVO ret = (PostVO) modelAndView.getModelMap().get("view"); Object editing = modelAndVie...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void main(String[] args) throws Exception { // STEP-1: read input parameters and validate them if (args.length < 2) { System.err.println("Usage: SecondarySortUsingGroupByKey <input> <output>"); System.exit(1); } String inputPath ...
#vulnerable code public static void main(String[] args) throws Exception { // STEP-1: read input parameters and validate them if (args.length < 2) { System.err.println("Usage: SecondarySortUsingGroupByKey <input> <output>"); System.exit(1); } String inpu...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static CacheManager get() { return get(defaultCacheManager); }
#vulnerable code public static CacheManager get() { if (instance == null) { synchronized (log) { if (instance == null) { instance = new CacheManager(); } } } return instance; } #location 9 ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @SuppressWarnings({"unchecked", "rawtypes"}) public void onReceive(ServiceContext serviceContext) throws Throwable { FlowMessage fm = serviceContext.getFlowMessage(); if (serviceContext.isSync() && !syncActors.containsKey(serviceContext.getId())) { syncActors.pu...
#vulnerable code @SuppressWarnings({"unchecked", "rawtypes"}) public void onReceive(ServiceContext serviceContext) throws Throwable { FlowMessage fm = serviceContext.getFlowMessage(); if (serviceContext.isSync() && !syncActors.containsKey(serviceContext.getId())) { syncAct...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("ServiceFlow [ flowName = "); builder.append(flowName); builder.append("\r\n\t"); ServiceConfig hh = header; buildString(hh, builder); builder.append(...
#vulnerable code @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("ServiceFlow [\r\n\tflowName = "); builder.append(flowName); builder.append("\r\n\t"); Set<ServiceConfig> nextServices = servicesOfFlow.get(getHeadServic...
Below is the vulnerable code, please generate the patch based on the following information.