Querying the Servers Affected by a Vulnerability
Function
This API is used to query the servers affected by a vulnerability.
Calling Method
For details, see Calling APIs.
URI
GET /v5/{project_id}/vulnerability/hosts
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Project ID Minimum: 1 Maximum: 256 |
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: 128 |
vul_id |
Yes |
String |
Vulnerability ID Minimum: 0 Maximum: 64 |
type |
Yes |
String |
Vulnerability type
Minimum: 0 Maximum: 64 |
host_name |
No |
String |
Affected server name Minimum: 0 Maximum: 256 |
host_ip |
No |
String |
IP address of the affected server Minimum: 0 Maximum: 128 |
status |
No |
String |
Vulnerability status.
Minimum: 0 Maximum: 128 |
limit |
No |
Integer |
Number of records on each page Minimum: 10 Maximum: 200 Default: 10 |
offset |
No |
Integer |
Offset, which specifies the start position of the record to be returned. The value must be a number no less than 0. The default value is 0. Minimum: 0 Maximum: 2000000 Default: 0 |
asset_value |
No |
String |
Asset importance important common test Minimum: 0 Maximum: 32 |
group_name |
No |
String |
Server group name Minimum: 0 Maximum: 256 |
handle_status |
No |
String |
description: |- Handling status. The options are as follows: - unhandled - handled Minimum: 1 Maximum: 32 |
severity_level |
No |
String |
Risk level. The value can be Critical, High, Medium, or Low. Minimum: 0 Maximum: 32 |
is_affect_business |
No |
Boolean |
Indicates whether services are affected. The value can be y or n. |
repair_priority |
No |
String |
Fixing priority. The options are as follows:
Minimum: 1 Maximum: 10 |
Request 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 a token. Minimum: 1 Maximum: 32768 |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
total_num |
Integer |
Number of affected servers Minimum: 0 Maximum: 10000 |
data_list |
Array of VulHostInfo objects |
List of affected ECSs Array Length: 1 - 10000 |
Parameter |
Type |
Description |
---|---|---|
host_id |
String |
ID of the server affected by the vulnerability Minimum: 1 Maximum: 128 |
severity_level |
String |
Risk level.
Minimum: 1 Maximum: 128 |
host_name |
String |
Affected server name Minimum: 1 Maximum: 256 |
host_ip |
String |
IP address of the affected server Minimum: 1 Maximum: 256 |
agent_id |
String |
Agent ID corresponding to the server Minimum: 1 Maximum: 128 |
version |
String |
The quota version bound to the server Minimum: 1 Maximum: 128 |
cve_num |
Integer |
Vulnerability CVEs Minimum: 0 Maximum: 10000 |
cve_id_list |
Array of strings |
The CVE ID list corresponding to the vulnerability Minimum: 1 Maximum: 64 Array Length: 1 - 10000 |
status |
String |
Vulnerability status.
Minimum: 1 Maximum: 128 |
repair_cmd |
String |
Command line to be executed to fix the vulnerability (This field is available only for Linux vulnerabilities.) Minimum: 1 Maximum: 256 |
app_path |
String |
Path of the application software (This field is available only for application vulnerabilities.) Minimum: 1 Maximum: 512 |
region_name |
String |
Region Minimum: 0 Maximum: 128 |
public_ip |
String |
Server public IP address Minimum: 0 Maximum: 128 |
private_ip |
String |
Server private IP address Minimum: 0 Maximum: 128 |
group_id |
String |
Server group ID Minimum: 0 Maximum: 128 |
group_name |
String |
Server group name Minimum: 0 Maximum: 256 |
os_type |
String |
Operating system (OS) Minimum: 0 Maximum: 32 |
asset_value |
String |
Asset importance. The options are as follows:
Minimum: 0 Maximum: 32 |
is_affect_business |
Boolean |
Whether services are affected |
first_scan_time |
Long |
First scan time Minimum: 0 Maximum: 9223372036854775807 |
scan_time |
Long |
Scanning time, in ms. Minimum: 0 Maximum: 9223372036854775807 |
support_restore |
Boolean |
Indicates whether data can be rolled back to the backup created when the vulnerability was fixed. |
disabled_operate_types |
Array of disabled_operate_types objects |
List of operation types of vulnerabilities that cannot be performed on the current server. Array Length: 1 - 10000 |
repair_priority |
String |
Fixing priority. The options are as follows:
Minimum: 1 Maximum: 10 |
Parameter |
Type |
Description |
---|---|---|
operate_type |
String |
Operation type.
Minimum: 1 Maximum: 64 |
reason |
String |
Indicates the reason why the operation cannot be performed. Minimum: 0 Maximum: 512 |
Example Requests
Query the first 10 records in the list of servers with EulerOS-SA-2021-1894 vulnerability.
GET https://{endpoint}/v5/2b31ed520xxxxxxebedb6e57xxxxxxxx/vulnerability/hosts?vul_id=EulerOS-SA-2021-1894&offset=0&limit=10
Example Responses
Status code: 200
Vul host info list
{ "total_num" : 1, "data_list" : [ { "host_id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "severity_level" : "Low", "host_name" : "ecs", "host_ip" : "xxx.xxx.xxx.xxx", "agent_id" : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "version" : "hss.version.enterprise", "cve_num" : 1, "cve_id_list" : [ "CVE-2022-1664" ], "status" : "vul_status_ignored", "repair_cmd" : "zypper update update-alternatives", "app_path" : "/root/apache-tomcat-8.5.15/bin/bootstrap.jar", "support_restore" : true, "disabled_operate_types" : [ { "operate_type" : "immediate_repair", "reason" : "The kernel vulnerability of CCE container node cannot be automatically fixed." } ], "repair_priority" : "Critical" } ] }
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 54 55 56 57 58 59 |
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 ListVulHostsSolution { 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(); ListVulHostsRequest request = new ListVulHostsRequest(); request.withEnterpriseProjectId("<enterprise_project_id>"); request.withVulId("<vul_id>"); request.withType("<type>"); request.withHostName("<host_name>"); request.withHostIp("<host_ip>"); request.withStatus("<status>"); request.withLimit(<limit>); request.withOffset(<offset>); request.withAssetValue("<asset_value>"); request.withGroupName("<group_name>"); request.withHandleStatus("<handle_status>"); request.withSeverityLevel("<severity_level>"); request.withIsAffectBusiness(<is_affect_business>); request.withRepairPriority("<repair_priority>"); try { ListVulHostsResponse response = client.listVulHosts(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 39 40 41 42 43 |
# 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 = ListVulHostsRequest() request.enterprise_project_id = "<enterprise_project_id>" request.vul_id = "<vul_id>" request.type = "<type>" request.host_name = "<host_name>" request.host_ip = "<host_ip>" request.status = "<status>" request.limit = <limit> request.offset = <offset> request.asset_value = "<asset_value>" request.group_name = "<group_name>" request.handle_status = "<handle_status>" request.severity_level = "<severity_level>" request.is_affect_business = <IsAffectBusiness> request.repair_priority = "<repair_priority>" response = client.list_vul_hosts(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 52 53 54 55 56 57 58 59 60 61 |
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.ListVulHostsRequest{} enterpriseProjectIdRequest:= "<enterprise_project_id>" request.EnterpriseProjectId = &enterpriseProjectIdRequest request.VulId = "<vul_id>" request.Type = "<type>" hostNameRequest:= "<host_name>" request.HostName = &hostNameRequest hostIpRequest:= "<host_ip>" request.HostIp = &hostIpRequest statusRequest:= "<status>" request.Status = &statusRequest limitRequest:= int32(<limit>) request.Limit = &limitRequest offsetRequest:= int32(<offset>) request.Offset = &offsetRequest assetValueRequest:= "<asset_value>" request.AssetValue = &assetValueRequest groupNameRequest:= "<group_name>" request.GroupName = &groupNameRequest handleStatusRequest:= "<handle_status>" request.HandleStatus = &handleStatusRequest severityLevelRequest:= "<severity_level>" request.SeverityLevel = &severityLevelRequest isAffectBusinessRequest:= <is_affect_business> request.IsAffectBusiness = &isAffectBusinessRequest repairPriorityRequest:= "<repair_priority>" request.RepairPriority = &repairPriorityRequest response, err := client.ListVulHosts(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 |
Vul host info list |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot