Example #1
0
def validate(audit):
    disk = AuditDB(audit)
    try:

        # Make sure all objects completed all stages.
        for stage in sorted(PluginManager.STAGES.values()):
            assert disk.get_pending_data(stage) == set()

    finally:
        disk.close()
Example #2
0
def validate(audit):
    disk = AuditDB(audit)
    try:

        # Make sure all objects completed all stages.
        for stage in sorted(STAGES.values()):
            assert disk.get_pending_data(stage) == set()



    finally:
        disk.close()
Example #3
0
def validate(audit):
    audit = AuditConfig()
    audit.from_dictionary({
        "audit_name": audit,
        "audit_db": "sqlite://%s.db" % audit,
    })
    disk = AuditDB(audit)
    try:

        # Make sure all objects completed all stages.
        for stage in sorted(PluginManager.STAGES.values()):
            assert disk.get_pending_data(stage) == set()

    finally:
        disk.close()
Example #4
0
def validate(audit):
    audit = AuditConfig()
    audit.from_dictionary({
        "audit_name": audit,
        "audit_db": "sqlite://%s.db" % audit,
    })
    disk = AuditDB(audit)
    try:

        # Make sure all objects completed all stages.
        for stage in sorted(PluginManager.STAGES.values()):
            assert disk.get_pending_data(stage) == set()



    finally:
        disk.close()
Example #5
0
    def do_audit_results(self, audit_name, data_type = "all"): # TODO: control audits with error at start
        """
        Implementation of: /audit/results

        :param audit_name: Name of the audit to query.
        :type audit_name: str

        :param data_type: Data type to request. Case insensitive.
            Must be one of the following values:
             - "all": All data types.
             - "information": Information type.
             - "resource": Resource type.
             - "vulnerability": Vulnerability type.
        :type data_type: str

        :returns: Result IDs.
        :rtype: list(str)

        :raises KeyError: Data type unknown.
        """
        if self.is_audit_running(audit_name):
            with SwitchToAudit(audit_name):
                i_data_type = {
                    "all": None,
                    "information": Data.TYPE_INFORMATION,
                    "resource": Data.TYPE_RESOURCE,
                    "vulnerability": Data.TYPE_VULNERABILITY,
                    }[data_type.strip().lower()]
                return sorted( Database.keys(i_data_type) )
        else:


            # XXX TODO open the database manually here
            raise NotImplementedError(
                "Querying finished audits is not implemented yet!")


            audit_db = "/home/pepe/fdfd/%s.db" % audit_name  # MENTIRA
            audit_config = AuditDB.get_audit_config(audit_db)
            with AuditDB(audit_config) as db:
                i_data_type = {
                    "all": None,
                    "information": Data.TYPE_INFORMATION,
                    "resource": Data.TYPE_RESOURCE,
                    "vulnerability": Data.TYPE_VULNERABILITY,
                    }[data_type.strip().lower()]
                return sorted( db.get_data_keys(i_data_type) )
Example #6
0
def main():

    # Show the program banner.
    show_banner()

    # Get the command line parser.
    parser = cmdline_parser()

    # Parse the command line options.
    try:
        args = sys.argv[1:]
        envcfg = getenv("GOLISMERO_SETTINGS")
        if envcfg:
            args = parser.convert_arg_line_to_args(envcfg) + args
        P = parser.parse_args(args)

        # Load the Orchestrator options.
        cmdParams = OrchestratorConfig()
        if P.config:
            cmdParams.config_file = path.abspath(P.config)
            if not path.isfile(cmdParams.config_file):
                raise ValueError("File not found: %r" % cmdParams.config_file)
        if cmdParams.config_file:
            cmdParams.from_config_file(cmdParams.config_file, allow_profile = True)
        if P.profile:
            cmdParams.profile = P.profile
            cmdParams.profile_file = get_profile(cmdParams.profile)
        if cmdParams.profile_file:
            cmdParams.from_config_file(cmdParams.profile_file)
        cmdParams.from_object(P)
        cmdParams.plugin_load_overrides = P.plugin_load_overrides

        # Load the target audit options.
        auditParams = AuditConfig()
        auditParams.profile = cmdParams.profile
        auditParams.profile_file = cmdParams.profile_file
        auditParams.config_file = cmdParams.config_file
        if auditParams.config_file:
            auditParams.from_config_file(auditParams.config_file)
        if auditParams.profile_file:
            auditParams.from_config_file(auditParams.profile_file)
        auditParams.from_object(P)
        auditParams.plugin_load_overrides = P.plugin_load_overrides

        # If importing is turned off, remove the list of imports.
        if P.disable_importing:
            auditParams.imports = []

        # If reports are turned off, remove the list of reports.
        # Otherwise, if no reports are specified, default to screen report.
        if P.disable_reporting:
            auditParams.reports = []
        elif not auditParams.reports:
            auditParams.reports = ["-"]

        # If there are no targets but there's a database,
        # get the targets (scope) from the database.
        if not auditParams.targets and auditParams.audit_db:
            try:
                cfg = AuditDB.get_config_from_closed_database(
                    auditParams.audit_db, auditParams.audit_name)
                if cfg:
                    auditParams.targets = cfg.targets
                    auditParams.include_subdomains = cfg.include_subdomains
                    if cmdParams.verbose > 1:
                        if auditParams.targets:
                            print "Found the following targets in the database:"
                            for t in auditParams.targets:
                                print "--> " + t
                            print
            except Exception:
                pass
                ##raise    # XXX DEBUG

    # Show exceptions as command line parsing errors.
    except Exception, e:
        ##raise    # XXX DEBUG
        parser.error(str(e))