Ejemplo n.º 1
0
    def load_threat_model(self, path):
        filename = data.abs_path(path, "threatmodel", "threatmodel.json")

        logger.debug("Validating {}".format(filename))
        (valid, error) = data.validate_yaml_file(
            filename, os.path.join("data", "threatmodel_schema.json"))
        if not valid:
            logger.error(
                "Couldn't validate the threat model file {}: {}".format(
                    filename, error))
            sys.exit(0)

        try:
            self.threatmodel.load(data.read_json(filename))
            logger.debug("Loaded threat model from {}".format(filename))
        except FileNotFoundError:
            pass
Ejemplo n.º 2
0
    def load_threat_library(self, path, local=False):
        filename = data.abs_path(path, "threatmodel", "threats.json")

        logger.debug("Validating {}".format(filename))
        (valid, error) = data.validate_yaml_file(
            filename, os.path.join("data", "threats_schema.json"))
        if not valid:
            logger.error(
                "Couldn't validate the threat library file {}: {}".format(
                    filename, error))
            sys.exit(0)

        try:
            if local:
                run_id = self.threatmodel.run_id
            else:
                run_id = None
            self.threat_library.load(data.read_json(filename), run_id)
            logger.debug("Loaded threat library from {}".format(filename))
        except FileNotFoundError:
            pass