Example #1
0
app.request_counter = Counter('requests', 'Number of overall requests.')
app.registry.register(app.request_counter)
app.scan_counter = Counter('scans', 'Number of overall virus scans.')
app.registry.register(app.scan_counter)
app.infection_counter = Counter('infections',
                                'Number of infected files found.')
app.registry.register(app.infection_counter)
app.scan_duration_histogram = Histogram('scan_duration',
                                        'Histogram over virus scan duration.')
app.registry.register(app.scan_duration_histogram)

logging.basicConfig(stream=sys.stdout, level=app.config['LOGLEVEL'])
logger = logging.getLogger('CLAMAV-REST')

try:
    cd = clamd.ClamdAsyncNetworkSocket(host=app.config['CLAMD_HOST'],
                                       port=app.config['CLAMD_PORT'])
except BaseException:
    logger.exception('error bootstrapping clamd for network socket')


# https://gitlab.com/pgjones/quart-auth/-/issues/6#note_460844029
def auth_required(func):
    @wraps(func)
    async def wrapper(*args, **kwargs):
        if (current_app.config['AUTH_USERNAME']
                and current_app.config['AUTH_PASSWORD']):
            auth = request.authorization
            if (auth is not None and auth.type == 'basic'
                    and auth.username == current_app.config['AUTH_USERNAME']
                    and compare_digest(auth.password,
                                       current_app.config['AUTH_PASSWORD'])):
Example #2
0
 def __init__(self):
     self.clamd = clamd.ClamdAsyncNetworkSocket(CLAMD_HOST, CLAMD_PORT,
                                                CLAMD_TIMEOUT)
Example #3
0
 def __init__(self):
     super(Scanner, self).__init__(ScanMode.ASYNC)
     self.clamd = clamd.ClamdAsyncNetworkSocket(CLAMD_HOST, CLAMD_PORT,
                                                CLAMD_TIMEOUT)