Help Center/ Host Security Service/ API Reference/ API Description/ Baseline Management/ Querying the Result List of Server Security Configuration Check
Updated on 2024-07-04 GMT+08:00

Querying the Result List of Server Security Configuration Check

Function

This API is used to query the result list of a user's server security configuration check.

Calling Method

For details, see Calling APIs.

URI

GET /v5/{project_id}/baseline/risk-configs

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID.

Minimum: 1

Maximum: 256

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

enterprise_project_id

No

String

Enterprise project ID. To query all enterprise projects, set this parameter to all_granted_eps.

Minimum: 0

Maximum: 256

check_name

No

String

Baseline name, for example, SSH, CentOS 7, and Windows.

Minimum: 0

Maximum: 256

group_id

No

String

Indicates the policy group ID.

Minimum: 0

Maximum: 128

severity

No

String

Risk level. Its value can be:

  • Security

  • Low

  • Medium

  • High

Minimum: 1

Maximum: 32

standard

No

String

Standard type. Its value can be:

  • cn_standard: DJCP MLPS compliance standard

  • hw_standard: Cloud security practice standard

Minimum: 1

Maximum: 32

host_id

No

String

Host ID

Minimum: 0

Maximum: 128

limit

No

Integer

Number of records on each page

Minimum: 0

Maximum: 200

Default: 10

offset

No

Integer

Offset, which specifies the start position of the record to be returned.

Minimum: 0

Maximum: 2000000

Default: 0

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token. It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token.

Minimum: 1

Maximum: 32768

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

total_num

Long

Total number of records

Minimum: 0

Maximum: 2147483647

data_list

Array of SecurityCheckInfoResponseInfo objects

Server configuration check result list

Array Length: 0 - 2147483647

Table 5 SecurityCheckInfoResponseInfo

Parameter

Type

Description

severity

String

Risk level. Its value can be:

  • Low

  • Medium

  • High

Minimum: 1

Maximum: 32

check_name

String

Baseline name, for example, SSH, CentOS 7, and Windows.

Minimum: 0

Maximum: 256

check_type

String

Baseline type. The values for check_type and check_name are the same for Linux servers. For example, they can both be set to SSH or CentOS 7. For Windows servers, the values for check_type and check_name are different. For example, check_type can be set to Windows Server 2019 R2 or Windows Server 2016 R2.

Minimum: 0

Maximum: 256

standard

String

Standard type. Its value can be:

  • cn_standard: DJCP MLPS compliance standard

  • hw_standard: Cloud security practice standard

Minimum: 1

Maximum: 16

check_rule_num

Integer

Indicates the total number of check items of the current configuration check (baseline) type. For example, if the standard type of the SSH baseline is hw_standard, server security provides 17 check items, but only five check items of the SSH baseline are detected on all servers. Therefore, the value of check_rule_num is 5. All check items are checked on a server. The value of check_rule_num is 17.

Minimum: 0

Maximum: 2097152

failed_rule_num

Integer

Number of failed check items. If a server fails to pass a check item in check_rule_num, the item is counted in failed_rule_num.

Minimum: 0

Maximum: 2097152

host_num

Integer

The number of servers on which the current baseline detection is performed.

Minimum: 0

Maximum: 2097152

scan_time

Long

Latest detection time (ms)

Minimum: 0

Maximum: 2097152

check_type_desc

String

Description of the baseline type, including the standards for the check items and the issues that can be audited.

Minimum: 0

Maximum: 65534

Example Requests

This API is used to query the server baseline configuration check list whose enterprise project ID is xxx. Data on the first page (the first 10 records) is returned by default.

GET https://{endpoint}/v5/{project_id}/baseline/risk-configs?enterprise_project_id=xxx

Example Responses

Status code: 200

server security configuration check result

{
  "total_num" : 1,
  "data_list" : [ {
    "check_name" : "Docker",
    "check_rule_num" : 25,
    "check_type" : "Docker",
    "check_type_desc" : "Configuring security audit of Docker's host configurations and container-running-related contents based on Docker Container Security Specifications V1_0.",
    "failed_rule_num" : 20,
    "host_num" : 0,
    "scan_time" : 1661716860935,
    "severity" : "High",
    "standard" : "hw_standard"
  } ]
}

SDK Sample Code

The SDK sample code is as follows.

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

    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();
        ListRiskConfigsRequest request = new ListRiskConfigsRequest();
        request.withEnterpriseProjectId("<enterprise_project_id>");
        request.withCheckName("<check_name>");
        request.withGroupId("<group_id>");
        request.withSeverity("<severity>");
        request.withStandard("<standard>");
        request.withHostId("<host_id>");
        request.withLimit(<limit>);
        request.withOffset(<offset>);
        try {
            ListRiskConfigsResponse response = client.listRiskConfigs(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
32
33
34
35
36
37
38
# 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"]

    credentials = BasicCredentials(ak, sk)

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

    try:
        request = ListRiskConfigsRequest()
        request.enterprise_project_id = "<enterprise_project_id>"
        request.check_name = "<check_name>"
        request.group_id = "<group_id>"
        request.severity = "<severity>"
        request.standard = "<standard>"
        request.host_id = "<host_id>"
        request.limit = <limit>
        request.offset = <offset>
        response = client.list_risk_configs(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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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.ListRiskConfigsRequest{}
	enterpriseProjectIdRequest:= "<enterprise_project_id>"
	request.EnterpriseProjectId = &enterpriseProjectIdRequest
	checkNameRequest:= "<check_name>"
	request.CheckName = &checkNameRequest
	groupIdRequest:= "<group_id>"
	request.GroupId = &groupIdRequest
	severityRequest:= "<severity>"
	request.Severity = &severityRequest
	standardRequest:= "<standard>"
	request.Standard = &standardRequest
	hostIdRequest:= "<host_id>"
	request.HostId = &hostIdRequest
	limitRequest:= int32(<limit>)
	request.Limit = &limitRequest
	offsetRequest:= int32(<offset>)
	request.Offset = &offsetRequest
	response, err := client.ListRiskConfigs(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

Status Codes

Status Code

Description

200

server security configuration check result

Error Codes

See Error Codes.