Augmentation Directives
Augmentation Directives are CPGQL Directives which extend a Code Property Graph with nodes, properties and edges.
Take the following simple program named X42:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[]) {
if (argc > 1 && strcmp(argv[1], "42") == 0) {
fprintf(stderr, "It depends!\n");
exit(42);
}
printf("What is the meaning of life?\n");
exit(0);
}newTagNode
newTagNode is an Augmentation Directive that adds tags with user-defined keys to the nodes that are part of the traversal they're suffixing. It works together with the store CPGQL Component which creates the actual nodes representing the tags, and the run.commit Top-Level Command which merges those nodes in the active Code Property Graph.
Say for example that you'd like to add tags to all the nodes of X42's Code Property Graph that represent calls to exit. That is, these two:
// list all CALL nodes in the X42 program with the string "exit" in their CALL property
ocular> cpg.call.name("exit").code.l
res0: List[String] = List("exit(0)", "exit(42)")And say that you'd like to use the key MY_KIND_OF_EXIT for the tags you want to create:
newTagNodePair
newTagNodePair is very similar to newTagNode: it is an Augmentation Directive that adds tags with user-defined keys and user-defined values to the nodes that are part of the traversal they're suffixing. It also works together with store and run.commit, but you can specify both a key and a value for the nodes created:
Last updated
Was this helpful?