Help Center/ SecMaster/ API Reference/ API/ Baseline Inspection/ Search Baseline Check Results
Updated on 2024-12-13 GMT+08:00

Search Baseline Check Results

Function

This API is used to search baseline check results.

Calling Method

For details, see Calling APIs.

URI

POST /v2/{project_id}/workspaces/{workspace_id}/sa/baseline/search

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID.

workspace_id

Yes

String

Workspace ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

X-Language

Yes

String

Language. The values are zh-CN and en-US.

content-type

Yes

String

Content type.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

limit

No

Integer

Page size.

offset

No

Integer

Offset. The records after this offset will be queried.

sort_by

No

String

Sorting keyword.

order

No

String

Descending or ascending order, the value is DESC or ESC.

from_date

No

String

Start time. The format is ISO 8601: YYYY-MM-DDTHH:mm:ss.ms+Time zone. Time zone refers to where the incident occurred. If this parameter cannot be parsed, the default time zone GMT+8 is used.

to_date

No

String

End time. The format is ISO 8601: YYYY-MM-DDTHH:mm:ss.ms+Time zone. Time zone refers to where the incident occurred. If this parameter cannot be parsed, the default time zone GMT+8 is used.

condition

No

Object

Search condition expression.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

code

String

Error code

total

Integer

Total number of queried records.

size

Integer

Page size.

page

Integer

Offset.

success

Boolean

Successful or not.

data

Array of strings

List of searching result.

Status code: 400

Table 5 Response body parameters

Parameter

Type

Description

code

String

Error Code

message

String

Error Description

Status code: 401

Table 6 Response body parameters

Parameter

Type

Description

code

String

Error Code

message

String

Error Description

Status code: 500

Table 7 Response body parameters

Parameter

Type

Description

code

String

Error Code

message

String

Error Description

Example Requests

Query the request example of baseline check results. The time ranges from June 20, 2024 to June 27, 2024. The compliance package ID is 6add7d71-2261-4195-bab7-8ada0f0ed4d2. The directory ID is 0b78937f-4d9b-4223-9a46-2361e5090be0. The resource type is iam_user. The results are sorted in descending order of the update time. Each page contains 10 records.

{
  "limit" : 10,
  "offset" : 0,
  "sort_by" : "last_observed_time",
  "order" : "DESC",
  "from_date" : "2024-06-20T00:00:00.000Z",
  "to_date" : "2024-06-27T23:59:59.999Z",
  "condition" : {
    "conditions" : [ {
      "name" : "compliance_package_id",
      "data" : [ "compliance_package_id", "=", "6add7d71-2261-4195-bab7-8ada0f0ed4d2" ]
    }, {
      "name" : "catalog_id",
      "data" : [ "catalog_id", "=", "0b78937f-4d9b-4223-9a46-2361e5090be0" ]
    }, {
      "name" : "resource.type",
      "data" : [ "resource.type", "=", "iam_user" ]
    } ],
    "logics" : [ "compliance_package_id", "AND", "catalog_id", "AND", "resource.type" ]
  }
}

Example Responses

Status code: 200

Request successful.

{
  "code" : "00000000",
  "data" : [ {
    "create_time" : "2024-01-03T01:16:21.666+08:00",
    "data_object" : {
      "arrive_time" : "2024-01-03T11:28:03.993Z+0800",
      "baseline_type" : {
        "baseline_type" : "Compliance Check",
        "baseline_type_en" : "Compliance Check",
        "baseline_type_zh" : "Compliance Check",
        "category" : "",
        "category_en" : "",
        "category_zh" : "",
        "id" : "23f48a58cXXX162846076cd0"
      },
      "catalog_id" : "9378d1e8-XXX-4aae-XXX-c41cf6829ede",
      "checkitem_id" : "13fcc967-cb49-XXX-811a-9f72ce6ce8ac",
      "compliance_package_id" : "39488f96-XXX-4cc6-XXX-ad3c29b3a6c2",
      "create_time" : "2024-01-02T17:16:21.666Z+0800",
      "data_source" : {
        "company_name" : "XXX",
        "domain_id" : "ac7438b990efXXXb45e8bf4",
        "product_feature" : "SA",
        "product_module" : "Base-line",
        "product_name" : "SecMaster",
        "project_id" : "15645222e8XXX93dab6341da6",
        "region_id" : "cn-north-7",
        "source_type" : 1
      },
      "dataclass_id" : "f846c8e0-XXX-XXX-bcbf-f77190847f08",
      "domain_id" : "ac7438b990eXXX1004eb45e8bf4",
      "domain_name" : "ac7438b99XXX1004eb45e8bf4",
      "end_time" : "2024-01-03T11:28:51.564Z+0800",
      "execitem_id" : "ca2a1361-5738-479c-8c40-d078e775a23a",
      "execitem_version" : 1,
      "first_observed_time" : "2024-01-03T11:28:50.955Z+0800",
      "handle_status" : "qualified",
      "id" : "39c56d70a9c2492XXXd91934cb5cb_13fcc967-XXX-494b-XXX-9f72ce6ce8ac",
      "is_deleted" : false,
      "last_observed_time" : "2024-01-03T11:28:51.564Z+0800",
      "method" : 1,
      "origin_id" : "",
      "project_id" : "15645222e874XXX93dab6341da6",
      "region_id" : "cn-north-7",
      "region_name" : "cn-north-7",
      "resource" : {
        "domain_id" : "ac7438b990eXXX04eb45e8bf4",
        "id" : "39c56d70a9cXXX1934cb5cb",
        "name" : "adfasd",
        "project_id" : "15645222XXXc93dab6341da6",
        "provider" : "XXX",
        "region_id" : "cn-north-7",
        "type" : "agency"
      },
      "severity" : "informational",
      "start_time" : "2024-01-03T11:28:50.955Z+0800",
      "task_id" : "10da8403-XXX-442d-XXX-fa2fdf42a3a1",
      "title" : "Agency Permissions for Project Services",
      "trigger_flag" : false,
      "update_time" : "2024-01-03T11:28:51.887Z+0800",
      "workspace_id" : "1350a050-XXX-45e2-XXX-9cbfef116de7"
    },
    "dataclass_ref" : {
      "id" : "f846c8e0-XXX-3767-XXX-f77190847f08"
    },
    "format_version" : 0,
    "id" : "39c56d7XXX278fXXX934cb5cb_13fcc967-cb49-XXX-811a-9f72ce6ce8ac",
    "update_time" : "2024-01-03T19:28:51.887+08:00",
    "version" : 0
  }, {
    "create_time" : "2024-01-03T01:16:21.821+08:00",
    "data_object" : {
      "arrive_time" : "2024-01-03T11:28:03.993Z+0800",
      "baseline_type" : {
        "baseline_type" : "Compliance check",
        "baseline_type_en" : "Compliance Check",
        "baseline_type_zh" : "Compliance check",
        "category" : "",
        "category_en" : "",
        "category_zh" : "",
        "id" : "23f48a58c5b2fXXX162846076cd0"
      },
      "catalog_id" : "9378d1e8-XXX-4aae-XXX-c41cf6829ede",
      "checkitem_id" : "13fcc967-cb49-XXX-811a-9f72ce6ce8ac",
      "compliance_package_id" : "39488f96-XXX-4cc6-XXX-ad3c29b3a6c2",
      "create_time" : "2024-01-02T17:16:21.821Z+0800",
      "data_source" : {
        "company_name" : "XXX",
        "domain_id" : "ac7438b990efXXX004eb45e8bf4",
        "product_feature" : "SA",
        "product_module" : "Base-line",
        "product_name" : "SecMaster",
        "project_id" : "15645222XXX5c93dab6341da6",
        "region_id" : "cn-north-7",
        "source_type" : 1
      },
      "dataclass_id" : "f846c8e0-XXX-3767-bcbf-f77190847f08",
      "domain_id" : "ac7438b990eXXXb741004eb45e8bf4",
      "domain_name" : "ac7438bXXX37b741004eb45e8bf4",
      "end_time" : "2024-01-03T11:28:51.701Z+0800",
      "execitem_id" : "ca2a1361-XXX-479c-XXX-d078e775a23a",
      "execitem_version" : 1,
      "first_observed_time" : "2024-01-03T11:28:51.565Z+0800",
      "handle_status" : "qualified",
      "id" : "f295575ab57XXX977d9be93ca9fe_13fcc967-XXX-494b-XXX-9f72ce6ce8ac",
      "is_deleted" : false,
      "last_observed_time" : "2024-01-03T11:28:51.701Z+0800",
      "method" : 1,
      "origin_id" : "",
      "project_id" : "15645222e8XXXa985c93dab6341da6",
      "region_id" : "cn-north-7",
      "region_name" : "cn-north-7",
      "resource" : {
        "domain_id" : "ac7438b99XXX1004eb45e8bf4",
        "id" : "f295575ab57bXXXd9be93ca9fe",
        "name" : "apigw_admin_trust_secmaster",
        "project_id" : "15645222e8XXX93dab6341da6",
        "provider" : "XXX",
        "region_id" : "cn-north-7",
        "type" : "agency"
      },
      "severity" : "informational",
      "start_time" : "2024-01-03T11:28:51.565Z+0800",
      "task_id" : "10da8403-4955XXXd-a974-faXXX2a3a1",
      "title" : "Agency Permissions for Project Services",
      "trigger_flag" : false,
      "update_time" : "2024-01-03T11:28:52.023Z+0800",
      "workspace_id" : "1350a050-d09a-4XXX-9503-9cbfef116de7"
    },
    "dataclass_ref" : {
      "id" : "f846c8e0-cf0e-XXX-bcbf-XXX7f08"
    },
    "format_version" : 0,
    "id" : "f295575ab57b49XXXe93ca9fe_13fcc967-XXX-494b-XXX-9f72ce6ce8ac",
    "update_time" : "2024-01-03T19:28:52.023+08:00",
    "version" : 0
  } ],
  "page" : 0,
  "size" : 10,
  "success" : true,
  "total" : 2
}

Status code: 400

Request failed.

{
  "error_code" : "SecMaster.00040006",
  "error_msg" : "Invalid request parameters"
}

Status code: 401

Insufficient permissions.

{
  "error_code" : "SecMaster.90010015",
  "error_msg" : "Unauthorized request"
}

Status code: 500

Request failed.

{
  "error_code" : "SecMaster.00040011",
  "error_msg" : "Internal system error."
}

SDK Sample Code

The SDK sample code is as follows.

Query the request example of baseline check results. The time ranges from June 20, 2024 to June 27, 2024. The compliance package ID is 6add7d71-2261-4195-bab7-8ada0f0ed4d2. The directory ID is 0b78937f-4d9b-4223-9a46-2361e5090be0. The resource type is iam_user. The results are sorted in descending order of the update time. Each page contains 10 records.

 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
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.v2.region.SecMasterRegion;
import com.huaweicloud.sdk.secmaster.v2.*;
import com.huaweicloud.sdk.secmaster.v2.model.*;


public class SearchBaselineSolution {

    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();
        SearchBaselineRequest request = new SearchBaselineRequest();
        request.withWorkspaceId("{workspace_id}");
        BaselineSearchRequestBody body = new BaselineSearchRequestBody();
        body.withCondition("{\"logics\":[\"compliance_package_id\",\"AND\",\"catalog_id\",\"AND\",\"resource.type\"],\"conditions\":[{\"data\":[\"compliance_package_id\",\"=\",\"6add7d71-2261-4195-bab7-8ada0f0ed4d2\"],\"name\":\"compliance_package_id\"},{\"data\":[\"catalog_id\",\"=\",\"0b78937f-4d9b-4223-9a46-2361e5090be0\"],\"name\":\"catalog_id\"},{\"data\":[\"resource.type\",\"=\",\"iam_user\"],\"name\":\"resource.type\"}]}");
        body.withToDate("2024-06-27T23:59:59.999Z");
        body.withFromDate("2024-06-20T00:00:00.000Z");
        body.withOrder("DESC");
        body.withSortBy("last_observed_time");
        body.withOffset(0);
        body.withLimit(10);
        request.withBody(body);
        try {
            SearchBaselineResponse response = client.searchBaseline(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());
        }
    }
}

Query the request example of baseline check results. The time ranges from June 20, 2024 to June 27, 2024. The compliance package ID is 6add7d71-2261-4195-bab7-8ada0f0ed4d2. The directory ID is 0b78937f-4d9b-4223-9a46-2361e5090be0. The resource type is iam_user. The results are sorted in descending order of the update time. Each page contains 10 records.

 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
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdksecmaster.v2.region.secmaster_region import SecMasterRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdksecmaster.v2 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 = SearchBaselineRequest()
        request.workspace_id = "{workspace_id}"
        request.body = BaselineSearchRequestBody(
            condition="{\"logics\":[\"compliance_package_id\",\"AND\",\"catalog_id\",\"AND\",\"resource.type\"],\"conditions\":[{\"data\":[\"compliance_package_id\",\"=\",\"6add7d71-2261-4195-bab7-8ada0f0ed4d2\"],\"name\":\"compliance_package_id\"},{\"data\":[\"catalog_id\",\"=\",\"0b78937f-4d9b-4223-9a46-2361e5090be0\"],\"name\":\"catalog_id\"},{\"data\":[\"resource.type\",\"=\",\"iam_user\"],\"name\":\"resource.type\"}]}",
            to_date="2024-06-27T23:59:59.999Z",
            from_date="2024-06-20T00:00:00.000Z",
            order="DESC",
            sort_by="last_observed_time",
            offset=0,
            limit=10
        )
        response = client.search_baseline(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

Query the request example of baseline check results. The time ranges from June 20, 2024 to June 27, 2024. The compliance package ID is 6add7d71-2261-4195-bab7-8ada0f0ed4d2. The directory ID is 0b78937f-4d9b-4223-9a46-2361e5090be0. The resource type is iam_user. The results are sorted in descending order of the update time. Each page contains 10 records.

 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
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    secmaster "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v2"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v2/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v2/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 := secmaster.NewSecMasterClient(
        secmaster.SecMasterClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.SearchBaselineRequest{}
	request.WorkspaceId = "{workspace_id}"
	var conditionBaselineSearchRequestBody interface{} = "{\"logics\":[\"compliance_package_id\",\"AND\",\"catalog_id\",\"AND\",\"resource.type\"],\"conditions\":[{\"data\":[\"compliance_package_id\",\"=\",\"6add7d71-2261-4195-bab7-8ada0f0ed4d2\"],\"name\":\"compliance_package_id\"},{\"data\":[\"catalog_id\",\"=\",\"0b78937f-4d9b-4223-9a46-2361e5090be0\"],\"name\":\"catalog_id\"},{\"data\":[\"resource.type\",\"=\",\"iam_user\"],\"name\":\"resource.type\"}]}"
	toDateBaselineSearchRequestBody:= "2024-06-27T23:59:59.999Z"
	fromDateBaselineSearchRequestBody:= "2024-06-20T00:00:00.000Z"
	orderBaselineSearchRequestBody:= "DESC"
	sortByBaselineSearchRequestBody:= "last_observed_time"
	offsetBaselineSearchRequestBody:= int32(0)
	limitBaselineSearchRequestBody:= int32(10)
	request.Body = &model.BaselineSearchRequestBody{
		Condition: &conditionBaselineSearchRequestBody,
		ToDate: &toDateBaselineSearchRequestBody,
		FromDate: &fromDateBaselineSearchRequestBody,
		Order: &orderBaselineSearchRequestBody,
		SortBy: &sortByBaselineSearchRequestBody,
		Offset: &offsetBaselineSearchRequestBody,
		Limit: &limitBaselineSearchRequestBody,
	}
	response, err := client.SearchBaseline(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

Request successful.

400

Request failed.

401

Insufficient permissions.

500

Request failed.

Error Codes

See Error Codes.