安全云脑 SECMASTER-告警转事件:Go

时间:2023-12-06 18:52:41

Go

将一条告警转为事件,告警ID为909494e3-558e-46b6-a9eb-07a8e18ca62f,事件ID为909494e3-558e-46b6-a9eb-07a8e18ca621,告警状态为已关闭,是否标记为证据为否。

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

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

    client := secmaster.NewSecMasterClient(
        secmaster.SecMasterClientBuilder().
            WithRegion(region.ValueOf("cn-north-4")).
            WithCredential(auth).
            Build())

    request := &model.CreateBatchOrderAlertsRequest{}
	idIncidentType:= "909494e3-558e-46b6-a9eb-07a8e18ca62f"
	categoryIncidentType:= "DDoS攻击"
	incidentTypeIncidentType:= "DNS协议攻击"
	incidentTypeIncidentContent := &model.OrderAlertIncidentContentIncidentType{
		Id: &idIncidentType,
		Category: &categoryIncidentType,
		IncidentType: &incidentTypeIncidentType,
	}
	titleIncidentContent:= "XXX"
	incidentContentbody := &model.OrderAlertIncidentContent{
		Title: &titleIncidentContent,
		IncidentType: incidentTypeIncidentContent,
	}
	var listIdsbody = []string{
        "909494e3-558e-46b6-a9eb-07a8e18ca62f",
    }
	request.Body = &model.OrderAlert{
		IncidentContent: incidentContentbody,
		Ids: &listIdsbody,
	}
	response, err := client.CreateBatchOrderAlerts(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}
support.huaweicloud.com/api-secmaster/CreateBatchOrderAlerts.html