更新时间:2025-09-26 GMT+08:00
分享

查询安全风险列表

功能介绍

查询安全风险列表

调用方法

请参见如何调用API

URI

GET /v5/{project_id}/overview/security/risk/list

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

参数解释:

项目ID,用于明确项目归属,配置后可通过该ID查询项目下资产。获取方式请参见获取项目ID

约束限制:

不涉及

取值范围:

字符长度1-256位

默认取值:

不涉及

表2 Query参数

参数

是否必选

参数类型

描述

enterprise_project_id

String

参数解释:

企业项目ID,用于过滤不同企业项目下的资产。获取方式请参见获取企业项目ID

如需查询所有企业项目下的资产请传参“all_granted_eps”。

约束限制:

开通企业项目功能后才需要配置企业项目ID参数。

取值范围:

字符长度1-256位

默认取值:

0,表示默认企业项目(default)。

请求参数

表3 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

参数解释:

用户Token,包含了用户的身份、权限等信息,在调用API接口时,可通过Token进行身份认证。获取方式请参见获取用户Token

约束限制:

不涉及

取值范围:

字符长度1-32768位

默认取值:

不涉及

响应参数

状态码:200

表4 响应Body参数

参数

参数类型

描述

alarm_risk

AlarmRiskInfo object

参数解释

入侵风险

baseline_risk

baseline_risk object

参数解释

基线风险

asset_risk

asset_risk object

参数解释

资产风险

security_protect_risk

security_protect_risk object

参数解释

安全防护风险

vul_risk

vul_risk object

参数解释

漏洞风险

image_risk

image_risk object

参数解释

镜像风险

total_risk_num

Integer

参数解释

总风险数量

取值范围:

最小值0,最大值2147483647

表5 AlarmRiskInfo

参数

参数类型

描述

risk_list

Array of RiskListInfo objects

参数解释

风险列表

取值范围:

最小值0,最大值4

deduct_score

Float

参数解释

扣分

取值范围:

最小值0,最大值30

policy_list

Array of PolicyInfo objects

参数解释

策略信息

取值范围:

最小值0,最大值32

total_risk_num

Integer

参数解释

风险总数

取值范围:

最小值0,最大值2147483647

表6 baseline_risk

参数

参数类型

描述

risk_list

Array of RiskListInfo objects

参数解释

基线风险列表

取值范围:

最小值0,最大值4

deduct_score

Float

参数解释

扣分

取值范围:

最小值0,最大值20

policy_list

Array of PolicyInfo objects

参数解释

未开启的策略列表

取值范围:

最小值0,最大值32

existed_pwd_host_num

Integer

参数解释

存在弱口令主机数量

取值范围:

最小值0,最大值2147483647

un_scanned_baseline_host_num

Integer

参数解释

未进行基线配置检查的主机数

取值范围:

最小值0,最大值2147483647

total_risk_num

Integer

参数解释

风险总数

取值范围:

最小值0,最大值2147483647

表7 asset_risk

参数

参数类型

描述

existed_danger_port_host_num

Integer

参数解释

存在危险端口主机数

取值范围:

最小值0,最大值2147483647

policy_list

Array of PolicyInfo objects

参数解释

策略列表

取值范围:

最小值0,最大值32

deduct_score

Float

参数解释

扣分

取值范围:

最小值0,最大值10

total_risk_num

Integer

参数解释

风险总数

取值范围:

最小值0,最大值2147483647

表8 PolicyInfo

参数

参数类型

描述

policy_id

String

策略ID

policy_name

String

策略名称

os_type

String

操作系统类型

host_num

Integer

关联服务器数

rule_name

String

检测特性规则名称,中间以逗号隔开

表9 security_protect_risk

参数

参数类型

描述

un_open_protection_host_num

Integer

参数解释

未开主机安全防护主机数

取值范围:

最小值0,最大值2147483647

deduct_score

Float

参数解释

扣分

取值范围:

最小值0,最大值10

total_risk_num

Integer

参数解释

风险总数

取值范围:

最小值0,最大值2147483647

表10 vul_risk

参数

参数类型

描述

risk_list

Array of RiskListInfo objects

参数解释

漏洞风险列表

取值范围:

最小值0,最大值4

deduct_score

Float

参数解释

扣分

取值范围:

最小值0,最大值20

un_scanned_host_num

Integer

参数解释

未进行漏洞扫描主机数(一个月内)

取值范围:

最小值0,最大值2147483647

total_risk_num

Integer

参数解释

风险总数

取值范围:

最小值0,最大值2147483647

表11 RiskListInfo

参数

参数类型

描述

severity

String

参数解释

风险级别

取值范围:

字符长度0-32位

risk_num

Integer

参数解释

风险数量

取值范围:

最小值0,最大值2147483647

effected_host_num

Integer

参数解释

受影响资产数量

取值范围:

最小值0,最大值2147483647

表12 image_risk

参数

参数类型

描述

deduct_score

Float

参数解释

扣分

取值范围:

最小值0,最大值10

un_scanned_image_num

Integer

参数解释

未扫描镜像数

取值范围:

最小值0,最大值2147483647

risk_list

Array of risk_list objects

参数解释

风险列表

取值范围:

最小值0,最大值4

total_risk_num

Integer

参数解释

风险总数

取值范围:

最小值0,最大值2147483647

表13 risk_list

参数

参数类型

描述

severity

String

参数解释

风险级别

取值范围:

字符长度0-32位

image_num

Integer

参数解释

镜像数量

取值范围:

最小值0,最大值2147483647

请求示例

查询安全风险列表

GET https://{endpoint}/v5/{project_id}/overview/security/risk/list

响应示例

状态码:200

请求已成功

{
  "asset_risk" : {
    "existed_danger_port_host_num" : 0,
    "existed_eip_host_num" : 0,
    "deduct_score" : 0,
    "policy_list" : [ {
      "type" : "assetmanage_collect",
      "count" : 0
    } ],
    "total_risk_num" : 0
  },
  "baseline_risk" : {
    "risk_list" : [ {
      "severity" : "High",
      "effected_host_num" : 1,
      "risk_num" : 1
    }, {
      "severity" : "Low",
      "effected_host_num" : 1,
      "risk_num" : 1
    }, {
      "severity" : "Medium",
      "effected_host_num" : 11,
      "risk_num" : 18
    } ],
    "deduct_score" : 20,
    "policy_list" : [ {
      "type" : "pwd_check_feature",
      "count" : 0
    } ],
    "existed_pwd_host_num" : 16,
    "un_scanned_baseline_host_num" : 3,
    "total_risk_num" : 39
  },
  "vul_risk" : {
    "risk_list" : [ {
      "severity" : "High",
      "effected_host_num" : 34,
      "risk_num" : 500
    }, {
      "severity" : "Medium",
      "effected_host_num" : 36,
      "risk_num" : 3569
    }, {
      "severity" : "Low",
      "effected_host_num" : 35,
      "risk_num" : 658
    } ],
    "deduct_score" : 20,
    "un_scanned_host_num" : 2,
    "total_risk_num" : 4729
  },
  "alarm_risk" : {
    "risk_list" : [ {
      "severity" : "Critical",
      "effected_host_num" : 35,
      "risk_num" : 27
    }, {
      "severity" : "High",
      "effected_host_num" : 35,
      "risk_num" : 4103
    }, {
      "severity" : "Medium",
      "effected_host_num" : 35,
      "risk_num" : 75
    }, {
      "severity" : "Low",
      "effected_host_num" : 35,
      "risk_num" : 936
    } ],
    "deduct_score" : 30,
    "policy_list" : [ {
      "type" : "webguard_feature",
      "count" : 0
    }, {
      "type" : "login_check_feature",
      "count" : 0
    }, {
      "type" : "any_policy",
      "count" : 0
    }, {
      "type" : "container_running_detect",
      "count" : 4
    }, {
      "type" : "antiransomware_feature",
      "count" : 0
    } ],
    "total_risk_num" : 5145
  },
  "image_risk" : {
    "risk_list" : [ {
      "severity" : "High",
      "image_num" : 507
    }, {
      "severity" : "Medium",
      "image_num" : 120
    }, {
      "severity" : "Low",
      "image_num" : 0
    } ],
    "deduct_score" : 10,
    "un_scanned_image_num" : 5,
    "total_risk_num" : 632,
    "total_image_num" : 805
  },
  "security_protect_risk" : {
    "un_open_protection_host_num" : 118,
    "deduct_score" : 10,
    "total_risk_num" : 118
  },
  "total_risk_num" : 10663
}

SDK代码示例

SDK代码示例如下。

 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
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 ListSecurityRiskSolution {

    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);

        HssClient client = HssClient.newBuilder()
                .withCredential(auth)
                .withRegion(HssRegion.valueOf("<YOUR REGION>"))
                .build();
        ListSecurityRiskRequest request = new ListSecurityRiskRequest();
        try {
            ListSecurityRiskResponse response = client.listSecurityRisk(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());
        }
    }
}
 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
# coding: utf-8

import os
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 = os.environ["CLOUD_SDK_AK"]
    sk = os.environ["CLOUD_SDK_SK"]
    projectId = "{project_id}"

    credentials = BasicCredentials(ak, sk, projectId)

    client = HssClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(HssRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = ListSecurityRiskRequest()
        response = client.list_security_risk(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)
 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
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")
    projectId := "{project_id}"

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        WithProjectId(projectId).
        Build()

    client := hss.NewHssClient(
        hss.HssClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.ListSecurityRiskRequest{}
	response, err := client.ListSecurityRisk(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。

状态码

状态码

描述

200

请求已成功

错误码

请参见错误码

相关文档