def query_images_by_vulnerability_get(user_id, vulnerability_id=None, severity=None, namespace=None, affected_package=None, vendor_only=True): try: session = get_session() request_inputs = apis.do_request_prep(connexion.request, default_params={ 'vulnerability_id': vulnerability_id, 'severity': severity, 'namespace': namespace, 'affected_package': affected_package, 'vendor_only': vendor_only }) return_object, httpcode = query_images_by_vulnerability( session, request_inputs) except Exception as err: httpcode = 500 return_object = str(err) finally: session.close() return (return_object, httpcode)
def query_images_by_vulnerability_get( user_id, vulnerability_id=None, severity=None, namespace=None, affected_package=None, vendor_only=True, ): log.info("Querying images by vulnerability {}".format(vulnerability_id)) session = get_session() try: # request prep is unnecessary but keeping it around for now to avoid weird corner cases request_inputs = apis.do_request_prep( connexion.request, default_params={ "vulnerability_id": vulnerability_id, "severity": severity, "namespace": namespace, "affected_package": affected_package, "vendor_only": vendor_only, }, ) request_account_id = request_inputs["userId"] request_id = request_inputs.get("params", {}).get("vulnerability_id", None) request_severity_filter = request_inputs.get("params", {}).get("severity", None) request_namespace_filter = request_inputs.get("params", {}).get( "namespace", None) request_affected_package_filter = request_inputs.get("params", {}).get( "affected_package", None) request_vendor_only = request_inputs.get("params", {}).get("vendor_only", True) return_object = get_vulnerabilities_provider( ).get_images_by_vulnerability( request_account_id, request_id, request_severity_filter, request_namespace_filter, request_affected_package_filter, request_vendor_only, session, ) httpcode = 200 except Exception as err: log.exception("Error querying images by vulnerability") httpcode = 500 return_object = make_response_error(err, in_httpcode=httpcode) finally: session.close() return return_object, httpcode