def main():
    logging.basicConfig(level=logging.INFO)
    if len(sys.argv) != 2:
        print("Usage: %s <SPEC_FILE>" % sys.argv[0])
        return -1

    spec_path = sys.argv[1]
    spec_dir = os.path.dirname(spec_path)
    with open(spec_path, "rb") as f:
        spec = yaml.safe_load(f)

    strings = spec["Decoded strings"]
    test_dict = { "all": strings }
    logging.info("created test dictionary from %s:\n  %s", spec_path, pformat(test_dict))

    for platform, archs in spec["Output Files"].items():
        for arch, filename in archs.items():
            filepath = os.path.join(spec_dir, filename)
            if not os.path.isfile(filepath):
                logging.warning("not a file: %s", filepath)
                continue

            if footer.has_footer(filepath):
                logging.info("already has footer, skipping: %s", filepath)
                continue

            footer.write_footer(filepath, {"all": strings})
            logging.info("set footer: %s", filepath)
def main():
    logging.basicConfig(level=logging.INFO)
    if len(sys.argv) != 2:
        print("Usage: %s <SPEC_FILE>" % sys.argv[0])
        return -1

    spec_path = sys.argv[1]
    spec_dir = os.path.dirname(spec_path)
    with open(spec_path, "rb") as f:
        spec = yaml.safe_load(f)

    strings = spec["Decoded strings"]
    test_dict = {"all": strings}
    logging.info("created test dictionary from %s:\n  %s", spec_path,
                 pformat(test_dict))

    for platform, archs in spec["Output Files"].items():
        for arch, filename in archs.items():
            filepath = os.path.join(spec_dir, filename)
            if not os.path.isfile(filepath):
                logging.warning("not a file: %s", filepath)
                continue

            if footer.has_footer(filepath):
                logging.info("already has footer, skipping: %s", filepath)
                continue

            footer.write_footer(filepath, {"all": strings})
            logging.info("set footer: %s", filepath)
Beispiel #3
0
    def _test_strings(self, test_path):
        if footer.has_footer(test_path):
            expected_strings = set(footer.read_footer(test_path)["all"])
        else:
            expected_strings = set(self.spec["Decoded strings"])

        if not expected_strings:
            return

        found_strings = set(extract_strings(test_path))

        if not (expected_strings <= found_strings):
            raise FLOSSStringsNotExtracted(expected_strings, found_strings)
Beispiel #4
0
    def _test_strings(self, test_path):
        if footer.has_footer(test_path):
            expected_strings = set(footer.read_footer(test_path)["all"])
        else:
            expected_strings = set(self.spec["Decoded strings"])

        if not expected_strings:
            return

        found_strings = set(extract_strings(test_path))

        if not (expected_strings <= found_strings):
            raise FLOSSStringsNotExtracted(expected_strings, found_strings)
Beispiel #5
0
    def _test_detection(self, test_path):
        if footer.has_footer(test_path):
            expected_functions = set(footer.read_footer(test_path).keys()) - set("all")
        else:
            try:
                expected_functions = set(self.spec["Decoding routines"][self.platform][self.arch])
            except KeyError:
                expected_functions = set([])

        if not expected_functions:
            return

        vw = viv_utils.getWorkspace(test_path)
        fs = map(lambda p: p[0], identify_decoding_functions(vw).get_top_candidate_functions())
        found_functions = set(fs)

        if not (expected_functions <= found_functions):
            raise FLOSSDecodingFunctionNotFound(expected_functions, found_functions)
Beispiel #6
0
    def _test_detection(self, test_path):
        if footer.has_footer(test_path):
            expected_functions = set(footer.read_footer(test_path).keys()) - set("all")
        else:
            try:
                expected_functions = set(self.spec["Decoding routines"][self.platform][self.arch])
            except KeyError:
                expected_functions = set([])

        if not expected_functions:
            return

        vw = viv_utils.getWorkspace(test_path)
        fs = map(lambda p: p[0], identify_decoding_functions(vw).get_top_candidate_functions())
        found_functions = set(fs)

        if not (expected_functions <= found_functions):
            raise FLOSSDecodingFunctionNotFound(expected_functions, found_functions)