
# 获取漏洞详情 - ShowVulnerability
#### 功能介绍
获取漏洞详情
#### 调用方法
请参见[如何调用API](https://support.huaweicloud.com/api-secmaster/secmaster_03_0008.html)。
#### 授权信息
账号具备所有API的调用权限，如果使用账号下的IAM用户调用当前API，该IAM用户需具备调用API所需的权限，具体权限要求请参见[权限和授权项](https://support.huaweicloud.com/api-secmaster/secmaster_03_0023.html)。
#### URI
GET /v1/{project_id}/workspaces/{workspace_id}/soc/vulnerability/{vul_id}
表1路径参数 
| 参数           | 是否必选 | 参数类型   | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
|:---|:---|:---|:---|
| project_id   | 是    | String | **参数解释：** 项目ID，用于明确项目归属，配置后可通过该ID查询项目下资产，可以通过调用API获取，也可以从控制台获取。[获取项目ID](https://support.huaweicloud.com/api-secmaster/secmaster_03_0014.html) **约束限制：** 不涉及 **取值范围：** 不涉及 **默认取值：** 不涉及 |
| workspace_id | 是    | String | **参数解释：** 工作空间id。 **约束限制：** 不涉及 **取值范围：** 不涉及 **默认取值：** 不涉及                                                                                                                             |
| vul_id       | 是    | String | 漏洞id                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
   
#### 请求参数
无
#### 响应参数
**状态码：200**
表2响应Body参数 
| 参数      | 参数类型                                                                           | 描述   |
|:---|:---|:---|
| code    | String                                                                         | 错误码  |
| message | String                                                                         | 错误信息 |
| data    | [VulnerabilityDetail] object | 漏洞详情 |
   
 表3VulnerabilityDetail 
| 参数             | 参数类型                                                                                   | 描述                                                                            |
|:---|:---|:---|
| id             | String                                                                                 | 漏洞id                                                                          |
| format_version | Integer                                                                                | 格式版本                                                                          |
| version        | Integer                                                                                | 版本                                                                            |
| project_id     | String                                                                                 | 当前项目的id                                                                       |
| workspace_id   | String                                                                                 | 当前的工作空间id                                                                     |
| create_time    | String                                                                                 | 创建时间，格式ISO8601：YYYY-MM-DDTHH:mm:ss.ms+timezone。时区信息为事件发生时区，无法解析时区的时间，默认时区填东八区 |
| update_time    | String                                                                                 | 更新时间，格式ISO8601：YYYY-MM-DDTHH:mm:ss.ms+timezone。时区信息为事件发生时区，无法解析时区的时间，默认时区填东八区 |
| dataclass_ref  | [dataclass_ref] object                     | 数据类对象                                                                         |
| data_object    | [VulnerabilityDataObject] object | 数据类                                                                           |
   
 表4dataclass_ref 
| 参数   | 参数类型   | 描述                     |
|:---|:---|:---|
| id   | String | 数据类唯一标识，UUID格式，最大36个字符 |
| name | String | 数据类名称                  |
   
 表5VulnerabilityDataObject 
| 参数                  | 参数类型                                                                         | 描述                                                                              |
|:---|:---|:---|
| vul_name            | String                                                                       | 漏洞名称                                                                            |
| first_observed_time | String                                                                       | 首次发现时间，格式ISO8601：YYYY-MM-DDTHH:mm:ss.ms+timezone。时区信息为事件发生时区，无法解析时区的时间，默认时区填东八区 |
| batch_number        | String                                                                       | 漏洞批次号                                                                           |
| description         | String                                                                       | 漏洞描述                                                                            |
| resource_num        | Integer                                                                      | 受影响的资产数量                                                                        |
| domain_id           | String                                                                       | 租户id                                                                            |
| workspace_id        | String                                                                       | 工作空间id                                                                          |
| remediation         | [remediation] object               | 修复建议                                                                            |
| domain_name         | String                                                                       | 租户名称                                                                            |
| update_time         | String                                                                       | 更新时间                                                                            |
| is_deleted          | Boolean                                                                      | 是否删除                                                                            |
| project_id          | String                                                                       | 项目ID                                                                            |
| extend_properties   | [extend_properties] object   | 扩展属性                                                                            |
| region_name         | String                                                                       | 区域名称                                                                            |
| id                  | String                                                                       | 漏洞公告ID                                                                          |
| vulnerability_type  | [vulnerability_type] object | 漏洞类型信息                                                                          |
| create_time         | String                                                                       | 创建时间                                                                            |
| last_observed_time  | String                                                                       | 最后发现时间                                                                          |
| resource            | [resource] object                     | 资产信息                                                                            |
| count               | Integer                                                                      | 漏洞计数                                                                            |
| region_id           | String                                                                       | 区域ID                                                                            |
| vulnerability       | [vulnerability] object           | 漏洞详细信息                                                                          |
| dataclass_id        | String                                                                       | 数据分类ID                                                                          |
| version             | String                                                                       | 漏洞版本号                                                                           |
| data_source         | [data_source] object               | 数据来源                                                                            |
| arrive_time         | String                                                                       | 数据到达时间                                                                          |
| environment         | [environment] object               | 环境信息                                                                            |
| trigger_flag        | Boolean                                                                      | 是否触发标记                                                                          |
| handled             | Integer                                                                      | 处理状态                                                                            |
   
 表6remediation 
| 参数             | 参数类型   | 描述     |
|:---|:---|:---|
| recommendation | String | 推荐修复措施 |
   
 表7extend_properties 
| 参数         | 参数类型                                                         | 描述     |
|:---|:---|:---|
| operations | [operations] object | 扩展操作属性 |
   
 表8operations 
| 参数          | 参数类型   | 描述                                     |
|:---|:---|:---|
| is_build_in | String | 是否内置属性，取值说明：false 表示手工导入漏洞；true 表示内置漏洞 |
   
 表9vulnerability_type 
| 参数                    | 参数类型   | 描述     |
|:---|:---|:---|
| id                    | String | 类型ID   |
| category              | String | 漏洞类别   |
| category_en           | String | 漏洞类别英文 |
| category_zh           | String | 漏洞类别中文 |
| vulnerability_type    | String | 漏洞类型   |
| vulnerability_type_en | String | 漏洞类型英文 |
| vulnerability_type_zh | String | 漏洞类型中文 |
   
 表10resource 
| 参数         | 参数类型                 | 描述     |
|:---|:---|:---|
| id         | String               | 资产ID   |
| name       | String               | 资产名称   |
| type       | String               | 资产类型   |
| provider   | String               | 提供商    |
| region_id  | String               | 区域ID   |
| domain_id  | String               | 租户ID   |
| project_id | String               | 项目ID   |
| ep_id      | String               | 企业项目ID |
| tags       | Map\<String,String\> | 资产标签   |
   
 表11vulnerability 
| 参数              | 参数类型             | 描述     |
|:---|:---|:---|
| id              | String           | 漏洞ID   |
| type            | Integer          | 漏洞类型编号 |
| url             | String           | 漏洞链接   |
| status          | Integer          | 漏洞状态   |
| level           | String           | 漏洞等级   |
| reason          | String           | 漏洞产生原因 |
| solution        | String           | 漏洞解决方案 |
| repair_severity | Integer          | 修复紧急程度 |
| related         | Array of objects | 相关漏洞   |
| tags            | Array of strings | 漏洞标签   |
   
 表12data_source 
| 参数              | 参数类型    | 描述   |
|:---|:---|:---|
| domain_id       | String  | 租户ID |
| project_id      | String  | 项目ID |
| region_id       | String  | 区域ID |
| company_name    | String  | 公司名称 |
| source_type     | Integer | 来源类型 |
| product_name    | String  | 产品名称 |
| product_feature | String  | 产品特性 |
   
 表13environment 
| 参数          | 参数类型   | 描述   |
|:---|:---|:---|
| domain_id   | String | 租户ID |
| domain_name | String | 租户名称 |
| project_id  | String | 项目ID |
| region_id   | String | 区域ID |
| region_name | String | 区域名称 |
| vendor_type | String | 厂商类型 |
   
#### 请求示例
```
https://{endpoint}/v1/{project_id}/workspaces/{workspace_id}/soc/vulnerability/{vul_id}
```
#### 响应示例
**状态码：200**
获取漏洞详情返回body体
```
{
  "code" : "00000000",
  "message" : "",
  "data" : {
    "id" : "",
    "format_version" : 0,
    "version" : 0,
    "project_id" : "",
    "workspace_id" : "",
    "data_object" : {
      "vul_name" : "vulnerability_a",
      "description" : "vulnerability_a description",
      "workspace_id" : "ea95*****55",
      "remediation" : {
        "recommendation" : "Download and install the patch KB*****5.For details, please refer to:https://*****5.Or use Windows Update to install patches."
      },
      "project_id" : "1564*****a6",
      "vulnerability" : {
        "id" : "KB*****5",
        "type" : 1,
        "url" : "Download and install the patch KB*****5.For details, please refer to:https://*****5.Or use Windows Update to install patches.",
        "level" : "Medium",
        "solution" : "Download and install the patch KB*****5.For details, please refer to:https://*****5.Or use Windows Update to install patches.",
        "repair_severity" : 2,
        "related" : [ {
          "cnnvd_id" : "",
          "cnvd_id" : "",
          "cve_description" : "",
          "cve_id" : "CVE-******37",
          "cve_name" : "",
          "cve_url" : "",
          "cvss" : "",
          "cvss_vector" : "",
          "cvss_version" : "",
          "public_time" : ""
        } ],
        "tags" : [ ]
      }
    }
  }
}
```
#### SDK代码示例
SDK代码示例如下。
- [Java]
  ```
  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.secmaster.v1.region.SecMasterRegion;
  import com.huaweicloud.sdk.secmaster.v1.*;
  import com.huaweicloud.sdk.secmaster.v1.model.*;
  public class ShowVulnerabilitySolution {
      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");
          String projectId = "{project_id}";
          ICredential auth = new BasicCredentials()
                  .withProjectId(projectId)
                  .withAk(ak)
                  .withSk(sk);
          SecMasterClient client = SecMasterClient.newBuilder()
                  .withCredential(auth)
                  .withRegion(SecMasterRegion.valueOf("<YOUR REGION>"))
                  .build();
          ShowVulnerabilityRequest request = new ShowVulnerabilityRequest();
          request.withWorkspaceId("{workspace_id}");
          request.withVulId("{vul_id}");
          try {
              ShowVulnerabilityResponse response = client.showVulnerability(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]
  ```
  # coding: utf-8
  import os
  from huaweicloudsdkcore.auth.credentials import BasicCredentials
  from huaweicloudsdksecmaster.v1.region.secmaster_region import SecMasterRegion
  from huaweicloudsdkcore.exceptions import exceptions
  from huaweicloudsdksecmaster.v1 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 = os.environ["CLOUD_SDK_AK"]
      sk = os.environ["CLOUD_SDK_SK"]
      projectId = "{project_id}"
      credentials = BasicCredentials(ak, sk, projectId)
      client = SecMasterClient.new_builder() \
          .with_credentials(credentials) \
          .with_region(SecMasterRegion.value_of("<YOUR REGION>")) \
          .build()
      try:
          request = ShowVulnerabilityRequest()
          request.workspace_id = "{workspace_id}"
          request.vul_id = "{vul_id}"
          response = client.show_vulnerability(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]
  ```
  package main
  import (
  "fmt"
  "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
      secmaster "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v1"
  "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v1/model"
      region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v1/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")
      projectId := "{project_id}"
      auth, err := basic.NewCredentialsBuilder().
          WithAk(ak).
          WithSk(sk).
          WithProjectId(projectId).
          SafeBuild()
      if err != nil {
          fmt.Println(err)
          return
      }
      hcClient, err := secmaster.SecMasterClientBuilder().
           WithRegion(region.ValueOf("<YOUR REGION>")).
           WithCredential(auth).
           SafeBuild()
      if err != nil {
          fmt.Println(err)
          return
      }
      client := secmaster.NewSecMasterClient(hcClient)
      request := &model.ShowVulnerabilityRequest{}
  request.WorkspaceId = "{workspace_id}"
  request.VulId = "{vul_id}"
  response, err := client.ShowVulnerability(request)
  if err == nil {
          fmt.Printf("%+v\n", response)
      } else {
          fmt.Println(err)
      }
  }
  ```
- [更多]
  更多编程语言的SDK代码示例，请参见[API Explorer](https://console.huaweicloud.com/apiexplorer/#/openapi/SecMaster/sdk?api=ShowVulnerability&version=v1)的代码示例页签，可生成自动对应的SDK代码示例。
#### 状态码
| 状态码 | 描述            |
|:---|:---|
| 200 | 获取漏洞详情返回body体 |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-secmaster/ErrorCode.html)。
