Пример #1
0
def db_remove(config: str, verbose: bool, db: str):
    """
    Remove a db from the list of known DBs and delete local copies of the DB.
    """
    m = CVDUpdate(config=config, verbose=verbose)
    if not m.config_remove_db(db):
        sys.exit(1)
Пример #2
0
def db_show(config: str, verbose: bool, db: str):
    """
    Show details about a specific database.
    """
    m = CVDUpdate(config=config, verbose=verbose)
    if not m.db_show(db):
        sys.exit(1)
Пример #3
0
def db_add(config: str, verbose: bool, db: str, url: str):
    """
    Add a db to the list of known DBs.
    """
    m = CVDUpdate(config=config, verbose=verbose)
    if not m.config_add_db(db, url=url):
        sys.exit(1)
Пример #4
0
def db_update(config: str, verbose: bool, db: str, debug_mode: bool):
    """
    Update the DBs from the internet. Will update all DBs if DB not specified.
    """
    m = CVDUpdate(config=config, verbose=verbose)
    errors = m.db_update(db, debug_mode)
    if errors > 0:
        sys.exit(errors)
Пример #5
0
def _update(interval: int) -> None:
    """Don't call this directly

    Updates the AV db after every "interval" seconds when it was started
    :param interval: the interval in seconds between 2 updates of the db
    """
    ticker = Event()
    m = CVDUpdate()
    m.logger.info(f"Updating the database every {interval} seconds")
    while not ticker.wait(interval):
        errors = m.db_update(debug_mode=True)
        if errors > 0:
            m.logger.error("Failed to fetch updates from ClamAV databases")
Пример #6
0
def config_set(config: str, verbose: bool, logdir: str, dbdir: str, nameserver: str):
    """
    Set up first time configuration.

    The default directories will be in ~/.cvdupdate
    """
    CVDUpdate(
        config=config,
        verbose=verbose,
        log_dir=logdir,
        db_dir=dbdir,
        nameserver=nameserver)
Пример #7
0
def serve(port: int, config: str, verbose: bool):
    """
    Serve up the database directory. Not a production quality server.
    Intended for testing purposes.
    """
    m = CVDUpdate(config=config, verbose=verbose)
    os.chdir(str(m.db_dir))
    m.logger.info(f"Serving up {m.db_dir} on localhost:{port}...")

    RangeRequestHandler.protocol_version = 'HTTP/1.0'
    # TODO(danvk): pick a random, available port
    httpd = HTTPServer(('', port), RangeRequestHandler)
    httpd.serve_forever()
Пример #8
0
def db_list(config: str, verbose: bool):
    """
    List the DBs found in the database directory.
    """
    m = CVDUpdate(config=config, verbose=verbose)
    m.db_list()
Пример #9
0
def clean_all(config: str, verbose: bool):
    """
    Delete the logs, databases, and config file.
    """
    m = CVDUpdate(config=config, verbose=verbose)
    m.clean_all()
Пример #10
0
def clean_logs(config: str, verbose: bool):
    """
    Delete all files in the logs directory
    """
    m = CVDUpdate(config=config, verbose=verbose)
    m.clean_logs()
Пример #11
0
def clean_dbs(config: str, verbose: bool):
    """
    Delete all files in the database directory.
    """
    m = CVDUpdate(config=config, verbose=verbose)
    m.clean_dbs()
Пример #12
0
def config_show(config: str, verbose: bool):
    """
    Print out the current configuration.
    """
    m = CVDUpdate(config=config, verbose=verbose)
    m.config_show()