instruction
stringclasses
1 value
output
stringlengths
64
69.4k
input
stringlengths
205
32.4k
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void reload(boolean optimize) throws IOException, URISyntaxException, SearchLibException, InstantiationException, IllegalAccessException, ClassNotFoundException { if (optimize) { urlDbClient.reload(null); urlDbClient.getIndex().optimize(null); targetClien...
#vulnerable code public void reload(boolean optimize) throws IOException, URISyntaxException, SearchLibException, InstantiationException, IllegalAccessException, ClassNotFoundException { if (optimize) { client.reload(null); client.getIndex().optimize(null); } client.reloa...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static HTMLDocument fetch(final URL url) throws IOException { final URLConnection conn = url.openConnection(); final String ct = conn.getContentType(); Charset cs = Charset.forName("Cp1252"); if (ct != null) { Matcher m = PAT_CHARSET.matcher(ct); if(m.find(...
#vulnerable code public static HTMLDocument fetch(final URL url) throws IOException { final URLConnection conn = url.openConnection(); final String charset = conn.getContentEncoding(); Charset cs = Charset.forName("Cp1252"); if (charset != null) { try { cs = Charset.forName...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public String getText(final URL url) throws BoilerpipeProcessingException { try { return getText(HTMLFetcher.fetch(url).toInputSource()); } catch (IOException e) { throw new BoilerpipeProcessingException(e); } }
#vulnerable code public String getText(final URL url) throws BoilerpipeProcessingException { try { final URLConnection conn = url.openConnection(); final String encoding = conn.getContentEncoding(); Charset cs = Charset.forName("Cp1252"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void insertLoginLog(String username) { UmsAdmin admin = getAdminByUsername(username); if(admin==null) return; UmsAdminLoginLog loginLog = new UmsAdminLoginLog(); loginLog.setAdminId(admin.getId()); loginLog.setCreateTime(new Dat...
#vulnerable code private void insertLoginLog(String username) { UmsAdmin admin = getAdminByUsername(username); UmsAdminLoginLog loginLog = new UmsAdminLoginLog(); loginLog.setAdminId(admin.getId()); loginLog.setCreateTime(new Date()); ServletReque...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public String getUserNameFromToken(String token) { String username; try { Claims claims = getClaimsFromToken(token); username = claims.getSubject(); } catch (Exception e) { username = null; } return ...
#vulnerable code public String getUserNameFromToken(String token) { String username; try { Claims claims = getClaimsFromToken(token); username = claims.getSubject(); } catch (Exception e) { e.printStackTrace(); user...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void onHttpFinish(QQHttpResponse response) { try { LOG.debug(response.getContentType()); String type = response.getContentType(); if(type!=null && (type.startsWith("application/x-javascript") || type.startsWith("application/json") || type.i...
#vulnerable code @Override public void onHttpFinish(QQHttpResponse response) { try { LOG.debug(response.getContentType()); String type = response.getContentType(); if((type.startsWith("application/x-javascript") || type.startsWith("application/json") || type.indexOf("...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @org.junit.Test public void test() throws InterruptedException, IOException { Node node = new MasterSlaveNode(); node.join(); new BufferedReader(new InputStreamReader(System.in)).readLine(); }
#vulnerable code @org.junit.Test public void test() throws InterruptedException, IOException { Node node = new MasterSlaveNode(new Configuration("com.zuoxiaolong.niubi.job.jobs"), "localhost:2181,localhost:3181,localhost:4181"); node.join(); new BufferedReade...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @org.junit.Test public void test() throws InterruptedException, IOException { Node node = new StandbyNode(); node.join(); new BufferedReader(new InputStreamReader(System.in)).readLine(); }
#vulnerable code @org.junit.Test public void test() throws InterruptedException, IOException { Node node = new StandbyNode(new Configuration("com.zuoxiaolong.niubi.job.jobs"), "localhost:2181,localhost:3181,localhost:4181"); node.join(); new BufferedReader(ne...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @org.junit.Test public void test() throws InterruptedException, IOException { Node node = new MasterSlaveNode(); node.join(); new BufferedReader(new InputStreamReader(System.in)).readLine(); }
#vulnerable code @org.junit.Test public void test() throws InterruptedException, IOException { Node node = new MasterSlaveNode(new Configuration("com.zuoxiaolong.niubi.job.jobs"), "localhost:2181,localhost:3181,localhost:4181"); node.join(); new BufferedReade...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public ExactRelation rewriteWithSubsampledErrorBounds() { ExactRelation r = rewriteWithPartition(); // List<SelectElem> selectElems = r.selectElemsWithAggregateSource(); List<SelectElem> selectElems = ((AggregatedRelation) r).getAggList(); // another wrapper...
#vulnerable code @Override public ExactRelation rewriteWithSubsampledErrorBounds() { ExactRelation r = rewriteWithPartition(); // List<SelectElem> selectElems = r.selectElemsWithAggregateSource(); List<SelectElem> selectElems = ((AggregatedRelation) r).getAggList(); // another w...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public List<Pair<String, Integer>> getColumns(String schema, String table) throws SQLException { if (!columnsCache.isEmpty()){ return columnsCache; } columnsCache.addAll(connection.getColumns(schema, table)); return columnsCache; }
#vulnerable code public List<Pair<String, Integer>> getColumns(String schema, String table) throws SQLException { if (!columnsCache.isEmpty()){ return columnsCache; } DbmsQueryResult queryResult = connection.executeQuery(syntax.getColumnsCommand(schema, table)); Jdbc...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code void addParent(QueryExecutionNode parent) { parents.add(parent); }
#vulnerable code void print(int indentSpace) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < indentSpace; i++) { builder.append(" "); } builder.append(this.toString()); System.out.println(builder.toString()); for (QueryExecutionNode de...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public List<String> getTables(String schema) throws SQLException { if (!tablesCache.isEmpty()){ return tablesCache; } tablesCache.addAll(connection.getTables(schema)); return tablesCache; }
#vulnerable code public List<String> getTables(String schema) throws SQLException { if (!tablesCache.isEmpty()){ return tablesCache; } DbmsQueryResult queryResult = connection.executeQuery(syntax.getTableCommand(schema)); JdbcResultSet jdbcQueryResult = new JdbcResul...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public List<String> getPartitionColumns(String schema, String table) throws VerdictDBDbmsException { List<String> partition = new ArrayList<>(); DbmsQueryResult queryResult = execute(syntax.getPartitionCommand(schema, table)); while (queryResult.next()) ...
#vulnerable code @Override public List<String> getPartitionColumns(String schema, String table) throws VerdictDBDbmsException { List<String> partition = new ArrayList<>(); DbmsQueryResult queryResult = execute(syntax.getPartitionCommand(schema, table)); JdbcResultSet jdbcRes...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public List<String> getTables(String schema) throws VerdictDBDbmsException { List<String> tables = new ArrayList<>(); DbmsQueryResult queryResult = execute(syntax.getTableCommand(schema)); while (queryResult.next()) { tables.add((String) queryResul...
#vulnerable code @Override public List<String> getTables(String schema) throws VerdictDBDbmsException { List<String> tables = new ArrayList<>(); DbmsQueryResult queryResult = execute(syntax.getTableCommand(schema)); JdbcResultSet jdbcResultSet = new JdbcResultSet(queryResult...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testExecuteNode() throws VerdictDBException { BaseTable base = new BaseTable(originalSchema, originalTable, "t"); SelectQuery query = SelectQuery.create(Arrays.<SelectItem>asList(new AsteriskColumn()), base); QueryExecutionNode root = CreateTable...
#vulnerable code @Test public void testExecuteNode() throws VerdictDBException { BaseTable base = new BaseTable(originalSchema, originalTable, "t"); SelectQuery query = SelectQuery.create(Arrays.<SelectItem>asList(new AsteriskColumn()), base); QueryExecutionNode root = Creat...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override protected Map<TableUniqueName, String> tableSubstitution() { return source.tableSubstitution(); }
#vulnerable code @Override protected Map<TableUniqueName, String> tableSubstitution() { return ImmutableMap.of(); } #location 2 #vulnerability type CHECKERS_IMMUTABLE_CAST
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public List<String> getSchemas() throws SQLException { if (!schemaCache.isEmpty()){ return schemaCache; } schemaCache.addAll(connection.getSchemas()); return schemaCache; }
#vulnerable code public List<String> getSchemas() throws SQLException { if (!schemaCache.isEmpty()){ return schemaCache; } DbmsQueryResult queryResult = connection.executeQuery(syntax.getSchemaCommand()); JdbcResultSet jdbcQueryResult = new JdbcResultSet(queryResult)...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testSingleAggCombiningWithH2() throws VerdictDBDbmsException, VerdictDBException { QueryExecutionPlan plan = new QueryExecutionPlan("newschema"); BaseTable base = new BaseTable(originalSchema, originalTable, "t"); SelectQuery leftQuery = Sel...
#vulnerable code @Test public void testSingleAggCombiningWithH2() throws VerdictDBDbmsException, VerdictDBException { QueryExecutionPlan plan = new QueryExecutionPlan("newschema"); BaseTable base = new BaseTable(originalSchema, originalTable, "t"); SelectQuery leftQuery...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public String visitSelect_list_elem(VerdictSQLParser.Select_list_elemContext ctx) { select_list_elem_num++; String newSelectListElem = null; Pair<String, Alias> colName2Alias = null; if (ctx.getText().equals("*")) { // TODO: replace * with all columns in...
#vulnerable code @Override public String visitSelect_list_elem(VerdictSQLParser.Select_list_elemContext ctx) { select_list_elem_num++; String newSelectListElem = null; Pair<String, Alias> colName2Alias = null; if (ctx.getText().equals("*")) { // TODO: replace * with all colu...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void main(String[] a) throws Exception { PropertyConfigurator.configure(FoxCfg.LOG_FILE); String in = "University of Leipzig in Leipzig.."; String query = "select * from search.termextract where context="; URIBuilder builder = ...
#vulnerable code public static void main(String[] a) throws Exception { PropertyConfigurator.configure(FoxCfg.LOG_FILE); String in = "University of Leipzig in Leipzig.."; String query = "select * from search.termextract where context="; URIBuilder buil...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void toDocuments() throws GenerateException { if (outputTemplate == null) { prepareMustacheTemplate(); } if (outputTemplate.getApiDocuments().isEmpty()) { LOG.warn("nothing to write."); return; } ...
#vulnerable code public void toDocuments() throws GenerateException { if (outputTemplate == null) { prepareMustacheTemplate(); } if (outputTemplate.getApiDocuments().isEmpty()) { LOG.warn("nothing to write."); return; }...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public Swagger read(SpringResource resource) { if (swagger == null) { swagger = new Swagger(); } String description; List<Method> methods = resource.getMethods(); Map<String, Tag> tags = new HashMap<String, Tag>(); ...
#vulnerable code public Swagger read(SpringResource resource) { if (swagger == null) { swagger = new Swagger(); } List<Method> methods = resource.getMethods(); Map<String, Tag> tags = new HashMap<String, Tag>(); List<SecurityRequireme...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public Operation parseMethod(String httpMethod, Method method) { int responseCode = 200; Operation operation = new Operation(); ApiOperation apiOperation = AnnotationUtils.findAnnotation(method, ApiOperation.class); String operationId = getOpe...
#vulnerable code public Operation parseMethod(String httpMethod, Method method) { int responseCode = 200; Operation operation = new Operation(); ApiOperation apiOperation = AnnotationUtils.findAnnotation(method, ApiOperation.class); String operationId = ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private Operation parseMethod(Method method) { Operation operation = new Operation(); RequestMapping requestMapping = AnnotationUtils.findAnnotation(method, RequestMapping.class); Class<?> responseClass = null; List<String> produces = new Arra...
#vulnerable code private Operation parseMethod(Method method) { Operation operation = new Operation(); RequestMapping requestMapping = Annotations.get(method, RequestMapping.class); Class<?> responseClass = null; List<String> produces = new ArrayList<Str...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void toDocuments() throws GenerateException { if (outputTemplate == null) { prepareMustacheTemplate(); } if (outputTemplate.getApiDocuments().isEmpty()) { LOG.warn("nothing to write."); return; } ...
#vulnerable code public void toDocuments() throws GenerateException { if (outputTemplate == null) { prepareMustacheTemplate(); } if (outputTemplate.getApiDocuments().isEmpty()) { LOG.warn("nothing to write."); return; }...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private boolean stopUsingMysqldadmin() { boolean retValue = false; Reader stdOut = null; Reader stdErr = null; LogFileProcessor processor = null; Set<String> successPatterns = Sets.newHashSet( "'Can't connect to MySQL s...
#vulnerable code private boolean stopUsingMysqldadmin() { boolean retValue = false; Reader stdOut = null; Reader stdErr = null; LogFileProcessor processor = null; Set<String> successPatterns = Sets.newHashSet( "'Can't connect to M...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private boolean stopUsingMysqldadmin() { boolean retValue = false; Reader stdOut = null; Reader stdErr = null; LogFileProcessor processor = null; Set<String> successPatterns = Sets.newHashSet( "'Can't connect to MySQL s...
#vulnerable code private boolean stopUsingMysqldadmin() { boolean retValue = false; Reader stdOut = null; Reader stdErr = null; LogFileProcessor processor = null; Set<String> successPatterns = Sets.newHashSet("'Can't connect to MySQL server on 'l...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private boolean stopUsingMysqldadmin() { ResultMatchingListener shutdownListener = outputWatch.addListener(new ResultMatchingListener(": Shutdown complete")); boolean retValue = false; Reader stdErr = null; try { String cmd = Paths...
#vulnerable code private boolean stopUsingMysqldadmin() { boolean retValue = false; Reader stdOut = null; Reader stdErr = null; LogFileProcessor processor = null; Set<String> successPatterns = Sets.newHashSet( "'Can't connect to M...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private boolean stopUsingMysqldadmin() { boolean retValue = false; Reader stdOut = null; Reader stdErr = null; LogFileProcessor processor = null; Set<String> successPatterns = Sets.newHashSet( "'Can't connect to MySQL s...
#vulnerable code private boolean stopUsingMysqldadmin() { boolean retValue = false; Reader stdOut = null; Reader stdErr = null; LogFileProcessor processor = null; Set<String> successPatterns = Sets.newHashSet("'Can't connect to MySQL server on 'l...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected SettableBeanProperty _resolvedObjectIdProperty(DeserializationContext ctxt, SettableBeanProperty prop) throws JsonMappingException { ObjectIdInfo objectIdInfo = prop.getObjectIdInfo(); JsonDeserializer<Object> valueDeser = prop.getVal...
#vulnerable code protected SettableBeanProperty _resolvedObjectIdProperty(DeserializationContext ctxt, SettableBeanProperty prop) throws JsonMappingException { ObjectIdInfo objectIdInfo = prop.getObjectIdInfo(); JsonDeserializer<Object> valueDeser = prop....
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void testDeepPrefixedUnwrappingDeserialize() throws Exception { DeepPrefixUnwrap bean = MAPPER.readValue("{\"u.name\":\"Bubba\",\"u._x\":2,\"u._y\":3}", DeepPrefixUnwrap.class); assertNotNull(bean.unwrapped); assertNotNull(be...
#vulnerable code public void testDeepPrefixedUnwrappingDeserialize() throws Exception { DeepPrefixUnwrap bean = mapper.readValue("{\"u.name\":\"Bubba\",\"u._x\":2,\"u._y\":3}", DeepPrefixUnwrap.class); assertNotNull(bean.unwrapped); assertNotN...
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 public void testRootBeans() throws Exception { final String JSON = aposToQuotes("{'a':3} {'x':5}"); MappingIterator<Bean> it = MAPPER.readerFor(Bean.class).readValues(JSON); // First one should be fine assertTrue(it.hasNextValue()); ...
#vulnerable code public void testRootBeans() throws Exception { final String JSON = aposToQuotes("{'a':3} {'b':5}"); MappingIterator<Bean> it = MAPPER.readerFor(Bean.class).readValues(JSON); // First one should be fine assertTrue(it.hasNextValue()); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void testAtomicLong() throws Exception { AtomicLong value = MAPPER.readValue("12345678901", AtomicLong.class); assertEquals(12345678901L, value.get()); }
#vulnerable code public void testAtomicLong() throws Exception { ObjectMapper mapper = new ObjectMapper(); AtomicLong value = mapper.readValue("12345678901", AtomicLong.class); assertEquals(12345678901L, value.get()); } #locat...
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 private AbstractSiteMap processXml(URL sitemapUrl, byte[] xmlContent) throws UnknownFormatException { BOMInputStream bomIs = new BOMInputStream(new ByteArrayInputStream(xmlContent)); InputSource is = new InputSource(); try { is.setCharacte...
#vulnerable code private AbstractSiteMap processXml(URL sitemapUrl, byte[] xmlContent) throws UnknownFormatException { BOMInputStream bomIs = new BOMInputStream(new ByteArrayInputStream(xmlContent)); InputSource is = new InputSource(); is.setCharacterStream(new ...
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 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 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 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 @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 testEncodingAttributeXML() throws Exception { final InputStream is = new ByteArrayInputStream(ENCODING_ATTRIBUTE_XML.getBytes()); final XmlReader xmlReader = new XmlReader(is, "", true); assertEquals(xmlReader.getEncoding(), "UTF-8"); ...
#vulnerable code public void testEncodingAttributeXML() throws Exception { final InputStream is = new ByteArrayInputStream(ENCODING_ATTRIBUTE_XML.getBytes()); final XmlReader xmlReader = new XmlReader(is, "", true); assertEquals(xmlReader.getEncoding(), "UTF-8");...
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 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 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 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 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 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 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 @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 boolean preserveWhitespace() { return tag.preserveWhitespace() || parent() != null && parent().preserveWhitespace(); }
#vulnerable code void outerHtmlHead(StringBuilder accum, int depth) { if (isBlock() || (parent() != null && parent().tag().canContainBlock() && siblingIndex() == 0)) indent(accum, depth); accum .append("<") .append(tagName()) ...
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 @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 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 protected void removeChild(Node out) { Validate.isTrue(out.parentNode == this); int index = out.siblingIndex(); childNodes.remove(index); reindexChildren(); out.parentNode = null; }
#vulnerable code protected void removeChild(Node out) { Validate.isTrue(out.parentNode == this); int index = indexInList(out, childNodes); childNodes.remove(index); out.parentNode = null; } #location 3 ...
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 ParseSettings defaultSettings() { return ParseSettings.htmlDefault; }
#vulnerable code void insert(Token.Character characterToken) { final Node node; final Element el = currentElement(); final String tagName = el.normalName(); final String data = characterToken.getData(); if (characterToken.isCData()) n...
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 @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 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 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 @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 parse() { Map<String,RouteParameter> params; RouteParameter param; // no named parameters is null params = RouteParameter.parse("/user"); assertThat(params, aMapWithSize(0)); params = Rout...
#vulnerable code @Test public void parse() { Map<String,RouteParameter> params; RouteParameter param; // no named parameters is null params = RouteParameter.parse("/user"); assertThat(params, is(nullValue())); params ...
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 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 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 @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 @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.
#fixed code @SuppressWarnings({"unchecked", "rawtypes"}) @Override public void onServiceContextReceived(ServiceContext serviceContext) throws Throwable { FlowMessage flowMessage = serviceContext.getFlowMessage(); if (serviceContext.isSync()) { CacheManager.get(serviceActo...
#vulnerable code @SuppressWarnings({"unchecked", "rawtypes"}) @Override public void onServiceContextReceived(ServiceContext serviceContext) throws Throwable { FlowMessage flowMessage = serviceContext.getFlowMessage(); if (serviceContext.isSync()) { CacheManager.get(servi...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void doStartup(String configLocation) throws Throwable { Class<?> applicationContextClazz = Class.forName("org.springframework.context.support.ClassPathXmlApplicationContext", true, getClassLoader()); Object flowerFactory = applicationContextC...
#vulnerable code @Override public void doStartup(String configLocation) { ClassPathXmlApplicationContext applicationContext = null; try { applicationContext = new ClassPathXmlApplicationContext(configLocation); applicationContext.start(); } catch (Exception e) {...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static List<Pair<String, String>> readFlow(String path) throws IOException { InputStreamReader fr = new InputStreamReader(FileUtil.class.getResourceAsStream(path),Constant.ENCODING_UTF_8); BufferedReader br = new BufferedReader(fr); String line; List<Pair...
#vulnerable code public static List<Pair<String, String>> readFlow(String path) throws IOException { InputStreamReader fr = new InputStreamReader(FileUtil.class.getResourceAsStream(path)); BufferedReader br = new BufferedReader(fr); String line = ""; List<Pair<String, Stri...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private EnvTypePair analyzeLooseCallNodeBwd( Node callNode, TypeEnv outEnv, JSType retType) { Preconditions.checkArgument(callNode.isCall()); Preconditions.checkNotNull(retType); Node callee = callNode.getFirstChild(); TypeEnv tmpEnv = outEnv; Function...
#vulnerable code private EnvTypePair analyzeLooseCallNodeBwd( Node callNode, TypeEnv outEnv, JSType retType) { Preconditions.checkArgument(callNode.isCall()); Preconditions.checkNotNull(retType); Node callee = callNode.getFirstChild(); TypeEnv tmpEnv = outEnv; Fu...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private List<JSSourceFile> getDefaultExterns() { try { return CommandLineRunner.getDefaultExterns(); } catch (IOException e) { throw new BuildException(e); } }
#vulnerable code private List<JSSourceFile> getDefaultExterns() { try { InputStream input = Compiler.class.getResourceAsStream( "/externs.zip"); ZipInputStream zip = new ZipInputStream(input); List<JSSourceFile> externs = Lists.newLinkedList(); for (...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void writeResult(String source) { if (this.outputFile.getParentFile().mkdirs()) { log("Created missing parent directory " + this.outputFile.getParentFile(), Project.MSG_DEBUG); } try { OutputStreamWriter out = new OutputStreamWriter( ...
#vulnerable code private void writeResult(String source) { if (this.outputFile.getParentFile().mkdirs()) { log("Created missing parent directory " + this.outputFile.getParentFile(), Project.MSG_DEBUG); } try { FileWriter out = new FileWriter(this.outputF...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private Writer fileNameToOutputWriter(String fileName) throws IOException { if (fileName == null) { return null; } if (testMode) { return new StringWriter(); } return streamToOutputWriter(filenameToOutputStream(fileName)); }
#vulnerable code private Writer fileNameToOutputWriter(String fileName) throws IOException { if (fileName == null) { return null; } if (testMode) { return new StringWriter(); } return streamToOutputWriter(new FileOutputStream(fileName)); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public List<INPUT> getSortedDependenciesOf(List<INPUT> roots) { return getDependenciesOf(roots, true); }
#vulnerable code public List<INPUT> getSortedDependenciesOf(List<INPUT> roots) { Preconditions.checkArgument(inputs.containsAll(roots)); Set<INPUT> included = Sets.newHashSet(); Deque<INPUT> worklist = new ArrayDeque<INPUT>(roots); while (!worklist.isEmpty()) { INPUT...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public Set<String> getOwnPropertyNames() { return getPropertyMap().getOwnPropertyNames(); }
#vulnerable code public Set<String> getOwnPropertyNames() { return ImmutableSet.of(); } #location 1 #vulnerability type CHECKERS_IMMUTABLE_CAST