예제 #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()