Consulta de la lista de vulnerabilidades
Función
Esta API se utiliza para consultar la lista de vulnerabilidades detectadas.
Método de invocación
Para obtener más información, consulte Invocación a las API.
URI
GET /v5/{project_id}/vulnerability/vulnerabilities
Parámetro |
Obligatorio |
Tipo |
Descripción |
---|---|---|---|
project_id |
Sí |
String |
ID de proyecto Mínimo: 1 Máximo: 256 |
Parámetro |
Obligatorio |
Tipo |
Descripción |
---|---|---|---|
enterprise_project_id |
No |
String |
ID de proyecto empresarial. El valor 0 indica el proyecto de empresa predeterminado. Para consultar todos los proyectos empresariales, establezca este parámetro en all_granted_eps. Valor predeterminado: 0 Mínimo: 0 Máximo: 256 |
type |
No |
String |
Tipo de vulnerabilidad. Las opciones son las siguientes: -linux_vul: vulnerabilidad de Linux -windows_vul: vulnerabilidad de Windows -web_cms: vulnerabilidad de Web-CMS -app_vul: vulnerabilidad de aplicación Mínimo: 0 Máximo: 32 |
vul_id |
No |
String |
ID de vulnerabilidad Mínimo: 0 Máximo: 256 |
vul_name |
No |
String |
Nombre de vulnerabilidad Mínimo: 0 Máximo: 256 |
limit |
No |
Integer |
Número de registros mostrados en cada página Mínimo: 0 Máximo: 200 Valor predeterminado: 10 |
offset |
No |
Integer |
Desfase, que especifica la posición inicial del registro que se va a devolver. El valor debe ser un número no menor que 0. El valor predeterminado es 0. Mínimo: 0 Máximo: 2000000 Valor predeterminado: 0 |
repair_priority |
No |
String |
Corregir prioridad crítica alta media baja Mínimo: 1 Máximo: 10 |
handle_status |
No |
String |
descripción: |- Estado de gestión. Las opciones son las siguientes: - unhandled - handled Valor predeterminado: unhandled Mínimo: 1 Máximo: 32 |
cve_id |
No |
String |
ID de vulnerabilidad Mínimo: 0 Máximo: 32 |
label_list |
No |
String |
Etiqueta de vulnerabilidad Mínimo: 0 Máximo: 128 |
status |
No |
String |
Estado de vulnerabilidad Mínimo: 0 Máximo: 32 |
asset_value |
No |
String |
Importancia de los activos importante prueba común Mínimo: 0 Máximo: 32 |
group_name |
No |
String |
Nombre del grupo de servidores Mínimo: 0 Máximo: 256 |
Parámetros de solicitud
Parámetro |
Obligatorio |
Tipo |
Descripción |
---|---|---|---|
X-Auth-Token |
Sí |
String |
Token de usuario. Se puede obtener invocando a la API de IAM utilizada para obtener un token de usuario. El valor de X-Subject-Token en el encabezado de respuesta es un token. Mínimo: 1 Máximo: 32768 |
Parámetros de respuesta
Código de estado: 200
Parámetro |
Tipo |
Descripción |
---|---|---|
total_num |
Long |
Número total de vulnerabilidades de software Mínimo: 0 Máximo: 2147483647 |
data_list |
Array of VulInfo objects |
Lista de vulnerabilidades de software Longitud de matriz: 0 - 2147483647 |
Parámetro |
Tipo |
Descripción |
---|---|---|
vul_name |
String |
Nombre de vulnerabilidad Mínimo: 0 Máximo: 256 |
vul_id |
String |
ID de vulnerabilidad Mínimo: 0 Máximo: 64 |
label_list |
Array of strings |
Etiqueta de vulnerabilidad Mínimo: 0 Máximo: 65534 Longitud de matriz: 0 - 2147483647 |
repair_necessity |
String |
Necesidad de reparación
Mínimo: 0 Máximo: 64 |
severity_level |
String |
Severidad
Mínimo: 0 Máximo: 64 |
host_num |
Integer |
Cantidad de servidores afectados Mínimo: 0 Máximo: 2147483647 |
unhandle_host_num |
Integer |
Número de servidores no procesados, excluidos servidores ignorados y fijos Mínimo: 0 Máximo: 2147483647 |
scan_time |
Long |
Último escaneado, en ms. Mínimo: 0 Máximo: 9223372036854775807 |
solution_detail |
String |
Guía de corrección de vulnerabilidades Mínimo: 0 Máximo: 65534 |
url |
String |
URL de vulnerabilidad Mínimo: 0 Máximo: 2083 |
description |
String |
Descripción de la vulnerabilidad Mínimo: 0 Máximo: 65534 |
type |
String |
Tipo de vulnerabilidad. Las opciones son las siguientes: -linux_vul: vulnerabilidad de Linux -windows_vul: vulnerabilidad de Windows -web_cms: vulnerabilidad de Web-CMS -app_vul: vulnerabilidad de aplicación Mínimo: 0 Máximo: 128 |
host_id_list |
Array of strings |
Listas de servidores que pueden manejar la vulnerabilidad Mínimo: 0 Máximo: 128 Longitud de matriz: 0 - 2147483647 |
cve_list |
Array of cve_list objects |
Lista de CVE Longitud de matriz: 1 - 10000 |
patch_url |
String |
Dirección del parche Mínimo: 0 Máximo: 512 |
repair_priority |
String |
Corregir prioridad crítica alta media baja Mínimo: 1 Máximo: 32 |
hosts_num |
VulnerabilityHostNumberInfo object |
Servidor afectado |
repair_success_num |
Integer |
Número de reparaciones exitosas Mínimo: 0 Máximo: 1000000 |
fixed_num |
Long |
Número de reparaciones Mínimo: 0 Máximo: 1000000 |
ignored_num |
Long |
Número de elementos ignorados Mínimo: 0 Máximo: 1000000 |
verify_num |
Integer |
Número de verificaciones Mínimo: 0 Máximo: 1000000 |
repair_priority_list |
Array of RepairPriorityListInfo objects |
Prioridad de corrección. El número de servidores correspondientes a cada prioridad de corrección. Longitud de la matriz: 0 - 4 |
Parámetro |
Tipo |
Descripción |
---|---|---|
cve_id |
String |
ID de CVE Mínimo: 1 Máximo: 32 |
cvss |
Float |
Puntuación de CVSS Mínimo: 0 Máximo: 10 |
Solicitudes de ejemplo
Consulte los primeros 10 registros de la lista de vulnerabilidades cuyo project_id sea 2b31ed520xxxxxxebedb6e57xxxxxxxx.
GET https://{endpoint}/v5/2b31ed520xxxxxxebedb6e57xxxxxxxx/vulnerability/vulnerabilities?offset=0&limit=10
Ejemplo de respuestas
Código de estado: 200
Lista de vulnerabilidades
{ "total_num" : 1, "data_list" : [ { "description" : "It was discovered that FreeType did not correctly handle certain malformed font files. If a user were tricked into using a specially crafted font file, a remote attacker could cause FreeType to crash, or possibly execute arbitrary code.", "host_id_list" : [ "caa958ad-a481-4d46-b51e-6861b8864515" ], "host_num" : 1, "scan_time" : 1661752185836, "severity_level" : "Critical", "repair_necessity" : "Critical", "solution_detail" : "To upgrade the affected software", "type" : "linux_vul", "unhandle_host_num" : 0, "url" : "https://ubuntu.com/security/CVE-2022-27405", "vul_id" : "USN-5528-1", "vul_name" : "USN-5528-1: FreeType vulnerabilities", "repair_priority_list" : [ { "repair_priority" : "Critical", "host_num" : 0 }, { "repair_priority" : "High", "host_num" : 0 }, { "repair_priority" : "Medium", "host_num" : 1 }, { "repair_priority" : "Low", "host_num" : 0 } ] } ] }
Código de ejemplo del SDK
El código de ejemplo del SDK es el siguiente.
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.hss.v5.region.HssRegion; import com.huaweicloud.sdk.hss.v5.*; import com.huaweicloud.sdk.hss.v5.model.*; public class ListVulnerabilitiesSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); ICredential auth = new BasicCredentials() .withAk(ak) .withSk(sk); HssClient client = HssClient.newBuilder() .withCredential(auth) .withRegion(HssRegion.valueOf("<YOUR REGION>")) .build(); ListVulnerabilitiesRequest request = new ListVulnerabilitiesRequest(); request.withEnterpriseProjectId("<enterprise_project_id>"); request.withType("<type>"); request.withVulId("<vul_id>"); request.withVulName("<vul_name>"); request.withLimit(<limit>); request.withOffset(<offset>); request.withRepairPriority("<repair_priority>"); request.withHandleStatus("<handle_status>"); request.withCveId("<cve_id>"); request.withLabelList("<label_list>"); request.withStatus("<status>"); request.withAssetValue("<asset_value>"); request.withGroupName("<group_name>"); try { ListVulnerabilitiesResponse response = client.listVulnerabilities(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } } |
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkhss.v5.region.hss_region import HssRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkhss.v5 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = __import__('os').getenv("CLOUD_SDK_AK") sk = __import__('os').getenv("CLOUD_SDK_SK") credentials = BasicCredentials(ak, sk) \ client = HssClient.new_builder() \ .with_credentials(credentials) \ .with_region(HssRegion.value_of("<YOUR REGION>")) \ .build() try: request = ListVulnerabilitiesRequest() request.enterprise_project_id = "<enterprise_project_id>" request.type = "<type>" request.vul_id = "<vul_id>" request.vul_name = "<vul_name>" request.limit = <limit> request.offset = <offset> request.repair_priority = "<repair_priority>" request.handle_status = "<handle_status>" request.cve_id = "<cve_id>" request.label_list = "<label_list>" request.status = "<status>" request.asset_value = "<asset_value>" request.group_name = "<group_name>" response = client.list_vulnerabilities(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
Go
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" hss "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/hss/v5" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/hss/v5/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/hss/v5/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). Build() client := hss.NewHssClient( hss.HssClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.ListVulnerabilitiesRequest{} enterpriseProjectIdRequest:= "<enterprise_project_id>" request.EnterpriseProjectId = &enterpriseProjectIdRequest typeRequest:= "<type>" request.Type = &typeRequest vulIdRequest:= "<vul_id>" request.VulId = &vulIdRequest vulNameRequest:= "<vul_name>" request.VulName = &vulNameRequest limitRequest:= int32(<limit>) request.Limit = &limitRequest offsetRequest:= int32(<offset>) request.Offset = &offsetRequest repairPriorityRequest:= "<repair_priority>" request.RepairPriority = &repairPriorityRequest handleStatusRequest:= "<handle_status>" request.HandleStatus = &handleStatusRequest cveIdRequest:= "<cve_id>" request.CveId = &cveIdRequest labelListRequest:= "<label_list>" request.LabelList = &labelListRequest statusRequest:= "<status>" request.Status = &statusRequest assetValueRequest:= "<asset_value>" request.AssetValue = &assetValueRequest groupNameRequest:= "<group_name>" request.GroupName = &groupNameRequest response, err := client.ListVulnerabilities(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
Más información
Para obtener un código de ejemplo del SDK de más lenguajes de programación, consulte la pestaña Código de ejemplo en API Explorer. El código de ejemplo del SDK se puede generar automáticamente.
Códigos de estado
Código de estado |
Descripción |
---|---|
200 |
Lista de vulnerabilidades |
Códigos de error
Consulte Códigos de error.