Search in sources :

Example 31 with CTagManager

use of com.google.security.zynamics.binnavi.Tagging.CTagManager in project binnavi by google.

the class PostgreSQLProviderTest method testTagView2.

@Test(expected = NullPointerException.class)
public void testTagView2() throws CouldntLoadDataException, CouldntSaveDataException {
    final CTagManager tagManager = getProvider().loadTagManager(TagType.VIEW_TAG);
    final CTag tag = tagManager.getRootTag().getChildren().get(0).getObject();
    getProvider().tagView(null, tag);
}
Also used : CTag(com.google.security.zynamics.binnavi.Tagging.CTag) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 32 with CTagManager

use of com.google.security.zynamics.binnavi.Tagging.CTagManager in project binnavi by google.

the class PostgreSQLProviderTest method testTagView1.

@Test
public void testTagView1() throws CouldntSaveDataException, CouldntLoadDataException, CPartialLoadException, LoadCancelledException {
    final INaviModule module = getProvider().loadModules().get(0);
    module.load();
    final CView view = (CView) module.getContent().getViewContainer().getViews().get(224);
    view.load();
    final CTagManager tagManager = getProvider().loadTagManager(TagType.VIEW_TAG);
    final CTag tag = tagManager.getRootTag().getChildren().get(0).getObject();
    getProvider().tagView(view, tag);
}
Also used : CView(com.google.security.zynamics.binnavi.disassembly.views.CView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 33 with CTagManager

use of com.google.security.zynamics.binnavi.Tagging.CTagManager in project binnavi by google.

the class PostgreSQLProviderTest method testCTagFunctionsMoveTag.

@Test
public void testCTagFunctionsMoveTag() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException {
    final CTagManager tagManager = getProvider().loadTagManager(TagType.VIEW_TAG);
    tagManager.addTag(tagManager.getRootTag(), "Node Tag I");
    tagManager.addTag(tagManager.getRootTag(), "Node Tag II");
    tagManager.addTag(tagManager.getRootTag().getChildren().get(0), "Node Tag III");
    final ITreeNode<CTag> tag1 = tagManager.getRootTag().getChildren().get(0);
    final ITreeNode<CTag> tag2 = tagManager.getRootTag().getChildren().get(1);
    final INaviModule module = getProvider().loadModules().get(0);
    module.load();
    tagManager.moveTag(tag1, tag2);
    tagManager.moveTag(tag2, tag1);
// m_sql.moveTag(tag1, tag2, TagType.VIEW_TAG);
// m_sql.moveTag(tag2, tag1, TagType.VIEW_TAG);
// PostgreSQLTagFunctions.moveTag((AbstractSQLProvider) m_sql, tag1, tag2);
// PostgreSQLTagFunctions.moveTag((AbstractSQLProvider) m_sql, tag2, tag1);
}
Also used : INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 34 with CTagManager

use of com.google.security.zynamics.binnavi.Tagging.CTagManager in project binnavi by google.

the class ViewGraphHelpersTest method setUp.

@Before
public void setUp() throws CouldntLoadDataException, LoadCancelledException, com.google.security.zynamics.binnavi.API.disassembly.CouldntLoadDataException, PartialLoadException {
    final MockSqlProvider provider = new MockSqlProvider();
    final TagManager tagManager = new TagManager(new MockTagManager(TagType.NODE_TAG));
    final TagManager viewTagManager = new TagManager(new CTagManager(new Tree<CTag>(new TreeNode<CTag>(new CTag(1, "", "", TagType.VIEW_TAG, provider))), TagType.VIEW_TAG, provider));
    final Database database = new Database(new MockDatabase());
    final CModule internalModule = new CModule(1, "", "", new Date(), new Date(), "00000000000000000000000000000000", "0000000000000000000000000000000000000000", 0, 0, new CAddress(0), new CAddress(0), null, null, Integer.MAX_VALUE, false, provider);
    internalModule.load();
    final Module module = new Module(database, internalModule, tagManager, viewTagManager);
    final CModuleViewGenerator generator = new CModuleViewGenerator(provider, internalModule);
    final INaviView internalView = generator.generate(1, "My View", "My View Description", com.google.security.zynamics.zylib.disassembly.ViewType.NonNative, GraphType.MIXED_GRAPH, new Date(), new Date(), 1, 2, new HashSet<CTag>(), new HashSet<CTag>(), false);
    m_view = new View(module, internalView, tagManager, viewTagManager);
    m_view.load();
    final List<INaviInstruction> instructions = new ArrayList<INaviInstruction>();
    instructions.add(new CInstruction(false, internalModule, new CAddress(0x123), "nop", new ArrayList<COperandTree>(), new byte[] { (byte) 0x90 }, "x86-32", provider));
    instructions.add(new CInstruction(false, internalModule, new CAddress(0x124), "nop", new ArrayList<COperandTree>(), new byte[] { (byte) 0x90 }, "x86-32", provider));
    instructions.add(new CInstruction(false, internalModule, new CAddress(0x125), "nop", new ArrayList<COperandTree>(), new byte[] { (byte) 0x90 }, "x86-32", provider));
    final INaviCodeNode codeNode = internalView.getContent().createCodeNode(null, instructions);
    final List<INaviViewNode> nodes1 = new ArrayList<INaviViewNode>();
    nodes1.add(codeNode);
    final List<INaviEdge> edges1 = new ArrayList<INaviEdge>();
    final CFunction internalFunction = new CFunction(internalModule, new MockView(nodes1, edges1, provider), new CAddress(0x123), "Mock Function", "Mock Function", "Mock Description", 0, 0, 0, 0, FunctionType.NORMAL, "", 0, null, null, null, provider);
    internalFunction.load();
    final Function function = new Function(module, internalFunction);
    final CFunctionNode functionNode = new CFunctionNode(0, internalFunction, 0, 0, 0, 0, Color.RED, false, false, null, new HashSet<CTag>(), provider);
    m_codeNode = new CodeNode(m_view, codeNode, tagManager);
    m_functionNode = new FunctionNode(m_view, functionNode, function, tagManager);
    m_textNode = new TextNode(m_view, new MockTextNode(), tagManager);
    final List<ViewNode> nodes = Lists.newArrayList(m_codeNode, m_functionNode, m_textNode);
    final List<ViewEdge> edges = Lists.newArrayList(new ViewEdge(new MockEdge(1, provider), nodes.get(0), nodes.get(0)));
    m_graph = new ViewGraph(nodes, edges);
}
Also used : MockEdge(com.google.security.zynamics.binnavi.disassembly.MockEdge) MockTextNode(com.google.security.zynamics.binnavi.disassembly.MockTextNode) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) ArrayList(java.util.ArrayList) MockTagManager(com.google.security.zynamics.binnavi.Tagging.MockTagManager) INaviEdge(com.google.security.zynamics.binnavi.disassembly.INaviEdge) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) CFunction(com.google.security.zynamics.binnavi.disassembly.CFunction) INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Tree(com.google.security.zynamics.zylib.types.trees.Tree) COperandTree(com.google.security.zynamics.binnavi.disassembly.COperandTree) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction) CFunctionNode(com.google.security.zynamics.binnavi.disassembly.CFunctionNode) CModuleViewGenerator(com.google.security.zynamics.binnavi.Database.CModuleViewGenerator) MockView(com.google.security.zynamics.binnavi.disassembly.MockView) CFunctionNode(com.google.security.zynamics.binnavi.disassembly.CFunctionNode) CFunction(com.google.security.zynamics.binnavi.disassembly.CFunction) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) MockTextNode(com.google.security.zynamics.binnavi.disassembly.MockTextNode) CInstruction(com.google.security.zynamics.binnavi.disassembly.CInstruction) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) MockView(com.google.security.zynamics.binnavi.disassembly.MockView) Date(java.util.Date) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) MockTagManager(com.google.security.zynamics.binnavi.Tagging.MockTagManager) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) Before(org.junit.Before)

Example 35 with CTagManager

use of com.google.security.zynamics.binnavi.Tagging.CTagManager in project binnavi by google.

the class ViewGraphTest method testConstructor.

@Test
public void testConstructor() throws CouldntLoadDataException, LoadCancelledException {
    final MockSqlProvider provider = new MockSqlProvider();
    final TagManager tagManager = new TagManager(new MockTagManager(TagType.NODE_TAG));
    final TagManager viewTagManager = new TagManager(new CTagManager(new Tree<CTag>(new TreeNode<CTag>(new CTag(1, "", "", TagType.VIEW_TAG, provider))), TagType.VIEW_TAG, provider));
    final Database database = new Database(new MockDatabase());
    final CModule internalModule = new CModule(1, "", "", new Date(), new Date(), "00000000000000000000000000000000", "0000000000000000000000000000000000000000", 0, 0, new CAddress(0), new CAddress(0), null, null, Integer.MAX_VALUE, false, provider);
    internalModule.load();
    final Module module = new Module(database, internalModule, tagManager, viewTagManager);
    final CModuleViewGenerator generator = new CModuleViewGenerator(provider, internalModule);
    final INaviView internalView = generator.generate(1, "My View", "My View Description", com.google.security.zynamics.zylib.disassembly.ViewType.NonNative, GraphType.MIXED_GRAPH, new Date(), new Date(), 1, 2, new HashSet<CTag>(), new HashSet<CTag>(), false);
    final View view = new View(module, internalView, tagManager, viewTagManager);
    final List<ViewNode> nodes = Lists.newArrayList((ViewNode) new TextNode(view, new MockTextNode(), tagManager));
    final List<ViewEdge> edges = Lists.newArrayList(new ViewEdge(new MockEdge(1, provider), nodes.get(0), nodes.get(0)));
    final ViewGraph graph = new ViewGraph(nodes, edges);
    assertEquals(1, graph.getNodes().size());
    assertEquals(nodes.get(0), graph.getNodes().get(0));
    assertEquals(1, graph.getEdges().size());
    assertEquals(edges.get(0), graph.getEdges().get(0));
    assertEquals("View Graph [1 nodes, 1 edges]", graph.toString());
}
Also used : MockEdge(com.google.security.zynamics.binnavi.disassembly.MockEdge) MockTextNode(com.google.security.zynamics.binnavi.disassembly.MockTextNode) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) MockTagManager(com.google.security.zynamics.binnavi.Tagging.MockTagManager) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Tree(com.google.security.zynamics.zylib.types.trees.Tree) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) CModuleViewGenerator(com.google.security.zynamics.binnavi.Database.CModuleViewGenerator) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) MockTextNode(com.google.security.zynamics.binnavi.disassembly.MockTextNode) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) Date(java.util.Date) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) MockTagManager(com.google.security.zynamics.binnavi.Tagging.MockTagManager) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) Test(org.junit.Test)

Aggregations

CTagManager (com.google.security.zynamics.binnavi.Tagging.CTagManager)46 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)34 Test (org.junit.Test)31 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)23 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)17 Tree (com.google.security.zynamics.zylib.types.trees.Tree)15 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)13 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)13 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)12 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)12 Date (java.util.Date)12 TreeNode (com.google.security.zynamics.zylib.types.trees.TreeNode)10 Before (org.junit.Before)9 TagManager (com.google.security.zynamics.binnavi.API.disassembly.TagManager)8 ITreeNode (com.google.security.zynamics.zylib.types.trees.ITreeNode)8 Database (com.google.security.zynamics.binnavi.API.disassembly.Database)7 CView (com.google.security.zynamics.binnavi.disassembly.views.CView)7 Module (com.google.security.zynamics.binnavi.API.disassembly.Module)6 MockTagManager (com.google.security.zynamics.binnavi.Tagging.MockTagManager)5 MockView (com.google.security.zynamics.binnavi.disassembly.MockView)5