use of com.google.security.zynamics.binnavi.disassembly.CommentManager.CommentOperation in project binnavi by google.
the class PostgreSQLCommentNotificationParser method processGroupNodeCommentNotification.
/**
* Parses the notifications from the database back end for group node comments by using a regular
* expression. If the regular expression matches the supplied {@link PGNotification} notification,
* it is determined if the group node in the notification is currently loaded, and if a
* {@link CommentNotificationContainer} with the gathered data from the notification is returned.
*
* @param notification The {@link PGNotification} from the PostgreSQL database server.
* @param provider The {@link SQLProvider} which is used to communicate with the database.
*/
static CommentNotification processGroupNodeCommentNotification(final PGNotification notification, final SQLProvider provider) {
final Matcher matcher = GROUP_NODE_PATTERN.matcher(notification.getParameter());
if (!matcher.find()) {
return null;
}
final Integer nodeId = Integer.parseInt(matcher.group(3));
final Integer commentId = matcher.group(4).equals("null") ? null : Integer.parseInt(matcher.group(4));
final INaviGroupNode groupNode = (INaviGroupNode) NodeCache.get(provider).getNodeById(nodeId);
if (groupNode == null) {
return null;
}
final CommentOperation operation = commentId == null ? CommentOperation.DELETE : CommentOperation.APPEND;
return new GroupNodeCommentNotificationContainer(groupNode, operation, commentId);
}
use of com.google.security.zynamics.binnavi.disassembly.CommentManager.CommentOperation in project binnavi by google.
the class PostgreSQLCommentNotificationParser method processNodeLocalNodeCommentNotification.
/**
* Parses the {@link PGNotification} notifications from the PostgreSQL database back end for local
* code node comments by using a regular expression. If the regular expression matches the
* supplied {@link PGNotification} notification, it is determined if the code node in the
* notification is currently loaded, and if a {@link CommentNotificationContainer} with the
* gathered data from the notification is returned.
*
* @param notification The {@link PGNotification} from the PostgreSQL database server.
* @param provider The {@link SQLProvider} which is used to communicate with the database.
*/
static CommentNotification processNodeLocalNodeCommentNotification(final PGNotification notification, final SQLProvider provider) {
final Matcher matcher = NODE_LOCAL_PATTERN.matcher(notification.getParameter());
if (!matcher.find()) {
return null;
}
final Integer moduleId = Integer.parseInt(matcher.group(3));
final Integer nodeId = Integer.parseInt(matcher.group(4));
final Integer commentId = matcher.group(6).equals("null") ? null : Integer.parseInt(matcher.group(6));
final INaviModule module = provider.findModule(moduleId);
if (!module.isLoaded()) {
return null;
}
final INaviCodeNode codeNode = (INaviCodeNode) NodeCache.get(provider).getNodeById(nodeId);
if (codeNode == null) {
return null;
}
final CommentOperation operation = commentId == null ? CommentOperation.DELETE : CommentOperation.APPEND;
return new CodeNodeCommentNotificationContainer(codeNode, operation, CommentScope.LOCAL, commentId);
}
use of com.google.security.zynamics.binnavi.disassembly.CommentManager.CommentOperation in project binnavi by google.
the class PostgreSQLCommentNotificationParser method processFunctionCommentNotification.
/**
* Parses the notifications from the database back end for function comments by using a regular
* expression. If the regular expression matches the supplied {@link PGNotification} notification,
* a {@link CommentNotificationContainer} is build with the data from the notification.
*
* @param notification The {@link PGNotification} from the PostgreSQL database server.
* @param provider The {@link SQLProvider} which is used to communicate with the database.
*/
static CommentNotification processFunctionCommentNotification(final PGNotification notification, final SQLProvider provider) {
final Matcher matcher = FUNCTION_PATTERN.matcher(notification.getParameter());
if (!matcher.find()) {
return null;
}
final Integer notificationModuleId = Integer.parseInt(matcher.group(3));
final IAddress notificationFunctionAddress = new CAddress(new BigInteger(matcher.group(4)));
final Integer commentId = matcher.group(5).equals("null") ? null : Integer.parseInt(matcher.group(5));
final INaviModule module = provider.findModule(notificationModuleId);
if ((module == null) || !module.isLoaded()) {
return null;
}
final INaviFunction function = module.getContent().getFunctionContainer().getFunction(notificationFunctionAddress);
if (function == null) {
return null;
}
final CommentOperation operation = commentId == null ? CommentOperation.DELETE : CommentOperation.APPEND;
return new FunctionCommentNotificationContainer(function, operation, commentId);
}
use of com.google.security.zynamics.binnavi.disassembly.CommentManager.CommentOperation in project binnavi by google.
the class PostgreSQLCommentNotificationParser method processEdgeGlobalCommentNotification.
/**
* Parses the notifications from the database back end for global edge comments by using a regular
* expression. If the regular expression matches the supplied notification it tries to figure out
* if the edge which was commented is loaded in BinNavi at this point in time. If the edge is
* loaded determine the operation which was performed by the database and then return a
* {@link CommentNotificationContainer} with the gathered results.
*
* @param notification The {@link PGNotification} from the PostgreSQL database server.
* @param provider The {@link SQLProvider} which is used to communicate with the database.
*/
static Collection<CommentNotification> processEdgeGlobalCommentNotification(final PGNotification notification, final SQLProvider provider) {
final Matcher matcher = EDGE_GLOBAL_PATTERN.matcher(notification.getParameter());
if (!matcher.find()) {
return new ArrayList<>();
}
final String databaseOperation = matcher.group(2);
final Integer notificationSourceModuleId = Integer.parseInt(matcher.group(3));
final Integer notificationDestinationModuleId = Integer.parseInt(matcher.group(4));
final IAddress notificationEdgeSourceAddress = new CAddress(new BigInteger(matcher.group(5)));
final IAddress notificationEdgeDestinationAddress = new CAddress(new BigInteger(matcher.group(6)));
final Integer commentId = matcher.group(8) == null ? null : Integer.parseInt(matcher.group(8));
final INaviModule notificationSourceModule = provider.findModule(notificationSourceModuleId);
if ((notificationSourceModule == null) || !notificationSourceModule.isLoaded()) {
return new ArrayList<>();
}
final INaviModule notificationDestinationModule = provider.findModule(notificationDestinationModuleId);
if ((notificationDestinationModule == null) || !notificationDestinationModule.isLoaded()) {
return new ArrayList<>();
}
final CommentOperation operation = databaseOperation.equalsIgnoreCase("DELETE") ? CommentOperation.DELETE : CommentOperation.APPEND;
Collection<CommentNotification> notifications = new ArrayList<>();
final ImmutableCollection<INaviEdge> edges = EdgeCache.get(provider).getEdgeBySourceAndTarget(notificationEdgeSourceAddress, notificationSourceModuleId, notificationEdgeDestinationAddress, notificationDestinationModuleId);
for (INaviEdge edge : edges) {
notifications.add(new EdgeCommentNotificationContainer(edge, operation, CommentScope.GLOBAL, commentId));
}
return notifications;
}
use of com.google.security.zynamics.binnavi.disassembly.CommentManager.CommentOperation in project binnavi by google.
the class PostgreSQLCommentNotificationParser method processFunctionNodeCommentNotification.
/**
* Parses the notifications from the database back end for function node comments by using a
* regular expression. If the regular expression matches the supplied {@link PGNotification}
* notification, it is determined if the function node in question is currently loaded, and if a
* {@link CommentNotificationContainer} with the gathered data is returned.
*
* @param notification The {@link PGNotification} from the PostgreSQL database server.
* @param provider The {@link SQLProvider} which is used to communicate with the database.
*/
static CommentNotification processFunctionNodeCommentNotification(final PGNotification notification, final SQLProvider provider) {
final Matcher matcher = FUNCTION_NODE_PATTERN.matcher(notification.getParameter());
if (!matcher.find()) {
return null;
}
final Integer moduleId = Integer.parseInt(matcher.group(3));
final Integer nodeId = Integer.parseInt(matcher.group(4));
final Integer commentId = matcher.group(6).equals("null") ? null : Integer.parseInt(matcher.group(6));
final INaviModule module = provider.findModule(moduleId);
if ((module == null) || !module.isLoaded()) {
return null;
}
final INaviFunctionNode functionNode = (INaviFunctionNode) NodeCache.get(provider).getNodeById(nodeId);
if (functionNode == null) {
return null;
}
final CommentOperation operation = commentId == null ? CommentOperation.DELETE : CommentOperation.APPEND;
return new FunctionNodeCommentNotificationContainer(functionNode, operation, commentId);
}
Aggregations