input
stringlengths
205
73.3k
output
stringlengths
64
73.2k
instruction
stringclasses
1 value
#vulnerable code @Test public void authPlain() throws IOException, MessagingException, UserException { try (Socket socket = new Socket(hostAddress, port)) { assertThat(socket.isConnected()).isTrue(); PrintStream printStream = new PrintStream(socket.ge...
#fixed code @Test public void authPlain() throws IOException { withConnection((printStream, reader) -> { // No such user assertThat(reader.readLine()).startsWith("+OK POP3 GreenMail Server v"); printStream.print("AUTH PLAIN dGVzdAB0ZXN0AHRl...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static int getLineCount(String str) { LineNumberReader reader = new LineNumberReader(new StringReader(str)); try { reader.skip(Long.MAX_VALUE); return reader.getLineNumber(); } catch (IOException e) { th...
#fixed code public static int getLineCount(String str) { if (null == str || str.isEmpty()) { return 0; } int count = 1; for (char c : str.toCharArray()) { if ('\n' == c) { count++; } } ret...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void authDisabled() throws IOException, UserException { try (Socket socket = new Socket(hostAddress, port)) { assertThat(socket.isConnected()).isTrue(); PrintStream printStream = new PrintStream(socket.getOutputStream());...
#fixed code @Test public void authDisabled() throws IOException { greenMail.getManagers().getUserManager().setAuthRequired(false); withConnection((printStream, reader) -> { assertThat(reader.readLine()).startsWith("+OK POP3 GreenMail Server v"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void authPlainWithContinuation() throws IOException, UserException { try (Socket socket = new Socket(hostAddress, port)) { assertThat(socket.isConnected()).isTrue(); PrintStream printStream = new PrintStream(socket.getOut...
#fixed code @Test public void authPlainWithContinuation() throws IOException, UserException { greenMail.getManagers().getUserManager() .createUser("test@localhost", "test", "testpass"); withConnection((printStream, reader) -> { assertThat(r...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void authPlain(Pop3Connection conn, Pop3State state, String[] args) { // https://tools.ietf.org/html/rfc4616 String initialResponse; if (args.length == 2 || args.length == 3 && "=".equals(args[2])) { // Continuation? conn.prin...
#fixed code private void authPlain(Pop3Connection conn, Pop3State state, String[] args) { // https://tools.ietf.org/html/rfc4616 String initialResponse; if (args.length == 2 || args.length == 3 && "=".equals(args[2])) { // Continuation? conn.println(CO...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void authEnabled() throws IOException, UserException { try (Socket socket = new Socket(hostAddress, port)) { assertThat(socket.isConnected()).isTrue(); PrintStream printStream = new PrintStream(socket.getOutputStream()); ...
#fixed code @Test public void authEnabled() throws IOException { greenMail.getManagers().getUserManager().setAuthRequired(true); withConnection((printStream, reader) -> { assertThat(reader.readLine()).startsWith("+OK POP3 GreenMail Server v"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void authPlain() throws IOException, MessagingException, UserException { try (Socket socket = new Socket(hostAddress, port)) { assertThat(socket.isConnected()).isTrue(); PrintStream printStream = new PrintStream(socket.ge...
#fixed code @Test public void authPlain() throws IOException { withConnection((printStream, reader) -> { // No such user assertThat(reader.readLine()).startsWith("+OK POP3 GreenMail Server v"); printStream.print("AUTH PLAIN dGVzdAB0ZXN0AHRl...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public long appendMessage(MimeMessage message, Flags flags, Date receivedDate) { long uid = nextUid; nextUid++; try { message.setFlags(flags, true); ...
#fixed code @Override public long appendMessage(MimeMessage message, Flags flags, Date receivedDate) { final long uid = nextUid.getAndIncrement(); try { message.setFlags(flags, true); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void authEnabled() throws IOException, UserException { try (Socket socket = new Socket(hostAddress, port)) { assertThat(socket.isConnected()).isTrue(); PrintStream printStream = new PrintStream(socket.getOutputStream()); ...
#fixed code @Test public void authEnabled() throws IOException { greenMail.getManagers().getUserManager().setAuthRequired(true); withConnection((printStream, reader) -> { assertThat(reader.readLine()).startsWith("+OK POP3 GreenMail Server v"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void authDisabled() throws IOException, UserException { try (Socket socket = new Socket(hostAddress, port)) { assertThat(socket.isConnected()).isTrue(); PrintStream printStream = new PrintStream(socket.getOutputStream());...
#fixed code @Test public void authDisabled() throws IOException { greenMail.getManagers().getUserManager().setAuthRequired(false); withConnection((printStream, reader) -> { assertThat(reader.readLine()).startsWith("+OK POP3 GreenMail Server v"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean waitForIncomingEmail(long timeout, int emailCount) { final SmtpManager.WaitObject waitObject = managers.getSmtpManager().createAndAddNewWaitObject(emailCount); final long endTime = System.currentTimeMillis() + timeout; ...
#fixed code @Override public boolean waitForIncomingEmail(long timeout, int emailCount) { final CountDownLatch waitObject = managers.getSmtpManager().createAndAddNewWaitObject(emailCount); final long endTime = System.currentTimeMillis() + timeout; while (w...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void authPlainWithContinuation() throws IOException, UserException { try (Socket socket = new Socket(hostAddress, port)) { assertThat(socket.isConnected()).isTrue(); PrintStream printStream = new PrintStream(socket.getOut...
#fixed code @Test public void authPlainWithContinuation() throws IOException, UserException { greenMail.getManagers().getUserManager() .createUser("test@localhost", "test", "testpass"); withConnection((printStream, reader) -> { assertThat(r...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private boolean authenticate(UserManager userManager, String value) { // authorization-id\0authentication-id\0passwd final BASE64DecoderStream stream = new BASE64DecoderStream( new ByteArrayInputStream(value.getBytes(StandardCharsets.UTF_...
#fixed code private boolean authenticate(UserManager userManager, String value) { // authorization-id\0authentication-id\0passwd final SaslMessage saslMessage = SaslMessage.parse(value); return userManager.test(saslMessage.getAuthcid(), saslMessage.getPasswd()); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public long getUidNext() { return nextUid; } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code @Override public long getUidNext() { return nextUid.get(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void authPlain() throws IOException, MessagingException, UserException { try (Socket socket = new Socket(hostAddress, port)) { assertThat(socket.isConnected()).isTrue(); PrintStream printStream = new PrintStream(socket.ge...
#fixed code @Test public void authPlain() throws IOException { withConnection((printStream, reader) -> { // No such user assertThat(reader.readLine()).startsWith("+OK POP3 GreenMail Server v"); printStream.print("AUTH PLAIN dGVzdAB0ZXN0AHRl...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void authDisabled() throws IOException, UserException { try (Socket socket = new Socket(hostAddress, port)) { assertThat(socket.isConnected()).isTrue(); PrintStream printStream = new PrintStream(socket.getOutputStream());...
#fixed code @Test public void authDisabled() throws IOException { greenMail.getManagers().getUserManager().setAuthRequired(false); withConnection((printStream, reader) -> { assertThat(reader.readLine()).startsWith("+OK POP3 GreenMail Server v"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void run() { try { serverSocket = openServerSocket(); setRunning(true); synchronized (this) { this.notifyAll(); } } catch (IOException e) { throw new Runtime...
#fixed code @Override public void run() { try { serverSocket = openServerSocket(); setRunning(true); synchronized (this) { this.notifyAll(); } synchronized (startupMonitor) { startupMo...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void authEnabled() throws IOException, UserException { try (Socket socket = new Socket(hostAddress, port)) { assertThat(socket.isConnected()).isTrue(); PrintStream printStream = new PrintStream(socket.getOutputStream()); ...
#fixed code @Test public void authEnabled() throws IOException { greenMail.getManagers().getUserManager().setAuthRequired(true); withConnection((printStream, reader) -> { assertThat(reader.readLine()).startsWith("+OK POP3 GreenMail Server v"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testMergeSelf_forceNormal() throws CardinalityMergeException, IOException { final int[] cardinalities = {0, 1, 10, 100, 1000, 10000, 100000, 1000000}; for (int cardinality : cardinalities) { for (int j = 4; j < 24; j++) ...
#fixed code @Test public void testMergeSelf_forceNormal() throws CardinalityMergeException, IOException { final int[] cardinalities = {0, 1, 10, 100, 1000, 10000, 100000, 1000000}; for (int cardinality : cardinalities) { for (int j = 4; j < 24; j++) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private ResponseEntity<String> mina(IPageData pd, JSONObject paramIn, JSONObject paramOut, String userId, List<OwnerAppUserDto> ownerAppUserDtos) { ResponseEntity<String> responseEntity = null; //查询微信信息 pd = PageData.newInstance().builder(userId...
#fixed code private ResponseEntity<String> mina(IPageData pd, JSONObject paramIn, JSONObject paramOut, String userId, List<OwnerAppUserDto> ownerAppUserDtos) { ResponseEntity<String> responseEntity = null; //查询微信信息 pd = PageData.newInstance().builder(userId, "", ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void soService(ServiceDataFlowEvent event) { DataFlowContext dataFlowContext = event.getDataFlowContext(); AppService service = event.getAppService(); JSONObject data = dataFlowContext.getReqJson(); Assert.hasKeyAn...
#fixed code @Override public void soService(ServiceDataFlowEvent event) throws ListenerExecuteException{ DataFlowContext dataFlowContext = event.getDataFlowContext(); AppService service = event.getAppService(); JSONObject data = dataFlowContext.getReqJson();...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private ResponseEntity<String> savedFloorAndUnitInfo(IPageData pd, List<ImportFloor> floors, ComponentValidateResult result) { String apiUrl = ""; JSONObject paramIn = null; ResponseEntity<String> responseEntity = null; for (ImportFloor i...
#fixed code private ResponseEntity<String> savedFloorAndUnitInfo(IPageData pd, List<ImportFloor> floors, ComponentValidateResult result) { String apiUrl = ""; JSONObject paramIn = null; ResponseEntity<String> responseEntity = new ResponseEntity<String>("成功",HttpSt...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void soService(ServiceDataFlowEvent event) { //获取数据上下文对象 DataFlowContext dataFlowContext = event.getDataFlowContext(); AppService service = event.getAppService(); String paramIn = dataFlowContext.getReqData(); ...
#fixed code @Override public void soService(ServiceDataFlowEvent event) { //获取数据上下文对象 DataFlowContext dataFlowContext = event.getDataFlowContext(); AppService service = event.getAppService(); String paramIn = dataFlowContext.getReqData(); Asser...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public List<FileDto> queryFiles(@RequestBody FileDto fileDto) { //return BeanConvertUtil.covertBeanList(fileServiceDaoImpl.getFiles(BeanConvertUtil.beanCovertMap(fileDto)), FileDto.class); List<FileDto> fileDtos = new ArrayList<>(); ...
#fixed code @Override public List<FileDto> queryFiles(@RequestBody FileDto fileDto) { //return BeanConvertUtil.covertBeanList(fileServiceDaoImpl.getFiles(BeanConvertUtil.beanCovertMap(fileDto)), FileDto.class); List<FileDto> fileDtos = new ArrayList<>(); Strin...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void validate(String paramIn) { Assert.jsonObjectHaveKey(paramIn, "communityId", "请求报文中未包含communityId节点"); Assert.jsonObjectHaveKey(paramIn, "squarePrice", "请求报文中未包含squarePrice节点"); Assert.jsonObjectHaveKey(paramIn, "additionalAmount", "请...
#fixed code private void validate(String paramIn) { Assert.jsonObjectHaveKey(paramIn, "communityId", "请求报文中未包含communityId节点"); Assert.jsonObjectHaveKey(paramIn, "squarePrice", "请求报文中未包含squarePrice节点"); Assert.jsonObjectHaveKey(paramIn, "additionalAmount", "请求报文中未包...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public List<FileDto> queryFiles(@RequestBody FileDto fileDto) { //return BeanConvertUtil.covertBeanList(fileServiceDaoImpl.getFiles(BeanConvertUtil.beanCovertMap(fileDto)), FileDto.class); List<FileDto> fileDtos = new ArrayList<>(); ...
#fixed code @Override public List<FileDto> queryFiles(@RequestBody FileDto fileDto) { //return BeanConvertUtil.covertBeanList(fileServiceDaoImpl.getFiles(BeanConvertUtil.beanCovertMap(fileDto)), FileDto.class); List<FileDto> fileDtos = new ArrayList<>(); Strin...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) { JSONObject outParam = null; ResponseEntity<String> responseEntity = null; Map<String, String> reqHeader = context.getRequestHeade...
#fixed code @Override protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) { //JSONObject outParam = null; ResponseEntity<String> responseEntity = null; Map<String, String> reqHeader = context.getRequestHeaders()...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void notify(DelegateTask delegateTask) { logger.info("查询部门审核人员"); auditUserInnerServiceSMOImpl = ApplicationContextFactory.getBean("auditUserInnerServiceSMOImpl", IAuditUserInnerServiceSMO.class); AuditUserDto auditUserDto =...
#fixed code @Override public void notify(DelegateTask delegateTask) { logger.info("查询部门审核人员"); // auditUserInnerServiceSMOImpl = ApplicationContextFactory.getBean("auditUserInnerServiceSMOImpl", IAuditUserInnerServiceSMO.class); // AuditUserDto auditUserDto = n...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private ResponseEntity<String> savedParkingSpaceInfo(IPageData pd, List<ImportParkingSpace> parkingSpaces, ComponentValidateResult result) { String apiUrl = ""; JSONObject paramIn = null; ResponseEntity<String> responseEntity = new ResponseEntity...
#fixed code private ResponseEntity<String> savedParkingSpaceInfo(IPageData pd, List<ImportParkingSpace> parkingSpaces, ComponentValidateResult result) { String apiUrl = ""; JSONObject paramIn = null; ResponseEntity<String> responseEntity = new ResponseEntity<Strin...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private JSONObject builderStaffInfo(JSONObject paramObj, DataFlowContext dataFlowContext) { //首先根据员工ID查询员工信息,根据员工信息修改相应的数据 ResponseEntity responseEntity = null; AppService appService = DataFlowFactory.getService(dataFlowContext.getAppId(), Servi...
#fixed code private JSONObject builderStaffInfo(JSONObject paramObj, DataFlowContext dataFlowContext) { UserDto userDto = new UserDto(); userDto.setStatusCd("0"); userDto.setUserId(paramObj.getString("userId")); List<UserDto> userDtos = userInnerServiceSM...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static List<com.java110.entity.order.Business> getSynchronousBusinesses(IOrderDataFlowContext dataFlow){ AppService service = null; AppRoute route = null; List<com.java110.entity.order.Business> syschronousBusinesses = new ArrayList<com.ja...
#fixed code public static List<com.java110.entity.order.Business> getSynchronousBusinesses(IOrderDataFlowContext dataFlow){ List<com.java110.entity.order.Business> syschronousBusinesses = new ArrayList<com.java110.entity.order.Business>(); for(com.java110.entity.order.Bus...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private List<Class<?>> loadClasses(StandardJavaFileManager fileManager, File classOutputFolder, List<JavaFile> classFiles) throws ClassNotFoundException, MalformedURLException { final ClassLoader loader = new URLClassLoader(new URL[] {classOutputFolder.toURI().toURL()}, ...
#fixed code private List<Class<?>> loadClasses(StandardJavaFileManager fileManager, File classOutputFolder, List<JavaFile> classFiles) throws ClassNotFoundException, MalformedURLException { final URLClassLoader loader = new URLClassLoader(new URL[] {classOutputFolder.toURI().toURL()}, fil...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private List<Class<?>> loadClasses(StandardJavaFileManager fileManager, File classOutputFolder, List<JavaFile> classFiles) throws ClassNotFoundException, MalformedURLException { final ClassLoader loader = new URLClassLoader(new URL[] {classOutputFolder.toURI().toURL()}, ...
#fixed code private List<Class<?>> loadClasses(StandardJavaFileManager fileManager, File classOutputFolder, List<JavaFile> classFiles) throws ClassNotFoundException, MalformedURLException { final URLClassLoader loader = new URLClassLoader(new URL[] {classOutputFolder.toURI().toURL()}, fil...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Object call(String method, Object[] params) throws XMLRPCException { try { Call c = createCall(method, params); URLConnection conn = this.url.openConnection(); if(!(conn instanceof HttpURLConnection)) { throw new IllegalArgumentException("The UR...
#fixed code public Object call(String method, Object[] params) throws XMLRPCException { return new Caller().call(method, params); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Object call(String method, Object[] params) throws XMLRPCException { try { Call c = createCall(method, params); URLConnection conn = this.url.openConnection(); if(!(conn instanceof HttpURLConnection)) { throw new IllegalArgumentException("The UR...
#fixed code public Object call(String method, Object[] params) throws XMLRPCException { return new Caller().call(method, params); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void canParseMilliseconds() throws Exception { Date ms500 = (Date) new DateTimeSerializer().deserialize("1985-03-04T12:21:36.5"); assertEquals(500, ms500.getTime() - new Date(85, 2, 4, 12, 21, 36).getTime()); } #location 4 ...
#fixed code @Test public void canParseMilliseconds() throws Exception { Date ms500 = (Date) new DateTimeSerializer(false).deserialize("1985-03-04T12:21:36.5"); assertEquals(500, ms500.getTime() - new Date(85, 2, 4, 12, 21, 36).getTime()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Object call(String method, Object[] params) throws XMLRPCException { try { Call c = createCall(method, params); URLConnection conn = this.url.openConnection(); if(!(conn instanceof HttpURLConnection)) { throw new IllegalArgumentException("The UR...
#fixed code public Object call(String method, Object[] params) throws XMLRPCException { return new Caller().call(method, params); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public int launch() throws Throwable { int returnCode = -1; Thread t = Thread.currentThread(); String currentThreadName = t.getName(); t.setName("Executing "+ env.displayName()); before(); try { // so that test...
#fixed code public int launch() throws Throwable { int returnCode = -1; Thread t = Thread.currentThread(); String currentThreadName = t.getName(); t.setName("Executing "+ env.displayName()); before(); try { // so that test code ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static File explodeWar(String jarPath) throws IOException { JarFile jarfile = new JarFile(new File(jarPath)); Enumeration<JarEntry> enu = jarfile.entries(); // Get current working directory path Path currentPath = FileSystems.getD...
#fixed code public static File explodeWar(String jarPath) throws IOException { try (JarFile jarfile = new JarFile(new File(jarPath))) { Enumeration<JarEntry> enu = jarfile.entries(); // Get current working directory path Path currentPath = Fil...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public int run() throws Throwable { ClassLoader jenkins = createJenkinsWarClassLoader(); ClassLoader setup = createSetupClassLoader(jenkins); Class<?> c = setup.loadClass("io.jenkins.jenkinsfile.runner.App"); return (int)c.getMethod("run...
#fixed code public int run() throws Throwable { ClassLoader jenkins = createJenkinsWarClassLoader(); ClassLoader setup = createSetupClassLoader(jenkins); Thread.currentThread().setContextClassLoader(setup); // or should this be 'jenkins'? Class<?> c =...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static File explodeWar(String jarPath) throws IOException { JarFile jarfile = new JarFile(new File(jarPath)); Enumeration<JarEntry> enu = jarfile.entries(); // Get current working directory path Path currentPath = FileSystems.getD...
#fixed code public static File explodeWar(String jarPath) throws IOException { try (JarFile jarfile = new JarFile(new File(jarPath))) { Enumeration<JarEntry> enu = jarfile.entries(); // Get current working directory path Path currentPath = Fil...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public int run() throws Throwable { ClassLoader jenkins = createJenkinsWarClassLoader(); ClassLoader setup = createSetupClassLoader(jenkins); Thread.currentThread().setContextClassLoader(setup); // or should this be 'jenkins'? try { ...
#fixed code public int run() throws Throwable { String appClassName = "io.jenkins.jenkinsfile.runner.App"; if (hasClass(appClassName)) { Class<?> c = Class.forName(appClassName); return ((IApp) c.newInstance()).run(this); } ClassLo...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void doCreateSlave(StaplerRequest req, StaplerResponse rsp, @QueryParameter String name, @QueryParameter String description, @QueryParameter int executors, @QueryParameter String remoteFsRoot, @QueryPara...
#fixed code public void doCreateSlave(StaplerRequest req, StaplerResponse rsp, @QueryParameter String name, @QueryParameter String description, @QueryParameter int executors, @QueryParameter String remoteFsRoot, @QueryParameter ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Restricted(NoExternalUse.class) public void doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { Plugin plugin = Jenkins.getInstance().getPlugin("swarm"); if (plugin != null) { plugin.doDynamic(req, r...
#fixed code @Restricted(NoExternalUse.class) public void doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { Plugin plugin = Jenkins.get().getPlugin("swarm"); if (plugin != null) { plugin.doDynamic(req, rsp); }...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressFBWarnings( value = "RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE", justification = "False positive for try-with-resources in Java 11") public void doSlaveInfo(StaplerRequest req, StaplerResponse rsp) throws IOException { Je...
#fixed code @SuppressFBWarnings( value = "RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE", justification = "False positive for try-with-resources in Java 11") public void doSlaveInfo(StaplerRequest req, StaplerResponse rsp) throws IOException { Jenkins ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Node getNodeByName(String name, StaplerResponse rsp) throws IOException { Jenkins jenkins = Jenkins.getInstance(); try { Node n = jenkins.getNode(name); if (n == null) { rsp.setStatus(SC_NOT_FOUND); ...
#fixed code private Node getNodeByName(String name, StaplerResponse rsp) throws IOException { Jenkins jenkins = Jenkins.get(); try { Node n = jenkins.getNode(name); if (n == null) { rsp.setStatus(SC_NOT_FOUND); rsp...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected int runWithJobId(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final JobId jobId, final BufferedReader stdin) throws IOException, Executi...
#fixed code @Override protected int runWithJobId(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final JobId jobId, final BufferedReader stdin) throws IOException, ExecutionExce...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected int runWithJobId(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final JobId jobId, final BufferedReader stdin) throws ExecutionException, ...
#fixed code @Override protected int runWithJobId(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final JobId jobId, final BufferedReader stdin) throws ExecutionException, Interr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void assertDockerReachable(final int probePort) throws Exception { final DockerClient docker = new DefaultDockerClient(DOCKER_HOST.uri()); try { docker.inspectImage(BUSYBOX); } catch (ImageNotFoundException e) { docker.pull(BUSYBOX); }...
#fixed code private void assertDockerReachable(final int probePort) throws Exception { try (final DefaultDockerClient docker = new DefaultDockerClient(DOCKER_HOST.uri())) { try { docker.inspectImage(BUSYBOX); } catch (ImageNotFoundException e) { docker.pull(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @After public void baseTeardown() throws Exception { tearDownJobs(); for (final HeliosClient client : clients) { client.close(); } clients.clear(); for (Service service : services) { try { service.stopAsync(); } catch (Exce...
#fixed code @After public void baseTeardown() throws Exception { tearDownJobs(); for (final HeliosClient client : clients) { client.close(); } clients.clear(); for (Service service : services) { try { service.stopAsync(); } catch (Exception ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void verifyAgentReportsDockerVersion() throws Exception { startDefaultMaster(); startDefaultAgent(testHost()); final HeliosClient client = defaultClient(); final DockerVersion dockerVersion = Polling.await( LONG_WAIT_MINUTES, MINUTE...
#fixed code @Test public void verifyAgentReportsDockerVersion() throws Exception { startDefaultMaster(); startDefaultAgent(testHost()); final HeliosClient client = defaultClient(); final DockerVersion dockerVersion = Polling.await( LONG_WAIT_MINUTES, MINUTES, new...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testDeploymentFailure() throws Exception { final long start = System.currentTimeMillis(); assertThat(testResult(TempJobFailureTestImpl.class), hasSingleFailureContaining("AssertionError: Unexpected job state")); final long e...
#fixed code @Test public void testDeploymentFailure() throws Exception { final long start = System.currentTimeMillis(); assertThat(testResult(TempJobFailureTestImpl.class), hasSingleFailureContaining("AssertionError: Unexpected job state")); final long end = S...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testReRegisterHost() throws Exception { ZooKeeperTestingServerManager testingServerManager = null; try { testingServerManager = new ZooKeeperTestingServerManager(); testingServerManager.awaitUp(5, TimeUnit.SECONDS); final Zoo...
#fixed code @Test public void testReRegisterHost() throws Exception { // Register the host & add some fake data to its status & config dirs final String idPath = Paths.configHostId(HOSTNAME); ZooKeeperRegistrarUtil.registerHost(zkClient, idPath, HOSTNAME, ID); zkClient.en...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testReRegisterHost() throws Exception { ZooKeeperTestingServerManager testingServerManager = null; try { testingServerManager = new ZooKeeperTestingServerManager(); testingServerManager.awaitUp(5, TimeUnit.SECONDS); final Zoo...
#fixed code @Test public void testReRegisterHost() throws Exception { // Register the host & add some fake data to its status & config dirs final String idPath = Paths.configHostId(HOSTNAME); ZooKeeperRegistrarUtil.registerHost(zkClient, idPath, HOSTNAME, ID); zkClient.en...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void assertDockerReachable(final int probePort) throws Exception { final DockerClient docker = new DefaultDockerClient(DOCKER_HOST.uri()); try { docker.inspectImage(BUSYBOX); } catch (ImageNotFoundException e) { docker.pull(BUSYBOX); }...
#fixed code private void assertDockerReachable(final int probePort) throws Exception { try (final DefaultDockerClient docker = new DefaultDockerClient(DOCKER_HOST.uri())) { try { docker.inspectImage(BUSYBOX); } catch (ImageNotFoundException e) { docker.pull(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private HttpURLConnection connect0(final URI ipUri, final String method, final byte[] entity, final Map<String, List<String>> headers, final String hostname, final AgentProxy agentProxy, ...
#fixed code private HttpURLConnection connect0(final URI ipUri, final String method, final byte[] entity, final Map<String, List<String>> headers, final String hostname, final AgentProxy agentProxy, ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override int run(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final BufferedReader stdin) throws ExecutionException, InterruptedException, IOException { final boolean quiet = options.getBoolean(quie...
#fixed code @Override int run(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final BufferedReader stdin) throws ExecutionException, InterruptedException, IOException { final boolean quiet = options.getBoolean(quietArg.g...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override int run(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final BufferedReader stdin) throws ExecutionException, InterruptedException { final boolean full = options.getBoolean(fullArg.getDest());...
#fixed code @Override int run(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final BufferedReader stdin) throws ExecutionException, InterruptedException { final boolean full = options.getBoolean(fullArg.getDest()); f...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected int runWithJobId(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final JobId jobId, final BufferedReader stdin) throws ExecutionException, ...
#fixed code @Override protected int runWithJobId(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final JobId jobId, final BufferedReader stdin) throws ExecutionException, Interr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected int runWithJobId(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final JobId jobId, final BufferedReader stdin) throws ExecutionException, ...
#fixed code @Override protected int runWithJobId(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final JobId jobId, final BufferedReader stdin) throws ExecutionException, Interr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected int runWithJobId(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final JobId jobId, final BufferedReader stdin) throws IOException, Executi...
#fixed code @Override protected int runWithJobId(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final JobId jobId, final BufferedReader stdin) throws IOException, ExecutionExce...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static int setGoalOnHosts(final HeliosClient client, final PrintStream out, final boolean json, final List<String> hosts, final Deployment deployment, final String token) throws Interrupted...
#fixed code public static int setGoalOnHosts(final HeliosClient client, final PrintStream out, final boolean json, final List<String> hosts, final Deployment deployment, final String token) throws InterruptedExcept...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static Builder builder(final String profile) { return new Builder(profile); } #location 2 #vulnerability type RESOURCE_LEAK
#fixed code public static Builder builder(final String profile) { return builder(profile, System.getenv()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override int run(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final BufferedReader stdin) throws ExecutionException, InterruptedException, IOException { final String jobIdString = options.getString(...
#fixed code @Override int run(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final BufferedReader stdin) throws ExecutionException, InterruptedException, IOException { final String jobIdString = options.getString(jobArg...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected int runWithJobId(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final JobId jobId, final BufferedReader stdin) throws ExecutionException, ...
#fixed code @Override protected int runWithJobId(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final JobId jobId, final BufferedReader stdin) throws ExecutionException, Interr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected int runWithJobId(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final JobId jobId, final BufferedReader stdin) throws ExecutionException, ...
#fixed code @Override protected int runWithJobId(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final JobId jobId, final BufferedReader stdin) throws ExecutionException, Interr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected ZooKeeperTestManager zooKeeperTestManager() { return new ZooKeeperTestingServerManager(zooKeeperNamespace); } #location 2 #vulnerability type RESOURCE_LEAK
#fixed code protected ZooKeeperTestManager zooKeeperTestManager() { return new ZooKeeperTestingServerManager(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static int setGoalOnHosts(final HeliosClient client, final PrintStream out, final boolean json, final List<String> hosts, final Deployment deployment, final String token) throws Interrupted...
#fixed code public static int setGoalOnHosts(final HeliosClient client, final PrintStream out, final boolean json, final List<String> hosts, final Deployment deployment, final String token) throws InterruptedExcept...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private HttpURLConnection connect0(final URI ipUri, final String method, final byte[] entity, final Map<String, List<String>> headers, final String hostname) throws IOException { if (log.i...
#fixed code private HttpURLConnection connect0(final URI ipUri, final String method, final byte[] entity, final Map<String, List<String>> headers, final String hostname) throws IOException { if (log.isTrace...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public List<String> listRecursive(final String path) throws KeeperException { assertClusterIdFlagTrue(); // namespace the path since we're using zookeeper directly final String namespace = emptyToNull(client.getNamespace()); final String names...
#fixed code @Override public List<String> listRecursive(final String path) throws KeeperException { assertClusterIdFlagTrue(); try { return ZKUtil.listSubTreeBFS(client.getZookeeperClient().getZooKeeper(), path); } catch (Exception e) { propagateIfInstanceOf(e, Ke...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override int run(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final BufferedReader stdin) throws ExecutionException, InterruptedException, IOException { final String jobIdString = options.getString(...
#fixed code @Override int run(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final BufferedReader stdin) throws ExecutionException, InterruptedException, IOException { final String jobIdString = options.getString(jobArg...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @After public void baseTeardown() throws Exception { tearDownJobs(); for (final HeliosClient client : clients) { client.close(); } clients.clear(); for (Service service : services) { try { service.stopAsync(); } catch (Exce...
#fixed code @After public void baseTeardown() throws Exception { tearDownJobs(); for (final HeliosClient client : clients) { client.close(); } clients.clear(); for (Service service : services) { try { service.stopAsync(); } catch (Exception ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected int runWithJobId(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final JobId jobId, final BufferedReader stdin) throws ExecutionException, ...
#fixed code @Override protected int runWithJobId(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final JobId jobId, final BufferedReader stdin) throws ExecutionException, Interr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected int runWithJobId(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final JobId jobId, final BufferedReader stdin) throws ExecutionException, ...
#fixed code @Override protected int runWithJobId(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final JobId jobId, final BufferedReader stdin) throws ExecutionException, Interr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private HttpURLConnection connect0(final URI ipUri, final String method, final byte[] entity, final Map<String, List<String>> headers, final String hostname) throws IOException { if (log.i...
#fixed code private HttpURLConnection connect0(final URI ipUri, final String method, final byte[] entity, final Map<String, List<String>> headers, final String hostname) throws IOException { if (log.isTrace...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void test() throws Exception { startDefaultMaster(); final String id = "test-" + toHexString(new SecureRandom().nextInt()); final String namespace = "helios-" + id; final String intruder1 = intruder(namespace); final String intruder2 = ...
#fixed code @Test public void test() throws Exception { startDefaultMaster(); final String id = "test-" + toHexString(new SecureRandom().nextInt()); final String namespace = "helios-" + id; final String intruder1 = intruder(namespace); final String intruder2 = intrud...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override int run(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final BufferedReader stdin) throws ExecutionException, InterruptedException, IOException { final boolean quiet = options.getBoolean(quie...
#fixed code @Override int run(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final BufferedReader stdin) throws ExecutionException, InterruptedException, IOException { final boolean quiet = options.getBoolean(quietArg.g...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected int runWithJobId(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final JobId jobId, final BufferedReader stdin) throws ExecutionException, ...
#fixed code @Override protected int runWithJobId(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final JobId jobId, final BufferedReader stdin) throws ExecutionException, Interr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void test() throws Exception { startDefaultMaster(); final Range<Integer> portRange = temporaryPorts.localPortRange("agent1", 2); final AgentMain agent1 = startDefaultAgent(testHost(), "--port-range=" + ...
#fixed code @Test public void test() throws Exception { startDefaultMaster(); final Range<Integer> portRange = temporaryPorts.localPortRange("agent1", 2); final AgentMain agent1 = startDefaultAgent(testHost(), "--port-range=" + ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private ZooKeeperClient setupZookeeperClient(final AgentConfig config, final String id, final CountDownLatch zkRegistrationSignal) { ACLProvider aclProvider = null; List<AuthInfo> authorization = null; if (config...
#fixed code private ZooKeeperClient setupZookeeperClient(final AgentConfig config, final String id, final CountDownLatch zkRegistrationSignal) { ACLProvider aclProvider = null; List<AuthInfo> authorization = null; if (config.isZoo...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static String getHeader() { return getHeader(WebUtil.getRequest()); } #location 2 #vulnerability type NULL_DEREFERENCE
#fixed code public static String getHeader() { return getHeader(Objects.requireNonNull(WebUtil.getRequest())); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean deleteLogic(@NotEmpty List<Integer> ids) { BladeUser user = SecureUtil.getUser(); T entity = BeanUtil.newInstance(modelClass); entity.setUpdateUser(user.getUserId()); entity.setUpdateTime(LocalDateTime.now()); return super.update(entity,...
#fixed code @Override public boolean deleteLogic(@NotEmpty List<Integer> ids) { BladeUser user = SecureUtil.getUser(); T entity = BeanUtil.newInstance(modelClass); entity.setUpdateUser(Objects.requireNonNull(user).getUserId()); entity.setUpdateTime(LocalDateTime.now()); return su...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static BladeUser getUser() { return getUser(WebUtil.getRequest()); } #location 2 #vulnerability type NULL_DEREFERENCE
#fixed code public static BladeUser getUser() { HttpServletRequest request = WebUtil.getRequest(); // 优先从 request 中获取 BladeUser bladeUser = (BladeUser) request.getAttribute(BLADE_USER_REQUEST_ATTR); if (bladeUser == null) { bladeUser = getUser(request); if (bladeUser != null) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean updateById(T entity) { BladeUser user = SecureUtil.getUser(); entity.setUpdateUser(user.getUserId()); entity.setUpdateTime(LocalDateTime.now()); return super.updateById(entity); } #location 4 ...
#fixed code @Override public boolean updateById(T entity) { BladeUser user = SecureUtil.getUser(); entity.setUpdateUser(Objects.requireNonNull(user).getUserId()); entity.setUpdateTime(LocalDateTime.now()); return super.updateById(entity); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean save(T entity) { BladeUser user = SecureUtil.getUser(); LocalDateTime now = LocalDateTime.now(); entity.setCreateUser(Objects.requireNonNull(user).getUserId()); entity.setCreateTime(now); entity.setUpdateUser(user.getUserId()); entity....
#fixed code @Override public boolean save(T entity) { BladeUser user = SecureUtil.getUser(); if (user != null) { entity.setCreateUser(user.getUserId()); entity.setUpdateUser(user.getUserId()); } LocalDateTime now = LocalDateTime.now(); entity.setCreateTime(now); entity.se...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static <T extends INode> List<T> merge(List<T> items) { ForestNodeManager<T> forestNodeManager = new ForestNodeManager<>(items); for (T forestNode : items) { if (forestNode.getParentId() != 0) { INode node = forestNodeManager.getTreeNodeAT(forestNode.getP...
#fixed code public static <T extends INode> List<T> merge(List<T> items) { List<Integer> parentIds = new ArrayList<>(); ForestNodeManager<T> forestNodeManager = new ForestNodeManager<>(items); items.forEach(forestNode -> { if (forestNode.getParentId() != 0) { INode node = fores...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Result<com.belerweb.social.weibo.bean.User> show(String source, String accessToken, String uid, String screenName) { List<NameValuePair> params = new ArrayList<NameValuePair>(); weibo.addNotNullParameter(params, "source", source); weibo.addNotNull...
#fixed code public Result<com.belerweb.social.weibo.bean.User> show(String source, String accessToken, String uid, String screenName) { List<NameValuePair> params = new ArrayList<NameValuePair>(); weibo.addNotNullParameter(params, "source", source); weibo.addNotNullParame...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Result<UserCounts> counts(String source, String accessToken, List<String> uids) { if (uids == null || uids.size() > 100) { throw new SocialException("需要获取数据的用户UID,必须且最多不超过100个"); } List<NameValuePair> params = new ArrayList<NameValuePair>(); ...
#fixed code public Result<UserCounts> counts(String source, String accessToken, List<String> uids) { if (uids == null || uids.size() > 100) { throw new SocialException("需要获取数据的用户UID,必须且最多不超过100个"); } List<NameValuePair> params = new ArrayList<NameValuePair>(); weibo....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Result<AccessToken> accessToken(String clientId, String clientSecret, String grantType, String code, String redirectUri) { List<NameValuePair> params = new ArrayList<NameValuePair>(); weibo.addParameter(params, "client_id", clientId); weibo.addPar...
#fixed code public Result<AccessToken> accessToken(String clientId, String clientSecret, String grantType, String code, String redirectUri) { List<NameValuePair> params = new ArrayList<NameValuePair>(); weibo.addParameter(params, "client_id", clientId); weibo.addParameter...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Result<com.belerweb.social.weibo.bean.User> domainShow(String source, String accessToken, String domain) { List<NameValuePair> params = new ArrayList<NameValuePair>(); weibo.addNotNullParameter(params, "source", source); weibo.addNotNullParameter(...
#fixed code public Result<com.belerweb.social.weibo.bean.User> domainShow(String source, String accessToken, String domain) { List<NameValuePair> params = new ArrayList<NameValuePair>(); weibo.addNotNullParameter(params, "source", source); weibo.addNotNullParameter(params...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Result<AccessToken> refreshAccessToken(String clientId, String clientSecret, String grantType, String refreshToken, Boolean wap) { List<NameValuePair> params = new ArrayList<NameValuePair>(); connect.addParameter(params, "client_id", clientId); co...
#fixed code public Result<AccessToken> refreshAccessToken(String clientId, String clientSecret, String grantType, String refreshToken, Boolean wap) { List<NameValuePair> params = new ArrayList<NameValuePair>(); connect.addParameter(params, "client_id", clientId); connect....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Result<AccessToken> accessToken(String clientId, String clientSecret, String grantType, String code, String redirectUri, Boolean wap) { List<NameValuePair> params = new ArrayList<NameValuePair>(); connect.addParameter(params, "client_id", clientId); ...
#fixed code public Result<AccessToken> accessToken(String clientId, String clientSecret, String grantType, String code, String redirectUri, Boolean wap) { List<NameValuePair> params = new ArrayList<NameValuePair>(); connect.addParameter(params, "client_id", clientId); con...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testUserInfo() { String accessToken = System.getProperty("weixin.atoken"); String openId = System.getProperty("weixin.openid"); Result<com.belerweb.social.weixin.bean.User> result = weixin.getUser().userInfo(accessToken, openId); ...
#fixed code @Test public void testUserInfo() { String openId = System.getProperty("weixin.openid"); Result<com.belerweb.social.weixin.bean.User> result = weixin.getUser().userInfo(weixin.getAccessToken().getToken(), openId); Assert.assertTrue(result.success()); Sy...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Result<TokenInfo> getTokenInfo(String accessToken) { List<NameValuePair> params = new ArrayList<NameValuePair>(); weibo.addParameter(params, "access_token", accessToken); String result = weibo.post("https://api.weibo.com/oauth2/get_token_info", params);...
#fixed code public Result<TokenInfo> getTokenInfo(String accessToken) { List<NameValuePair> params = new ArrayList<NameValuePair>(); weibo.addParameter(params, "access_token", accessToken); String result = weibo.post("https://api.weibo.com/oauth2/get_token_info", params); r...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void doFilter(final Logbook logbook, final HttpServletRequest httpRequest, final HttpServletResponse httpResponse, final FilterChain chain) throws ServletException, IOException { final TeeRequest request = new TeeRequest(httpReq...
#fixed code @Override public void doFilter(final Logbook logbook, final HttpServletRequest httpRequest, final HttpServletResponse httpResponse, final FilterChain chain) throws ServletException, IOException { final RemoteRequest request = new RemoteRequest(httpReq...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void doFilter(final Logbook logbook, final HttpServletRequest httpRequest, final HttpServletResponse httpResponse, final FilterChain chain) throws ServletException, IOException { final TeeRequest request = new TeeRequest(httpReq...
#fixed code @Override public void doFilter(final Logbook logbook, final HttpServletRequest httpRequest, final HttpServletResponse httpResponse, final FilterChain chain) throws ServletException, IOException { final RemoteRequest request = new RemoteRequest(httpReq...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void doFilter(final Logbook logbook, final HttpServletRequest httpRequest, final HttpServletResponse httpResponse, final FilterChain chain) throws ServletException, IOException { final TeeRequest request = new TeeRequest(httpReq...
#fixed code @Override public void doFilter(final Logbook logbook, final HttpServletRequest httpRequest, final HttpServletResponse httpResponse, final FilterChain chain) throws ServletException, IOException { final RemoteRequest request = new RemoteRequest(httpReq...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void doFilter(final Logbook logbook, final HttpServletRequest httpRequest, final HttpServletResponse httpResponse, final FilterChain chain) throws ServletException, IOException { final TeeRequest request = new TeeRequest(httpReq...
#fixed code @Override public void doFilter(final Logbook logbook, final HttpServletRequest httpRequest, final HttpServletResponse httpResponse, final FilterChain chain) throws ServletException, IOException { final RemoteRequest request = new RemoteRequest(httpReq...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldUseSameBody() throws IOException { final HttpServletResponse mock = mock(HttpServletResponse.class); when(mock.getOutputStream()).thenReturn(new ServletOutputStream() { @Override public void write(final...
#fixed code @Test public void shouldUseSameBody() throws IOException { unit.getOutputStream().write("test".getBytes()); final byte[] body1 = unit.getBody(); final byte[] body2 = unit.getBody(); assertSame(body1, body2); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public HttpRequest withBody() throws IOException { body = ByteStreams.toByteArray(getInputStream()); return this; } #location 3 #vulnerability type RESOURCE_LEAK
#fixed code @Override public HttpRequest withBody() throws IOException { body = ByteStreams.toByteArray(super.getInputStream()); return this; }
Below is the vulnerable code, please generate the patch based on the following information.