Search in sources :

Example 1 with FunctionNotificationContainer

use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionNotificationContainer in project binnavi by google.

the class PostgreSQLFunctionNotificationParserTest method testParser.

private void testParser(final String table, final String databaseOperation, final String address, final String moduleId) {
    final String notification = table + " " + databaseOperation + " " + moduleId + " " + address;
    notifications.add(new MockPGNotification("function_changes", notification));
    final PostgreSQLFunctionNotificationParser parser = new PostgreSQLFunctionNotificationParser();
    final Collection<FunctionNotificationContainer> result = parser.parse(notifications, provider);
    assertNotNull(result);
    assertTrue(!result.isEmpty());
    assertTrue(result.size() == 1);
    final FunctionNotificationContainer container = Iterables.getFirst(result, null);
    assertNotNull(container);
    assertEquals(databaseOperation, container.getDatabaseOperation());
    assertEquals(new CAddress(address, 10), container.getFunctionAddress());
}
Also used : FunctionNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionNotificationContainer) PostgreSQLFunctionNotificationParser(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLFunctionNotificationParser) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Example 2 with FunctionNotificationContainer

use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionNotificationContainer in project binnavi by google.

the class PostgreSQLFunctionNotificationParserTest method testFunctionInform2Description.

@Test
public void testFunctionInform2Description() throws CouldntLoadDataException {
    final String description = "FUNCTION DESCRIPTION CHANGE TEST";
    function.setDescriptionInternal(description);
    assertEquals(description, function.getDescription());
    final FunctionNotificationContainer container = new FunctionNotificationContainer(module.getConfiguration().getId(), module, function.getAddress(), "UPDATE");
    final PostgreSQLFunctionNotificationParser parser = new PostgreSQLFunctionNotificationParser();
    parser.inform(Lists.newArrayList(container), provider);
    assertEquals("Mock Description", function.getDescription());
}
Also used : FunctionNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionNotificationContainer) PostgreSQLFunctionNotificationParser(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLFunctionNotificationParser) Test(org.junit.Test)

Example 3 with FunctionNotificationContainer

use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionNotificationContainer in project binnavi by google.

the class PostgreSQLFunctionNotificationParser method inform.

@Override
public void inform(final Collection<FunctionNotificationContainer> parsedFunctionNotifications, final SQLProvider provider) throws CouldntLoadDataException {
    Preconditions.checkNotNull(parsedFunctionNotifications, "Error: parsedFunctionNotifications argument can not be null");
    Preconditions.checkNotNull(provider, "IE02740: provider argument can not be null");
    for (final FunctionNotificationContainer container : parsedFunctionNotifications) {
        informFunctionNotification(container, provider);
    }
}
Also used : FunctionNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionNotificationContainer)

Example 4 with FunctionNotificationContainer

use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionNotificationContainer in project binnavi by google.

the class PostgreSQLFunctionNotificationParserTest method testFunctionInform0.

@Test
public void testFunctionInform0() throws CouldntLoadDataException {
    final FunctionNotificationContainer container = new FunctionNotificationContainer(module.getConfiguration().getId(), module, function.getAddress(), "INSERT");
    final PostgreSQLFunctionNotificationParser parser = new PostgreSQLFunctionNotificationParser();
    parser.inform(Lists.newArrayList(container), provider);
}
Also used : FunctionNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionNotificationContainer) PostgreSQLFunctionNotificationParser(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLFunctionNotificationParser) Test(org.junit.Test)

Example 5 with FunctionNotificationContainer

use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionNotificationContainer in project binnavi by google.

the class PostgreSQLFunctionNotificationParserTest method testFunctionInform1Name.

@Test
public void testFunctionInform1Name() throws CouldntLoadDataException {
    final String name = "FUNCTION NAME CHANGE TEST";
    function.setNameInternal(name);
    assertEquals(name, function.getName());
    final FunctionNotificationContainer container = new FunctionNotificationContainer(module.getConfiguration().getId(), module, function.getAddress(), "UPDATE");
    final PostgreSQLFunctionNotificationParser parser = new PostgreSQLFunctionNotificationParser();
    parser.inform(Lists.newArrayList(container), provider);
    assertEquals("Mock Function", function.getName());
}
Also used : FunctionNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionNotificationContainer) PostgreSQLFunctionNotificationParser(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLFunctionNotificationParser) Test(org.junit.Test)

Aggregations

FunctionNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionNotificationContainer)8 PostgreSQLFunctionNotificationParser (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLFunctionNotificationParser)5 Test (org.junit.Test)4 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)2 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)1 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)1 MockFunction (com.google.security.zynamics.binnavi.disassembly.MockFunction)1 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)1 BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 PGNotification (org.postgresql.PGNotification)1