use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionNotificationContainer in project binnavi by google.
the class PostgreSQLFunctionNotificationParserTest method testFunctionInform3Resolve.
@Test
public void testFunctionInform3Resolve() throws CouldntLoadDataException {
final INaviFunction forwardFunction = new MockFunction(provider);
function.setForwardedFunctionInternal(forwardFunction);
assertTrue(function.isForwarded());
assertEquals(forwardFunction.getAddress(), function.getForwardedFunctionAddress());
assertEquals(forwardFunction.getModule().getConfiguration().getId(), function.getForwardedFunctionModuleId());
final FunctionNotificationContainer container = new FunctionNotificationContainer(module.getConfiguration().getId(), module, function.getAddress(), "UPDATE");
final PostgreSQLFunctionNotificationParser parser = new PostgreSQLFunctionNotificationParser();
parser.inform(Lists.newArrayList(container), provider);
assertFalse(function.isForwarded());
assertNull(function.getForwardedFunctionAddress());
assertEquals(0, function.getForwardedFunctionModuleId());
}
use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionNotificationContainer 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;
}
use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionNotificationContainer in project binnavi by google.
the class PostgreSQLFunctionNotificationParser method parseFunctionNotification.
private FunctionNotificationContainer parseFunctionNotification(final PGNotification notification, final SQLProvider provider) {
final Pattern pattern = Pattern.compile(functionNotificationPattern);
final Matcher matcher = pattern.matcher(notification.getParameter());
if (!matcher.find()) {
throw new IllegalStateException("IE02739: compiled pattern: " + pattern.toString() + " did not match notification: " + notification.getParameter());
}
final String databaseOperation = matcher.group(2);
final Integer moduleId = Integer.parseInt(matcher.group(3));
final IAddress functionAddress = new CAddress(new BigInteger(matcher.group(4)));
final INaviModule module = provider.findModule(moduleId);
return new FunctionNotificationContainer(moduleId, module, functionAddress, databaseOperation);
}
Aggregations