File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -517,6 +517,21 @@ func (v *VulnerabilityHost) GetMachineTags() (machineTags VulnerabilityHostMachi
517517 return
518518}
519519
520+ func (v * VulnerabilityHost ) GetMachineTagsRaw () (map [string ]interface {}, error ) {
521+ jsonTags , err := json .Marshal (v .MachineTags )
522+ if err != nil {
523+ return nil , err
524+ }
525+
526+ var rawTags map [string ]interface {}
527+
528+ if err := json .Unmarshal (jsonTags , & rawTags ); err != nil {
529+ return nil , err
530+ }
531+
532+ return rawTags , nil
533+ }
534+
520535type VulnerabilityHostMachineTags struct {
521536 Account string `json:"Account"`
522537 AmiID string `json:"AmiId"`
Original file line number Diff line number Diff line change @@ -437,6 +437,19 @@ func TestV2Vulnerabilities_Hosts_AllPages(t *testing.T) {
437437 }
438438}
439439
440+ func TestV2Vulnerabilities_HostGetAwsMachineTagsRaw (t * testing.T ) {
441+ var mockHostResponse api.VulnerabilitiesHostResponse
442+ err := json .Unmarshal ([]byte (mockVulnerabilitiesHostsResponseSetTags (vulnerabilityHostAwsMachineTags )), & mockHostResponse )
443+ assert .NoError (t , err )
444+
445+ tags , err := mockHostResponse .Data [0 ].GetMachineTagsRaw ()
446+ assert .NoError (t , err )
447+ assert .Equal (t , tags ["Account" ], "123456789038" )
448+ assert .Equal (t , tags ["AmiId" ], "ami-1234567890540c038" )
449+ assert .Equal (t , tags ["ExternalIp" ], "1.5.8.9" )
450+ assert .Equal (t , tags ["Hostname" ], "ip-192-168-28-69.us-east-2.compute.internal" )
451+ }
452+
440453func TestV2Vulnerabilities_HostGetAwsMachineTags (t * testing.T ) {
441454 var mockHostResponse api.VulnerabilitiesHostResponse
442455 err := json .Unmarshal ([]byte (mockVulnerabilitiesHostsResponseSetTags (vulnerabilityHostAwsMachineTags )), & mockHostResponse )
You can’t perform that action at this time.
0 commit comments