feat(saas) add vuls tags from env (#1487)

This commit is contained in:
sadayuki-matsuno
2022-07-04 12:00:02 +09:00
committed by GitHub
parent 999529a05b
commit 93731311a1

View File

@@ -47,6 +47,7 @@ func (w Writer) Write(rs ...models.ScanResult) error {
if len(rs) == 0 {
return nil
}
tags := strings.Split(os.Getenv("VULS_TAGS"), ",")
ipv4s, ipv6s, err := util.IP()
if err != nil {
@@ -111,6 +112,13 @@ func (w Writer) Write(rs ...models.ScanResult) error {
svc := s3.New(sess)
for _, r := range rs {
if 0 < len(tags) {
if r.Optional == nil {
r.Optional = map[string]interface{}{}
}
r.Optional["VULS_TAGS"] = tags
}
b, err := json.Marshal(r)
if err != nil {
return xerrors.Errorf("Failed to Marshal to JSON: %w", err)