Beispiel #1
0
from common.identity import get_identity, is_entitled_smart_management
from common.logging import get_logger
from common.peewee_model import CveMetadata, RHAccount

LOGGER = get_logger(__name__)

DEFAULT_ROUTE = "%s/%s" % (os.environ.get(
    'PATH_PREFIX', "/api"), os.environ.get('APP_NAME', "vulnerability"))
IDENTITY_HEADER = "x-rh-identity"
DEFAULT_PAGE_SIZE = 20
READ_ONLY_MODE = strtobool(os.environ.get('READ_ONLY_MODE', 'FALSE'))
DEFAULT_BUSINESS_RISK = 'Not Defined'
DEFAULT_STATUS = "Not Reviewed"
CVE_SYNOPSIS_SORT = [
    fn.SUBSTRING(CveMetadata.cve, r'-(\d+)-').cast('integer'),
    fn.SUBSTRING(CveMetadata.cve, r'-(\d+)$').cast('integer')
]
RBAC_URL = os.environ.get('RBAC_URL')
if RBAC_URL:
    RBAC_URL = '{}/api/rbac/v1/access/?application=vulnerability&limit=1000'.format(
        RBAC_URL)

LOGGER.info("Access URL: %s", DEFAULT_ROUTE)

# Prometheus support
# Counter for all-the-get-calls, dealt with in BaseHandler
REQUEST_COUNTS = Counter('ve_manager_invocations',
                         'Number of calls per handler', ['method', 'endpoint'])
ACCOUNT_REQUESTS = Counter('ve_manager_account_invocations',
                           'Number of calls per account', ['account'])
import requests

from common.identity import get_identity, is_entitled_smart_management
from common.logging import get_logger
from common.peewee_model import CveMetadata, RHAccount

LOGGER = get_logger(__name__)

DEFAULT_ROUTE = "%s/%s" % (os.environ.get('PATH_PREFIX', "/api"),
                           os.environ.get('APP_NAME', "vulnerability"))
IDENTITY_HEADER = "x-rh-identity"
DEFAULT_PAGE_SIZE = 25
READ_ONLY_MODE = strtobool(os.environ.get('READ_ONLY_MODE', 'FALSE'))
DEFAULT_BUSINESS_RISK = 'Not Defined'
DEFAULT_STATUS = "Not Reviewed"
CVE_SYNOPSIS_SORT = [fn.SUBSTRING(CveMetadata.cve, r'-(\d+)-').cast('integer'),
                     fn.SUBSTRING(CveMetadata.cve, r'-(\d+)$').cast('integer')]
RBAC_URL = os.environ.get('RBAC_URL')
if RBAC_URL:
    RBAC_URL = '{}/api/rbac/v1/access/?application=vulnerability&limit=1000'.format(RBAC_URL)

LOGGER.info("Access URL: %s", DEFAULT_ROUTE)

# Prometheus support
# Counter for all-the-get-calls, dealt with in BaseHandler
REQUEST_COUNTS = Counter('ve_manager_invocations', 'Number of calls per handler', ['method', 'endpoint'])
ACCOUNT_REQUESTS = Counter('ve_manager_account_invocations', 'Number of calls per account', ['account'])


class InvalidArgumentException(Exception):
    """Illegal arguments for pagination/filtering/sorting"""