input
stringlengths
205
73.3k
output
stringlengths
64
73.2k
instruction
stringclasses
1 value
#vulnerable code @Test public void testFields() throws Exception { // GIVEN ResultBuilder builder = new ResultBuilder( "<unknown>", ParameterSupport.NO_PARAMETERS ); builder.keys( new String[]{"k1"} ); builder.record( new Value[]{value(42)} ); ...
#fixed code @Test public void testFields() throws Exception { // GIVEN ResultBuilder builder = new ResultBuilder( "<unknown>", ParameterSupport.NO_PARAMETERS ); builder.keys( new String[]{"k1"} ); builder.record( new Value[]{value(42)} ); R...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private boolean serverResponds() throws IOException, InterruptedException { try { URI uri = URI.create( DEFAULT_URL ); SocketClient client = new SocketClient( uri.getHost(), uri.getPort(), new DevNullLogger() ); cl...
#fixed code private boolean serverResponds() throws IOException, InterruptedException { try { URI uri = URI.create( DEFAULT_URL ); SocketClient client = new SocketClient( uri.getHost(), uri.getPort() ); client.start(); c...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldNotBeAbleToUseSessionWhileOngoingTransaction() throws Throwable { // Given Connection mock = mock( Connection.class ); when( mock.isOpen() ).thenReturn( true ); InternalSession sess = new InternalSession( m...
#fixed code @Test public void shouldNotBeAbleToUseSessionWhileOngoingTransaction() throws Throwable { // Given when( mock.isOpen() ).thenReturn( true ); sess.beginTransaction(); // Expect exception.expect( ClientException.class ); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public final Connection connect( BoltServerAddress address ) { Connection connection = createConnection( address, securityPlan, logging ); // Because SocketConnection is not thread safe, wrap it in this guard // to ensure concu...
#fixed code @Override public final Connection connect( BoltServerAddress address ) { Connection connection = createConnection( address, securityPlan, logging ); // Because SocketConnection is not thread safe, wrap it in this guard // to ensure concurrent ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @BeforeEach void setUp() { System.setProperty( DRIVER_METRICS_ENABLED_KEY, "true" ); logging = new LoggerNameTrackingLogging(); Config config = Config.builder() .withoutEncryption() .withLogging( logging )...
#fixed code @BeforeEach void setUp() { System.setProperty( DRIVER_METRICS_ENABLED_KEY, "true" ); logging = new LoggerNameTrackingLogging(); Config.ConfigBuilder builder = Config.builder() .withLogging( logging ) .withMaxCon...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static String resource( String fileName ) { URL resource = StubServer.class.getClassLoader().getResource( fileName ); if ( resource == null ) { fail( fileName + " does not exists" ); } return resource.getFi...
#fixed code private static String resource( String fileName ) { File resource = new File( TestNeo4j.TEST_RESOURCE_FOLDER_PATH, fileName ); if ( !resource.exists() ) { fail( fileName + " does not exists" ); } return resource.getAbsol...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void load() throws IOException { if ( !knownHosts.exists() ) { return; } assertKnownHostFileReadable(); BufferedReader reader = new BufferedReader( new FileReader( knownHosts ) ); String line; ...
#fixed code private void load() throws IOException { if ( !knownHosts.exists() ) { return; } assertKnownHostFileReadable(); try ( BufferedReader reader = new BufferedReader( new FileReader( knownHosts ) ) ) { S...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static Driver driver( URI uri, AuthToken authToken, Config config ) { // Break down the URI into its constituent parts String scheme = uri.getScheme(); BoltServerAddress address = BoltServerAddress.from( uri ); // Make sure we...
#fixed code public static Driver driver( URI uri, AuthToken authToken, Config config ) { // Make sure we have some configuration to play with config = config == null ? Config.defaultConfig() : config; return new DriverFactory().newInstance( uri, authToken, co...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldEstablishTLSConnection() throws Throwable { ConfigTest.deleteDefaultKnownCertFileIfExists(); Config config = Config.build().withTlsEnabled( true ).toConfig(); Driver driver = GraphDatabase.driver( ...
#fixed code @Test public void shouldEstablishTLSConnection() throws Throwable { ConfigTest.deleteDefaultKnownCertFileIfExists(); Config config = Config.build().withTlsEnabled( true ).toConfig(); Driver driver = GraphDatabase.driver( URI.cr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test void shouldSaveNewCert() throws Throwable { // Given int newPort = 200; BoltServerAddress address = new BoltServerAddress( knownServerIp, newPort ); Logger logger = mock(Logger.class); TrustOnFirstUseTrustManager man...
#fixed code @Test void shouldSaveNewCert() throws Throwable { // Given int newPort = 200; BoltServerAddress address = new BoltServerAddress( knownServerIp, newPort ); Logger logger = mock(Logger.class); TrustOnFirstUseTrustManager manager =...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldBeAbleToOpenTxAfterPreviousIsClosed() throws Throwable { // Given Connection mock = mock( Connection.class ); when( mock.isOpen() ).thenReturn( true ); InternalSession sess = new InternalSession( mock ); ...
#fixed code @Test public void shouldBeAbleToOpenTxAfterPreviousIsClosed() throws Throwable { // Given when( mock.isOpen() ).thenReturn( true ); sess.beginTransaction().close(); // When Transaction tx = sess.beginTransaction(); // ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldGetHelpfulErrorWhenTryingToConnectToHttpPort() throws Throwable { // Given //the http server needs some time to start up Thread.sleep( 2000 ); Driver driver = GraphDatabase.driver( "bolt://localhost:7474", ...
#fixed code @Test public void shouldGetHelpfulErrorWhenTryingToConnectToHttpPort() throws Throwable { // Given //the http server needs some time to start up Thread.sleep( 2000 ); try( Driver driver = GraphDatabase.driver( "bolt://localhost:7474", ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public final Connection connect( BoltServerAddress address ) { Connection connection = createConnection( address, securityPlan, logging ); // Because SocketConnection is not thread safe, wrap it in this guard // to ensure concu...
#fixed code @Override public final Connection connect( BoltServerAddress address ) { Connection connection = createConnection( address, securityPlan, logging ); // Because SocketConnection is not thread safe, wrap it in this guard // to ensure concurrent ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldBeAbleToUseSessionAgainWhenTransactionIsClosed() throws Throwable { // Given Connection mock = mock( Connection.class ); when( mock.isOpen() ).thenReturn( true ); InternalSession sess = new InternalSession(...
#fixed code @Test public void shouldBeAbleToUseSessionAgainWhenTransactionIsClosed() throws Throwable { // Given when( mock.isOpen() ).thenReturn( true ); sess.beginTransaction().close(); // When sess.run( "whatever" ); // Then ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Driver driverWithPool( ConnectionPool pool ) { Logging logging = DEV_NULL_LOGGING; RoutingSettings settings = new RoutingSettings( 10, 5_000, null ); AsyncConnectionPool asyncConnectionPool = mock( AsyncConnectionPool.class ); ...
#fixed code private Driver driverWithPool( ConnectionPool pool ) { Logging logging = DEV_NULL_LOGGING; RoutingSettings settings = new RoutingSettings( 10, 5_000, null ); AsyncConnectionPool asyncConnectionPool = mock( AsyncConnectionPool.class ); when(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldEstablishTLSConnection() throws Throwable { Config config = Config.build().withEncryptionLevel( Config.EncryptionLevel.REQUIRED ).toConfig(); Driver driver = GraphDatabase.driver( URI.create( Neo4jRunner....
#fixed code @Test public void shouldEstablishTLSConnection() throws Throwable { Config config = Config.build().withEncryptionLevel( Config.EncryptionLevel.REQUIRED ).toConfig(); try( Driver driver = GraphDatabase.driver( URI.create( Neo4jRunner.DEFAULT_URL ), co...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings( "ConstantConditions" ) @Test public void shouldHandleNullAuthToken() throws Throwable { // Given AuthToken token = null; Driver driver = GraphDatabase.driver( neo4j.address(), token); Session session = drive...
#fixed code @SuppressWarnings( "ConstantConditions" ) @Test public void shouldHandleNullAuthToken() throws Throwable { // Given AuthToken token = null; try ( Driver driver = GraphDatabase.driver( neo4j.address(), token ) ) { Session...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test void shouldContainTimeInformation() { // Given ResultSummary summary = session.run( "UNWIND range(1,1000) AS n RETURN n AS number" ).consume(); // Then ServerVersion serverVersion = ServerVersion.version( summary.server().v...
#fixed code @Test void shouldContainTimeInformation() { // Given ResultSummary summary = session.run( "UNWIND range(1,1000) AS n RETURN n AS number" ).consume(); // Then assertThat( summary.resultAvailableAfter( TimeUnit.MILLISECONDS ), greaterTha...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldNotAllowMoreTransactionsInSessionWhileConnectionClosed() throws Throwable { // Given Connection mock = mock( Connection.class ); when( mock.isOpen() ).thenReturn( false ); InternalSession sess = new Interna...
#fixed code @Test public void shouldNotAllowMoreTransactionsInSessionWhileConnectionClosed() throws Throwable { // Given when( mock.isOpen() ).thenReturn( false ); // Expect exception.expect( ClientException.class ); // When sess....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldNotAllowNewTxWhileOneIsRunning() throws Throwable { // Given Connection mock = mock( Connection.class ); when( mock.isOpen() ).thenReturn( true ); InternalSession sess = new InternalSession( mock ); ...
#fixed code @Test public void shouldNotAllowNewTxWhileOneIsRunning() throws Throwable { // Given when( mock.isOpen() ).thenReturn( true ); sess.beginTransaction(); // Expect exception.expect( ClientException.class ); // When ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldNotPutBackPurgedConnection() throws IOException, InterruptedException, StubServer.ForceKilled { // Given StubServer server = StubServer.start( resource( "not_reuse_connection.script" ), 9001 ); //START servers ...
#fixed code @Test public void shouldNotPutBackPurgedConnection() throws IOException, InterruptedException, StubServer.ForceKilled { // Given StubServer server = StubServer.start( resource( "not_reuse_connection.script" ), 9001 ); //START servers S...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void saveX509Cert( Certificate[] certs, File certFile ) throws GeneralSecurityException, IOException { BufferedWriter writer = new BufferedWriter( new FileWriter( certFile ) ); for ( Certificate cert : certs ) { Str...
#fixed code public static void saveX509Cert( Certificate[] certs, File certFile ) throws GeneralSecurityException, IOException { try ( BufferedWriter writer = new BufferedWriter( new FileWriter( certFile ) ) ) { for ( Certificate cert : certs ) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldKnowSessionIsClosed() throws Throwable { // Given Driver driver = GraphDatabase.driver( neo4j.address() ); Session session = driver.session(); // When session.close(); // Then asse...
#fixed code @Test public void shouldKnowSessionIsClosed() throws Throwable { // Given try( Driver driver = GraphDatabase.driver( neo4j.address() ) ) { Session session = driver.session(); // When session.close(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static String parseNeo4jVersion() { String[] split = Neo4jRunner.NEOCTRL_ARGS.split( "\\s+" ); String version = split[split.length - 1]; ServerVersion serverVersion = ServerVersion.version( NEO4J_PRODUCT + "/" + version ); ass...
#fixed code private static String parseNeo4jVersion() { String[] split = Neo4jRunner.NEOCTRL_ARGS.split( "\\s+" ); return split[split.length - 1]; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldBeAbleToUseSessionAgainWhenTransactionIsClosed() throws Throwable { // Given Connection mock = mock( Connection.class ); when( mock.isOpen() ).thenReturn( true ); InternalSession sess = new InternalSession(...
#fixed code @Test public void shouldBeAbleToUseSessionAgainWhenTransactionIsClosed() throws Throwable { // Given when( mock.isOpen() ).thenReturn( true ); sess.beginTransaction().close(); // When sess.run( "whatever" ); // Then ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldNotPutBackPurgedConnection() throws IOException, InterruptedException, StubServer.ForceKilled { // Given StubServer server = StubServer.start( "not_reuse_connection.script", 9001 ); //START servers StubSer...
#fixed code @Test public void shouldNotPutBackPurgedConnection() throws IOException, InterruptedException, StubServer.ForceKilled { // Given StubServer server = StubServer.start( "not_reuse_connection.script", 9001 ); //START servers StubServer re...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldNotCloseSessionFactoryMultipleTimes() { SessionFactory sessionFactory = sessionFactoryMock(); InternalDriver driver = newDriver( sessionFactory ); assertNull( getBlocking( driver.closeAsync() ) ); assertNu...
#fixed code @Test public void shouldNotCloseSessionFactoryMultipleTimes() { SessionFactory sessionFactory = sessionFactoryMock(); InternalDriver driver = newDriver( sessionFactory ); assertNull( await( driver.closeAsync() ) ); assertNull( await( d...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test void shouldSendReadAccessModeInStatementMetadata() throws Exception { StubServer server = StubServer.start( "hello_run_exit_read.script", 9001 ); Config config = Config.builder() .withoutEncryption() .build(...
#fixed code @Test void shouldSendReadAccessModeInStatementMetadata() throws Exception { StubServer server = StubServer.start( "hello_run_exit_read.script", 9001 ); try ( Driver driver = GraphDatabase.driver( "bolt://localhost:9001", INSECURE_CONFIG ); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldExplainConnectionError() throws Throwable { // Expect exception.expect( ClientException.class ); exception.expectMessage( "Unable to connect to 'localhost' on port 7777, ensure the database is running " + ...
#fixed code @Test public void shouldExplainConnectionError() throws Throwable { // Expect exception.expect( ClientException.class ); exception.expectMessage( "Unable to connect to 'localhost' on port 7777, ensure the database is running " + ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldBeAbleToOpenTxAfterPreviousIsClosed() throws Throwable { // Given Connection mock = mock( Connection.class ); when( mock.isOpen() ).thenReturn( true ); InternalSession sess = new InternalSession( mock ); ...
#fixed code @Test public void shouldBeAbleToOpenTxAfterPreviousIsClosed() throws Throwable { // Given when( mock.isOpen() ).thenReturn( true ); sess.beginTransaction().close(); // When Transaction tx = sess.beginTransaction(); // ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldNotPutBackPurgedConnection() throws IOException, InterruptedException, StubServer.ForceKilled { // Given StubServer server = StubServer.start( "not_reuse_connection.script", 9001 ); //START servers StubSer...
#fixed code @Test public void shouldNotPutBackPurgedConnection() throws IOException, InterruptedException, StubServer.ForceKilled { // Given StubServer server = StubServer.start( "not_reuse_connection.script", 9001 ); //START servers StubServer re...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override void assertExpectedReadQueryDistribution( Context context ) { Map<String,Long> readQueriesByServer = context.getReadQueriesByServer(); ClusterAddresses clusterAddresses = fetchClusterAddresses( driver ); // before 3.2.0 only re...
#fixed code @Override void assertExpectedReadQueryDistribution( Context context ) { Map<String,Long> readQueriesByServer = context.getReadQueriesByServer(); ClusterAddresses clusterAddresses = fetchClusterAddresses( driver ); // expect all followers to se...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldNotPutBackPurgedConnection() throws IOException, InterruptedException, StubServer.ForceKilled { // Given StubServer server = StubServer.start( resource( "not_reuse_connection.script" ), 9001 ); //START servers ...
#fixed code @Test public void shouldNotPutBackPurgedConnection() throws IOException, InterruptedException, StubServer.ForceKilled { // Given StubServer server = StubServer.start( resource( "not_reuse_connection.script" ), 9001 ); //START servers S...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static Driver driver( URI uri, AuthToken authToken, Config config ) { // Break down the URI into its constituent parts String scheme = uri.getScheme(); BoltServerAddress address = BoltServerAddress.from( uri ); // Make sure we...
#fixed code public static Driver driver( URI uri, AuthToken authToken, Config config ) { // Make sure we have some configuration to play with config = config == null ? Config.defaultConfig() : config; return new DriverFactory().newInstance( uri, authToken, co...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldSyncOnRun() throws Throwable { // Given Connection mock = mock( Connection.class ); InternalSession sess = new InternalSession( mock ); // When sess.run( "whatever" ); // Then veri...
#fixed code @Test public void shouldSyncOnRun() throws Throwable { // Given Connection mock = mock( Connection.class ); when( mock.isOpen() ).thenReturn( true ); InternalSession sess = new InternalSession( mock ); // When sess.run(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldLoadCSV() throws Throwable { // Given Driver driver = GraphDatabase.driver( neo4j.address() ); Session session = driver.session(); String csvFileUrl = createLocalIrisData( session ); // When ...
#fixed code @Test public void shouldLoadCSV() throws Throwable { // Given try( Driver driver = GraphDatabase.driver( neo4j.address() ); Session session = driver.session() ) { String csvFileUrl = createLocalIrisData( session ); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldNotAllowMoreStatementsInSessionWhileConnectionClosed() throws Throwable { // Given Connection mock = mock( Connection.class ); when( mock.isOpen() ).thenReturn( false ); InternalSession sess = new InternalS...
#fixed code @Test public void shouldNotAllowMoreStatementsInSessionWhileConnectionClosed() throws Throwable { // Given when( mock.isOpen() ).thenReturn( false ); // Expect exception.expect( ClientException.class ); // When sess.ru...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldNotAllowNewTxWhileOneIsRunning() throws Throwable { // Given Connection mock = mock( Connection.class ); when( mock.isOpen() ).thenReturn( true ); InternalSession sess = new InternalSession( mock ); ...
#fixed code @Test public void shouldNotAllowNewTxWhileOneIsRunning() throws Throwable { // Given when( mock.isOpen() ).thenReturn( true ); sess.beginTransaction(); // Expect exception.expect( ClientException.class ); // When ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void loadX509Cert( File certFile, KeyStore keyStore ) throws GeneralSecurityException, IOException { BufferedInputStream inputStream = new BufferedInputStream( new FileInputStream( certFile ) ); CertificateFactory certFactory = Certific...
#fixed code public static void loadX509Cert( File certFile, KeyStore keyStore ) throws GeneralSecurityException, IOException { try ( BufferedInputStream inputStream = new BufferedInputStream( new FileInputStream( certFile ) ) ) { CertificateFactory certFac...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void loadX509Cert( File certFile, KeyStore keyStore ) throws GeneralSecurityException, IOException { BufferedInputStream inputStream = new BufferedInputStream( new FileInputStream( certFile ) ); CertificateFactory certFactory = Certific...
#fixed code public static void loadX509Cert( File certFile, KeyStore keyStore ) throws GeneralSecurityException, IOException { try ( BufferedInputStream inputStream = new BufferedInputStream( new FileInputStream( certFile ) ) ) { CertificateFactory certFac...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test void shouldNotSendWriteAccessModeInStatementMetadata() throws Exception { StubServer server = StubServer.start( "hello_run_exit.script", 9001 ); Config config = Config.builder() .withoutEncryption() .build()...
#fixed code @Test void shouldNotSendWriteAccessModeInStatementMetadata() throws Exception { StubServer server = StubServer.start( "hello_run_exit.script", 9001 ); try ( Driver driver = GraphDatabase.driver( "bolt://localhost:9001", INSECURE_CONFIG ); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void load() throws IOException { if ( !knownHosts.exists() ) { return; } assertKnownHostFileReadable(); BufferedReader reader = new BufferedReader( new FileReader( knownHosts ) ); String line; ...
#fixed code private void load() throws IOException { if ( !knownHosts.exists() ) { return; } assertKnownHostFileReadable(); try ( BufferedReader reader = new BufferedReader( new FileReader( knownHosts ) ) ) { S...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test @SuppressWarnings( "unchecked" ) public void connectSendsInit() { String userAgent = "agentSmith"; ConnectionSettings settings = new ConnectionSettings( basicAuthToken(), userAgent ); TestSocketConnector connector = new TestSock...
#fixed code @Test @SuppressWarnings( "unchecked" ) public void connectSendsInit() { String userAgent = "agentSmith"; ConnectionSettings settings = new ConnectionSettings( basicAuthToken(), userAgent ); RecordingSocketConnector connector = new Recording...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void saveX509Cert( String certStr, File certFile ) throws IOException { BufferedWriter writer = new BufferedWriter( new FileWriter( certFile ) ); writer.write( BEGIN_CERT ); writer.newLine(); writer.write( certStr ); ...
#fixed code public static void saveX509Cert( String certStr, File certFile ) throws IOException { try ( BufferedWriter writer = new BufferedWriter( new FileWriter( certFile ) ) ) { writer.write( BEGIN_CERT ); writer.newLine(); writ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldGetHelpfulErrorWhenTryingToConnectToHttpPort() throws Throwable { // Given //the http server needs some time to start up Thread.sleep( 2000 ); Driver driver = GraphDatabase.driver( "bolt://localhost:7474", ...
#fixed code @Test public void shouldGetHelpfulErrorWhenTryingToConnectToHttpPort() throws Throwable { // Given //the http server needs some time to start up Thread.sleep( 2000 ); try( Driver driver = GraphDatabase.driver( "bolt://localhost:7474", ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldEstablishTLSConnection() throws Throwable { Config config = Config.build().withEncryptionLevel( Config.EncryptionLevel.REQUIRED ).toConfig(); Driver driver = GraphDatabase.driver( URI.create( Neo4jRunner....
#fixed code @Test public void shouldEstablishTLSConnection() throws Throwable { Config config = Config.build().withEncryptionLevel( Config.EncryptionLevel.REQUIRED ).toConfig(); try( Driver driver = GraphDatabase.driver( URI.create( Neo4jRunner.DEFAULT_URL ), co...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testFields() throws Exception { // GIVEN ResultBuilder builder = new ResultBuilder( "<unknown>", ParameterSupport.NO_PARAMETERS ); builder.keys( new String[]{"k1"} ); builder.record( new Value[]{value(42)} ); ...
#fixed code @Test public void testFields() throws Exception { // GIVEN ResultBuilder builder = new ResultBuilder( "<unknown>", ParameterSupport.NO_PARAMETERS ); builder.keys( new String[]{"k1"} ); builder.record( new Value[]{value(42)} ); R...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void shouldNotPutBackPurgedConnection() throws IOException, InterruptedException, StubServer.ForceKilled { // Given StubServer server = StubServer.start( "not_reuse_connection.script", 9001 ); //START servers StubSer...
#fixed code @Test public void shouldNotPutBackPurgedConnection() throws IOException, InterruptedException, StubServer.ForceKilled { // Given StubServer server = StubServer.start( "not_reuse_connection.script", 9001 ); //START servers StubServer re...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void connectThrowsForUnknownAuthToken() { ConnectionSettings settings = new ConnectionSettings( mock( AuthToken.class ) ); TestSocketConnector connector = new TestSocketConnector( settings, insecure(), loggingMock() ); try ...
#fixed code @Test public void connectThrowsForUnknownAuthToken() { ConnectionSettings settings = new ConnectionSettings( mock( AuthToken.class ) ); RecordingSocketConnector connector = new RecordingSocketConnector( settings ); try { co...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static String read(File file) throws IOException { // BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8")); InputStream inStream = new FileInputStream(file); BufferedReader in = new BufferedReader(inputStreamToReader...
#fixed code public static String read(File file) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8")); String ret = new String(new byte[0], "UTF-8"); String line; while ((line = in.readLine()) != null) { ret +=...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static String read(File file) throws IOException { // BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8")); InputStream inStream = new FileInputStream(file); BufferedReader in = new BufferedReader(inputStreamToReader...
#fixed code public static String read(File file) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8")); String ret = new String(new byte[0], "UTF-8"); String line; while ((line = in.readLine()) != null) { ret +=...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) { System.out.println("********** Running Sikulix.main"); int dl = RunTime.checkArgs(args); if (dl > -1) { testNumber = dl; } if (RunTime.testing) { rt = RunTime.get(); testNumber = rt.getOpt...
#fixed code public static void main(String[] args) { System.out.println("********** Running Sikulix.main"); int dl = RunTime.checkArgs(args); if (dl > -1) { testNumber = dl; } if (RunTime.testing) { rt = RunTime.get(); testNumber = rt.getOptionNum...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) { String[] splashArgs = new String[]{ "splash", "#", "#" + Settings.SikuliVersionIDE, "", "#", "#... starting - please wait ..."}; Runtime.getRuntime().addShutdownHook(new Thread() { @Override public vo...
#fixed code public static void main(String[] args) { String[] splashArgs = new String[]{ "splash", "#", "#" + Settings.SikuliVersionIDE, "", "#", "#... starting - please wait ..."}; Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public <PSI> Iterator<Match> findAll(PSI target) throws FindFailed { lastMatches = null; Image img = null; String targetStr = target.toString(); if (target instanceof String) { targetStr = targetStr.trim(); } while (true) { try { ...
#fixed code public <PSI> Iterator<Match> findAll(PSI target) throws FindFailed { lastMatches = null; Image img = null; String targetStr = target.toString(); if (target instanceof String) { targetStr = targetStr.trim(); } while (true) { try { if (...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private int runRuby(File ruFile, String[] stmts, String[] scriptPaths) { int exitCode = 0; String stmt = ""; boolean fromIDE = false; String filename = "<script>"; try { if (null == ruFile) { log(lvl, "runRuby: running statements"); StringBuilder buffe...
#fixed code private int runRuby(File ruFile, String[] stmts, String[] scriptPaths) { int exitCode = 0; String stmt = ""; boolean fromIDE = false; String filename = "<script>"; try { if (null == ruFile) { log(lvl, "runRuby: running statements"); StringBuilder buffer = ne...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public ScreenImage capture(Rectangle rect) { Debug.log(3, "ScreenUnion: capture: " + rect); return Region.create(rect).getScreen().capture(rect); } #location 4 #vulnerability type NULL_DEREFER...
#fixed code @Override public ScreenImage capture(Rectangle rect) { Debug.log(3, "ScreenUnion: capture: " + rect); Screen s = Screen.getPrimaryScreen(); Location tl = new Location(rect.getLocation()); for (Screen sx : Screen.screens) { if (sx.contains(tl)) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static boolean unpackJar(String jarName, String folderName, boolean del) { ZipInputStream in = null; BufferedOutputStream out = null; try { if (del) { FileManager.deleteFileOrFolder(folderName); } in = new ZipInputStream(new Bu...
#fixed code public static boolean unpackJar(String jarName, String folderName, boolean del) { jarName = FileManager.slashify(jarName, false); if (!jarName.endsWith(".jar")) { jarName += ".jar"; } if (!new File(jarName).isAbsolute()) { log(-1, "unpackJar: jar pat...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) { String[] splashArgs = new String[]{ "splash", "#", "#" + Settings.SikuliVersionIDE, "", "#", "#... starting - please wait ..."}; Runtime.getRuntime().addShutdownHook(new Thread() { @Override public vo...
#fixed code public static void main(String[] args) { String[] splashArgs = new String[]{ "splash", "#", "#" + Settings.SikuliVersionIDE, "", "#", "#... starting - please wait ..."}; Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws FindFailed { System.out.println("********** Running Sikulix.main"); int dl = RunTime.checkArgs(args, RunTime.Type.API); if (dl > -1 && dl < 999) { testNumber = dl; Debug.on(3); } else { test...
#fixed code public static void main(String[] args) throws FindFailed { System.out.println("********** Running Sikulix.main"); int dl = RunTime.checkArgs(args, RunTime.Type.API); if (dl > -1 && dl < 999) { testNumber = dl; Debug.on(3); } else { testNumber...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private boolean checkPatterns(ScreenImage simg) { log(lvl + 1, "update: checking patterns"); if (!observedRegion.isObserving()) { return false; } Finder finder = null; for (String name : eventStates.keySet()) { if (!patternsToCheck()) { ...
#fixed code private boolean checkPatterns(ScreenImage simg) { log(lvl + 1, "update: checking patterns"); if (!observedRegion.isObserving()) { return false; } Finder finder = null; for (String name : eventStates.keySet()) { if (!patternsToCheck()) { c...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws FindFailed { System.out.println("********** Running Sikulix.main"); int dl = RunTime.checkArgs(args, RunTime.Type.API); if (dl > -1 && dl < 999) { testNumber = dl; Debug.on(3); } else { test...
#fixed code public static void main(String[] args) throws FindFailed { System.out.println("********** Running Sikulix.main"); int dl = RunTime.checkArgs(args, RunTime.Type.API); if (dl > -1 && dl < 999) { testNumber = dl; Debug.on(3); } else { testNumber...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code <PatternString> Component createTargetComponent(org.sikuli.script.Image img) { JLabel cause = null; JPanel dialog = new JPanel(); dialog.setLayout(new BorderLayout()); if (img.isValid()) { if (!img.isText()) { String rescale = ""; Ima...
#fixed code <PatternString> Component createTargetComponent(org.sikuli.script.Image img) { JLabel cause = null; JPanel dialog = new JPanel(); dialog.setLayout(new BorderLayout()); if (img.isValid()) { if (!img.isText()) { Image bimage = img.get(false); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private <PSI> Match doFind(PSI ptn, RepeatableFind repeating) throws IOException { Finder f = null; Match m = null; boolean findingText = false; lastFindTime = (new Date()).getTime(); ScreenImage simg; if (repeating != null && repeating._finder != ...
#fixed code private <PSI> Match doFind(PSI ptn, RepeatableFind repeating) throws IOException { Finder f = null; Match m = null; boolean findingText = false; lastFindTime = (new Date()).getTime(); ScreenImage simg; if (repeating != null && repeating._finder != null) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void cleanup() { HotkeyManager.getInstance().cleanUp(); keyUp(); mouseUp(0); } #location 3 #vulnerability type NULL_DEREFERENCE
#fixed code @Override public void cleanup() { }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Boolean handleImageMissing(Image img, boolean recap) { log(lvl, "handleImageMissing: %s (%s)", img.getName(), (recap?"recapture ":"capture missing ")); FindFailedResponse response = handleFindFailedShowDialog(img, true); if (findFailedResponse.RETRY.eq...
#fixed code private Boolean handleImageMissing(Image img, boolean recap) { log(lvl, "handleImageMissing: %s (%s)", img.getName(), (recap?"recapture ":"capture missing ")); ObserveEvent evt = null; FindFailedResponse response = findFailedResponse; if (FindFailedResponse.HAND...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void paintLoading(Graphics2D g2d) { int w = getWidth(), h = getHeight(); g2d.setColor(new Color(0, 0, 0, 200)); g2d.fillRect(0, 0, w, h); BufferedImage spinner = _loading.getFrame(); g2d.drawImage(spinner, null, w / 2 - spinner.getWidth() / 2, h / 2 - spinner.get...
#fixed code void findTarget(final String patFilename, final Location initOffset) { Thread thread = new Thread(new Runnable() { @Override public void run() { Region screenUnion = Region.create(0, 0, 1, 1); Finder f = new Finder(_simg, screenUnion); try { f.find(p...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Deprecated public static boolean addHotkey(String key, int modifiers, HotkeyListener listener) { return HotkeyManager.getInstance().addHotkey(key, modifiers, listener); } #location 3 #vulnerability type NU...
#fixed code @Deprecated public static boolean addHotkey(String key, int modifiers, HotkeyListener listener) { return Key.addHotkey(key, modifiers, listener); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static synchronized RunTime get(Type typ, String[] clArgs) { if (runTime == null) { runTime = new RunTime(); if (null != clArgs) { int debugLevel = checkArgs(clArgs, typ); if (Type.IDE.equals(typ)) { if(debugLevel == -1) {...
#fixed code public static synchronized RunTime get(Type typ, String[] clArgs) { if (runTime == null) { runTime = new RunTime(); if (null != clArgs) { int debugLevel = checkArgs(clArgs, typ); if (Type.IDE.equals(typ)) { if(debugLevel == -1) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) { String[] splashArgs = new String[]{ "splash", "#", "#" + Settings.SikuliVersionIDE, "", "#", "#... starting - please wait ..."}; Runtime.getRuntime().addShutdownHook(new Thread() { @Override public vo...
#fixed code public static void main(String[] args) { String[] splashArgs = new String[]{ "splash", "#", "#" + Settings.SikuliVersionIDE, "", "#", "#... starting - please wait ..."}; Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static int isUrlUseabel(URL aURL) { try { // HttpURLConnection.setFollowRedirects(false); HttpURLConnection con = (HttpURLConnection) aURL.openConnection(); // con.setInstanceFollowRedirects(false); con.setRequestMethod("HEAD"); int retval = con.getRe...
#fixed code public static int isUrlUseabel(URL aURL) { HttpURLConnection conn = null; try { // HttpURLConnection.setFollowRedirects(false); if (getProxy() != null) { conn = (HttpURLConnection) aURL.openConnection(getProxy()); } else { conn = (HttpURLConnection...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static int checkArgs(String[] args, Type typ) { int debugLevel = -99; List<String> options = new ArrayList<String>(); options.addAll(Arrays.asList(args)); for (int n = 0; n < options.size(); n++) { String opt = options.get(n); if (!opt.s...
#fixed code public static int checkArgs(String[] args, Type typ) { int debugLevel = -99; boolean runningScriptsWithIDE = false; List<String> options = new ArrayList<String>(); options.addAll(Arrays.asList(args)); for (int n = 0; n < options.size(); n++) { String o...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void initSikulixOptions() { SikuliRepo = null; Properties prop = new Properties(); String svf = "sikulixversion.txt"; try { InputStream is; is = clsRef.getClassLoader().getResourceAsStream("Settings/" + svf); if (is == null) { terminate...
#fixed code private void initSikulixOptions() { SikuliRepo = null; Properties prop = new Properties(); String svf = "sikulixversion.txt"; try { InputStream is; is = clsRef.getClassLoader().getResourceAsStream("Settings/" + svf); if (is == null) { t...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public <PSI> Iterator<Match> findAll(PSI target) throws FindFailed { lastMatches = null; Image img = null; String targetStr = target.toString(); if (target instanceof String) { targetStr = targetStr.trim(); } while (true) { try { ...
#fixed code public <PSI> Iterator<Match> findAll(PSI target) throws FindFailed { lastMatches = null; Image img = null; String targetStr = target.toString(); if (target instanceof String) { targetStr = targetStr.trim(); } while (true) { try { if (...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String mName = method.getName(); if ("handleAbout".equals(mName)) { SikuliIDE.getInstance().doAbout(); } else if ("handlePreferences".equals(mName)) { S...
#fixed code @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String mName = method.getName(); if ("handleAbout".equals(mName)) { sikulixIDE.doAbout(); } else if ("handlePreferences".equals(mName)) { sikulixIDE.showPrefe...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void drawScreenFrame(Graphics2D g2d, int scrId) { Rectangle rect = Screen.getBounds(scrId); Rectangle ubound = (new ScreenUnion()).getBounds(); g2d.setColor(screenFrameColor); g2d.setStroke(strokeScreenFrame); rect.x -= ubound.x; rect.y -= ...
#fixed code private void drawScreenFrame(Graphics2D g2d, int scrId) { g2d.setColor(screenFrameColor); g2d.setStroke(strokeScreenFrame); if (screenFrame == null) { screenFrame = Screen.getBounds(scrId); Rectangle ubound = scrOCP.getBounds(); screenFrame.x -= ub...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void clearCache(int maxSize) { Image first; while (images.size() > 0 && currentMemory > maxSize) { first = images.remove(0); first.bimg = null; currentMemory -= first.bsize; } if (maxSize == 0) { currentMemory = 0; ...
#fixed code public static void clearCache(int maxSize) { currentMemoryChange(0, maxSize); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static boolean unzip(File fZip, File fTarget) { String fpZip = null; String fpTarget = null; try { fpZip = fZip.getCanonicalPath(); if (!fZip.exists()) { log(-1, "unzip: source not found:\n%s", fpZip); return false; } ...
#fixed code public static boolean unzip(File fZip, File fTarget) { String fpZip = null; String fpTarget = null; log(lvl, "unzip: from: %s\nto: %s", fZip, fTarget); try { fpZip = fZip.getCanonicalPath(); if (!new File(fpZip).exists()) { throw new IOExcept...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Deprecated public static boolean removeHotkey(char key, int modifiers) { return HotkeyManager.getInstance().removeHotkey(key, modifiers); } #location 3 #vulnerability type NULL_DEREFERENCE
#fixed code @Deprecated public static boolean removeHotkey(char key, int modifiers) { return Key.removeHotkey(key, modifiers); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public <PSI> Match wait(PSI target, double timeout) throws FindFailed { RepeatableFind rf; lastMatch = null; //Image img = null; String targetStr = target.toString(); if (target instanceof String) { targetStr = targetStr.trim(); } while (...
#fixed code public <PSI> Match wait(PSI target, double timeout) throws FindFailed { lastMatch = null; FindFailed shouldAbort = null; RepeatableFind rf = new RepeatableFind(target, null); Image img = rf._image; String targetStr = img.getName(); Boolean response = tru...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) { String[] splashArgs = new String[]{ "splash", "#", "#" + Settings.SikuliVersionIDE, "", "#", "#... starting - please wait ..."}; Runtime.getRuntime().addShutdownHook(new Thread() { @Override public vo...
#fixed code public static void main(String[] args) { String[] splashArgs = new String[]{ "splash", "#", "#" + Settings.SikuliVersionIDE, "", "#", "#... starting - please wait ..."}; Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws FindFailed { System.out.println("********** Running Sikulix.main"); int dl = RunTime.checkArgs(args, RunTime.Type.API); if (dl > -1 && dl < 999) { testNumber = dl; Debug.on(3); } else { test...
#fixed code public static void main(String[] args) throws FindFailed { System.out.println("********** Running Sikulix.main"); int dl = RunTime.checkArgs(args, RunTime.Type.API); if (dl > -1 && dl < 999) { testNumber = dl; Debug.on(3); } else { testNumber...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D) g; if (getWidth() > 0 && getHeight() > 0) { if (_match != null) { zoomToMatch(); paintSubScreen(g2d); paintMatch(g2d); } else { paintPatternOnly(g2d); } paintR...
#fixed code @Override public void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D) g; if (getWidth() > 0 && getHeight() > 0) { if (_match != null) { zoomToMatch(); paintSubScreen(g2d); paintMatch(g2d); } else { paintPatternOnly(g2d); } // paintRuler...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public <PSI> Iterator<Match> findAll(PSI target) throws FindFailed { lastMatches = null; Image img = null; String targetStr = target.toString(); if (target instanceof String) { targetStr = targetStr.trim(); } while (true) { try { ...
#fixed code public <PSI> Iterator<Match> findAll(PSI target) throws FindFailed { lastMatches = null; RepeatableFindAll rf = new RepeatableFindAll(target, null); Image img = rf._image; String targetStr = img.getName(); Boolean response = true; if (!img.isValid() && i...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void loadFile(String filename) { log(lvl, "loadfile: %s", filename); filename = FileManager.slashify(filename, false); setSrcBundle(filename + "/"); File script = new File(filename); _editingFile = ScriptRunner.getScriptFile(script); if (_editingFile !...
#fixed code public void loadFile(String filename) { log(lvl, "loadfile: %s", filename); filename = FileManager.slashify(filename, false); setSrcBundle(filename + "/"); File script = new File(filename); _editingFile = ScriptRunner.getScriptFile(script); if (_editingFile != null...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void initBeforeLoad(String scriptType, boolean reInit) { String scrType = null; boolean paneIsEmpty = false; if (scriptType == null) { scriptType = Settings.EDEFAULT; paneIsEmpty = true; } if (Settings.EPYTHON.equals(scriptType)) { scrType = Set...
#fixed code public void initBeforeLoad(String scriptType, boolean reInit) { String scrType = null; boolean paneIsEmpty = false; log(lvl, "initBeforeLoad: %s", scriptType); if (scriptType == null) { scriptType = Settings.EDEFAULT; paneIsEmpty = true; } if (Settings.EPYT...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws FindFailed { System.out.println("********** Running Sikulix.main"); int dl = RunTime.checkArgs(args, RunTime.Type.API); if (dl > -1 && dl < 999) { testNumber = dl; Debug.on(3); } else { test...
#fixed code public static void main(String[] args) throws FindFailed { System.out.println("********** Running Sikulix.main"); int dl = RunTime.checkArgs(args, RunTime.Type.API); if (dl > -1 && dl < 999) { testNumber = dl; Debug.on(3); } else { testNumber...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public <PSI> Iterator<Match> findAll(PSI target) throws FindFailed { lastMatches = null; Image img = null; String targetStr = target.toString(); if (target instanceof String) { targetStr = targetStr.trim(); } while (true) { try { ...
#fixed code public <PSI> Iterator<Match> findAll(PSI target) throws FindFailed { lastMatches = null; Image img = null; String targetStr = target.toString(); if (target instanceof String) { targetStr = targetStr.trim(); } while (true) { try { if (...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static int checkArgs(String[] args, Type typ) { int debugLevel = -99; List<String> options = new ArrayList<String>(); options.addAll(Arrays.asList(args)); for (int n = 0; n < options.size(); n++) { String opt = options.get(n); if (!opt.s...
#fixed code public static int checkArgs(String[] args, Type typ) { int debugLevel = -99; boolean runningScriptsWithIDE = false; List<String> options = new ArrayList<String>(); options.addAll(Arrays.asList(args)); for (int n = 0; n < options.size(); n++) { String o...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws FindFailed { System.out.println("********** Running Sikulix.main"); int dl = RunTime.checkArgs(args, RunTime.Type.API); if (dl > -1 && dl < 999) { testNumber = dl; Debug.on(3); } else { test...
#fixed code public static void main(String[] args) throws FindFailed { System.out.println("********** Running Sikulix.main"); if (args.length > 1 && args[0].toLowerCase().startsWith("runserver")) { if (args[1].toLowerCase().contains("start")) { RunServer.run(nul...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void drawSelection(Graphics2D g2d) { if (srcx != destx || srcy != desty) { int x1 = (srcx < destx) ? srcx : destx; int y1 = (srcy < desty) ? srcy : desty; int x2 = (srcx > destx) ? srcx : destx; int y2 = (srcy > desty) ? srcy : desty; ...
#fixed code private void drawSelection(Graphics2D g2d) { if (srcx != destx || srcy != desty) { int x1 = (srcx < destx) ? srcx : destx; int y1 = (srcy < desty) ? srcy : desty; int x2 = (srcx > destx) ? srcx : destx; int y2 = (srcy > desty) ? srcy : desty; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Deprecated public static boolean removeHotkey(String key, int modifiers) { return HotkeyManager.getInstance().removeHotkey(key, modifiers); } #location 3 #vulnerability type NULL_DEREFERENCE
#fixed code @Deprecated public static boolean removeHotkey(String key, int modifiers) { return Key.removeHotkey(key, modifiers); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) { Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { log(lvl, "final cleanup"); if (isRunning != null) { try { isRunningFile.close(); ...
#fixed code public static void main(String[] args) { Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { log(lvl, "final cleanup"); if (isRunning != null) { try { isRunningFile.close(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static String getFilenameFromImage(BufferedImage img){ if (! PreferencesUser.getInstance().getPrefMoreTextOCR()) { return ""; } TextRecognizer tr = TextRecognizer.getInstance(); String text = tr.recognize(img); text = text.replaceAll("\\W"...
#fixed code public static String getFilenameFromImage(BufferedImage img){ TextRecognizer tr = TextRecognizer.getInstance(); if (! PreferencesUser.getInstance().getPrefMoreTextOCR() || tr == null) { return ""; } String text = tr.recognize(img); text = text.replaceA...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void drawMessage(Graphics2D g2d) { if (promptMsg == null) { return; } g2d.setFont(fontMsg); g2d.setColor(new Color(1f, 1f, 1f, 1)); int sw = g2d.getFontMetrics().stringWidth(promptMsg); int sh = g2d.getFontMetrics().getMaxAscent(); Rectan...
#fixed code void drawMessage(Graphics2D g2d) { if (promptMsg == null) { return; } g2d.setFont(fontMsg); g2d.setColor(new Color(1f, 1f, 1f, 1)); int sw = g2d.getFontMetrics().stringWidth(promptMsg); int sh = g2d.getFontMetrics().getMaxAscent(); // Rectangle ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected static int move(Location loc, Region region) { if (get().device.isSuspended()) { return 0; } if (loc != null) { IRobot r = null; r = Screen.getMouseRobot(); if (r == null) { return 0; } if (!r.isRemote()) {...
#fixed code protected static int move(Location loc, Region region) { if (get().device.isSuspended()) { return 0; } if (loc != null) { IRobot r = null; r = loc.getScreen().getRobot(); if (r == null) { return 0; } if (!r.isRemote()) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void update(EventSubject es) { OverlayCapturePrompt cp = null; ScreenImage simg = cp.getSelection(); Screen.closePrompt(); if (simg != null) { try { Thread.sleep(300); } catch (InterruptedException ie) { } ...
#fixed code @Override public void update(EventSubject es) { OverlayCapturePrompt ocp = (OverlayCapturePrompt) es; ScreenImage simg = ocp.getSelection(); Screen.closePrompt(); if (simg != null) { try { Thread.sleep(300); } catch (InterruptedException ie...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static String input(String msg, String preset, String title, boolean hidden) { JFrame anchor = popLocation(); String ret = ""; if (!hidden) { if ("".equals(title)) { title = "Sikuli input request"; } ret = (String) JOptionPane....
#fixed code public static String input(String msg, String preset, String title, boolean hidden) { JFrame anchor = popLocation(); String ret = ""; if (!hidden) { if ("".equals(title)) { title = "Sikuli input request"; } ret = (String) JOptionPane.showIn...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void update(EventSubject es) { OverlayCapturePrompt cp = null; ScreenImage simg = cp.getSelection(); Screen.closePrompt(); if (simg != null) { try { Thread.sleep(300); } catch (InterruptedException ie) { } ...
#fixed code @Override public void update(EventSubject es) { OverlayCapturePrompt ocp = (OverlayCapturePrompt) es; ScreenImage simg = ocp.getSelection(); Screen.closePrompt(); if (simg != null) { try { Thread.sleep(300); } catch (InterruptedException ie...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws FindFailed { System.out.println("********** Running Sikulix.main"); int dl = RunTime.checkArgs(args, RunTime.Type.API); if (dl > -1 && dl < 999) { testNumber = dl; Debug.on(3); } else { test...
#fixed code public static void main(String[] args) throws FindFailed { System.out.println("********** Running Sikulix.main"); int dl = RunTime.checkArgs(args, RunTime.Type.API); if (dl > -1 && dl < 999) { testNumber = dl; Debug.on(3); } else { testNumber...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public String saveCapture(String name, Region reg) { ScreenImage img; if (reg == null) { img = userCapture("Capture for image " + name); } else { img = capture(reg); } img.saveInBundle(name); return name; } ...
#fixed code public String saveCapture(String name, Region reg) { ScreenImage img; if (reg == null) { img = userCapture("Capture for image " + name); } else { img = capture(reg); } if (img == null) { return null; } else { return img.saveInBund...
Below is the vulnerable code, please generate the patch based on the following information.