Consulta del informe de un elemento de comprobación en una comprobación de configuración de seguridad
Función
Esta API se utiliza para consultar el informe de un elemento de comprobación en una comprobación de configuración de seguridad.
Método de invocación
Para obtener más información, consulte Invocación a las API.
URI
GET /v5/{project_id}/baseline/check-rule/detail
Parámetro |
Obligatorio |
Tipo |
Descripción |
---|---|---|---|
project_id |
Sí |
String |
ID de proyecto Mínimo: 20 Máximo: 64 |
Parámetro |
Obligatorio |
Tipo |
Descripción |
---|---|---|---|
enterprise_project_id |
No |
String |
ID del proyecto empresarial Mínimo: 0 Máximo: 64 |
check_name |
Sí |
String |
Nombre de línea base, por ejemplo, SSH, CentOS 7 y Windows. Mínimo: 0 Máximo: 255 |
check_type |
Sí |
String |
Tipo de línea base. Los valores de check_type y check_name son los mismos para los servidores Linux. Por ejemplo, ambos pueden configurarse como SSH o CentOS 7. Para los servidores Windows, los valores de check_type y check_name son diferentes. Por ejemplo, check_type se puede establecer en Windows Server 2019 R2 o Windows Server 2016 R2. Mínimo: 0 Máximo: 255 |
check_rule_id |
Sí |
String |
ID de elemento de verificación, que se puede obtener a partir de los datos devueltos de esta API: /v5/{project_id}/baseline/risk-config/{check_name}/check-rules Mínimo: 0 Máximo: 255 |
standard |
Sí |
String |
Tipo estándar. Su valor puede ser:
Mínimo: 0 Máximo: 32 |
host_id |
No |
String |
ID de host Mínimo: 0 Máximo: 64 |
Parámetros de solicitud
Parámetro |
Obligatorio |
Tipo |
Descripción |
---|---|---|---|
X-Auth-Token |
Sí |
String |
Token de usuario, que 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 el token de usuario. Mínimo: 32 Máximo: 2097152 |
Parámetros de respuesta
Código de estado: 200
Parámetro |
Tipo |
Descripción |
---|---|---|
description |
String |
Descripción del elemento de comprobación actual (regla de detección). Mínimo: 0 Máximo: 2048 |
reference |
String |
Base para la configuración del elemento de comprobación (regla) Mínimo: 0 Máximo: 255 |
audit |
String |
Descripción de auditoría del elemento de comprobación (regla) Mínimo: 0 Máximo: 65534 |
remediation |
String |
Sugerencias de modificación para el elemento de comprobación (regla) Mínimo: 0 Máximo: 65534 |
check_info_list |
Array of CheckRuleCheckCaseResponseInfo objects |
Casos de prueba Longitud de matriz: 0 - 2147483647 |
Solicitudes de ejemplo
Esta API se utiliza para consultar el informe de los elementos de comprobación de configuración cuyo nombre de línea base es SSH, el ID de elemento de comprobación es 1.12, el estándar de comprobación es el estándar de práctica de seguridad en la nube y el ID de proyecto empresarial es xxx.
GET https://{endpoint}/v5/{project_id}/baseline/check-rule/detail?standard=hw_standard&enterprise_project_id=xxx&check_name=SSH&check_type=SSH&check_rule_id=1.12
Ejemplo de respuestas
Código de estado: 200
Informe de comprobación de elementos de configuración
{ "audit" : "Run the following commands and verify that ClientAliveInterval is smaller than 300 and ClientAliveCountMax is 3 or less: \n#grep '^ClientAliveInterval' /etc/ssh/sshd_config\nClientAliveInterval 300(default is 0) \n#grep '^ClientAliveCountMax' /etc/ssh/sshd_config\nClientAliveCountMax 0(default is 3)", "description" : "The two options ClientAliveInterval and ClientAliveCountMax control the timeout of SSH sessions. The ClientAliveInterval parameter sets a timeout interval in seconds after which if no data has been received from the client, sshd will send a message through the encrypted channel to request a response from the client. The ClientAliveCountMax parameter sets the number of client alive messages which may be sent without sshd receiving any messages back from the client. For example, if the ClientAliveInterval is set to 15s and the ClientAliveCountMax is set to 3, unresponsive SSH clients will be disconnected after approximately 45s.", "reference" : "", "remediation" : "Edit the /etc/ssh/sshd_config file to set the parameter as follows: \nClientAliveInterval 300 \nClientAliveCountMax 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 |
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 ShowCheckRuleDetailSolution { 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(); ShowCheckRuleDetailRequest request = new ShowCheckRuleDetailRequest(); request.withEnterpriseProjectId("<enterprise_project_id>"); request.withCheckName("<check_name>"); request.withCheckType("<check_type>"); request.withCheckRuleId("<check_rule_id>"); request.withStandard("<standard>"); request.withHostId("<host_id>"); try { ShowCheckRuleDetailResponse response = client.showCheckRuleDetail(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 |
# 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 = ShowCheckRuleDetailRequest() request.enterprise_project_id = "<enterprise_project_id>" request.check_name = "<check_name>" request.check_type = "<check_type>" request.check_rule_id = "<check_rule_id>" request.standard = "<standard>" request.host_id = "<host_id>" response = client.show_check_rule_detail(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 |
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.ShowCheckRuleDetailRequest{} enterpriseProjectIdRequest:= "<enterprise_project_id>" request.EnterpriseProjectId = &enterpriseProjectIdRequest request.CheckName = "<check_name>" request.CheckType = "<check_type>" request.CheckRuleId = "<check_rule_id>" request.Standard = "<standard>" hostIdRequest:= "<host_id>" request.HostId = &hostIdRequest response, err := client.ShowCheckRuleDetail(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 |
Informe de comprobación de elementos de configuración |
Códigos de error
Consulte Códigos de error.