Example #1
0
    def test_with_not42(self):
        m = self.run_macke_test_on_file("examples/not42.bc")
        chains = reconstruct_all_error_chains(m.errorregistry, m.callgraph)

        # Only one reason for the chain
        self.assertEqual(len(chains), 1)

        # Only one chain trough all functions
        self.assertEqual(next(iter(chains.values())), [['not42']])
Example #2
0
    def test_with_chain(self):
        m = self.run_macke_test_on_file("examples/chain.bc")
        chains = reconstruct_all_error_chains(m.errorregistry, m.callgraph)

        # Only one reason for the chain
        self.assertEqual(len(chains), 1)

        # Only one chain trough all functions
        self.assertEqual(
            next(iter(chains.values())), [['c4', 'c3', 'c2', 'c1', 'main']])
Example #3
0
    def test_with_split(self):
        m = self.run_macke_test_on_file("examples/split.bc")
        chains = reconstruct_all_error_chains(m.errorregistry, m.callgraph)

        # All errors share the same vulnerable instruction
        self.assertEqual(len(chains), 1)

        # Two chains to top
        self.assertEqual(
            next(iter(chains.values())),
            [['bottom', 'left', 'top'], ['bottom', 'right', 'top']])
Example #4
0
    def test_with_split(self):
        m = self.run_macke_test_on_file("examples/split.bc")
        chains = reconstruct_all_error_chains(m.errorregistry, m.callgraph)

        # All errors share the same vulnerable instruction
        self.assertEqual(len(chains), 1)

        # Two chains to top
        self.assertEqual(
            next(iter(chains.values())),
            [['bottom', 'left', 'top'], ['bottom', 'right', 'top']])
Example #5
0
    def test_with_small(self):
        m = self.run_macke_test_on_file("examples/small.bc")
        chains = reconstruct_all_error_chains(m.errorregistry, m.callgraph)

        self.assertEqual(len(chains), 3)

        for vulninst, chainlist in chains.items():
            if vulninst.endswith("small.c:4"):
                self.assertEqual(chainlist, [['f2', 'f1']])
            elif vulninst.endswith("small.c:9"):
                self.assertEqual(chainlist, [['f3', 'f1']])
            elif vulninst.endswith("small.c:10"):
                self.assertEqual(chainlist, [['f3', 'f1']])
            else:
                raise Exception("Unexpected vulnerable instruction")
Example #6
0
    def test_with_small(self):
        m = self.run_macke_test_on_file("examples/small.bc")
        chains = reconstruct_all_error_chains(m.errorregistry, m.callgraph)

        self.assertEqual(len(chains), 3)

        for vulninst, chainlist in chains.items():
            if vulninst.endswith("small.c:4"):
                self.assertEqual(chainlist, [['f2', 'f1']])
            elif vulninst.endswith("small.c:9"):
                self.assertEqual(chainlist, [['f3', 'f1']])
            elif vulninst.endswith("small.c:10"):
                self.assertEqual(chainlist, [['f3', 'f1']])
            else:
                raise Exception("Unexpected vulnerable instruction")
Example #7
0
    def test_with_sanatized(self):
        m = self.run_macke_test_on_file("examples/sanatized.bc")
        chains = reconstruct_all_error_chains(m.errorregistry, m.callgraph)

        self.assertEqual(len(chains), 1)
        self.assertEqual(next(iter(chains.values())), [['c4', 'c3']])
Example #8
0
    def test_with_sanatized(self):
        m = self.run_macke_test_on_file("examples/sanatized.bc")
        chains = reconstruct_all_error_chains(m.errorregistry, m.callgraph)

        self.assertEqual(len(chains), 1)
        self.assertEqual(next(iter(chains.values())), [['c4', 'c3']])