Search in sources :

Example 6 with PGNotification

use of org.postgresql.PGNotification in project binnavi by google.

the class PostgreSQLNotificationParserTest method testFunctionNodeCommentParsingCompleteGarbageInput.

@Test
public void testFunctionNodeCommentParsingCompleteGarbageInput() {
    new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
    // Normal input "bn_function_nodes UPDATE 1 6666 4608 null"
    notifications.add(new MockPGNotification("comment_changes", "bn_function_nodes 1 1 1 1 1"));
    notifications.add(new MockPGNotification("comment_changes", "bn_function_nodes UPDATE"));
    notifications.add(new MockPGNotification("comment_changes", "bn_function_nodes UPDATE 1 "));
    notifications.add(new MockPGNotification("comment_changes", "bn_function_nodes"));
    notifications.add(new MockPGNotification("comment_changes", "bn_function_nodes 1 FOO FOO FOOO ooqwkepqwpoekpqowkep" + "oqw\\n\\\n\\\n\\\\\\n\\n\n\\n\\\n\\n\\\n\\c\\c\\c\\c" + "ckepokqwpekpqwokepoaksjeofijsoiefjosejfosjoefjsoisje" + "foisjefoisjeofijsoeifjsoeifj"));
    for (PGNotification notification : notifications) {
        assertNull(PostgreSQLCommentNotificationParser.processFunctionCommentNotification(notification, provider));
    }
}
Also used : MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) PGNotification(org.postgresql.PGNotification) Test(org.junit.Test)

Example 7 with PGNotification

use of org.postgresql.PGNotification in project binnavi by google.

the class PostgreSQLFunctionNotificationParser method parse.

@Override
public Collection<FunctionNotificationContainer> parse(final Collection<PGNotification> notifications, final SQLProvider provider) {
    Preconditions.checkNotNull(notifications, "IE02629: notifications argument can not be null");
    Preconditions.checkNotNull(provider, "IE02630: provider argument can not be null");
    final Collection<FunctionNotificationContainer> containers = new ArrayList<FunctionNotificationContainer>();
    for (final PGNotification notification : notifications) {
        if (notification.getParameter().startsWith(CTableNames.FUNCTIONS_TABLE)) {
            containers.add(parseFunctionNotification(notification, provider));
        } else {
            throw new IllegalStateException("IE02738: Table name supplied in notification: " + notification.getParameter() + " does not match tables where function notifications are accepted on.");
        }
    }
    return containers;
}
Also used : FunctionNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionNotificationContainer) ArrayList(java.util.ArrayList) PGNotification(org.postgresql.PGNotification)

Aggregations

PGNotification (org.postgresql.PGNotification)7 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)1 FunctionNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionNotificationContainer)1 TypeInstanceCommentNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.TypeInstanceCommentNotificationContainer)1 TypeInstancesNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.TypeInstancesNotificationContainer)1 TypesNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.TypesNotificationContainer)1 ViewNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.ViewNotificationContainer)1 CommentNotification (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.interfaces.CommentNotification)1 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)1 TypeInstance (com.google.security.zynamics.binnavi.disassembly.types.TypeInstance)1 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)1