Skip to content

Commit

Permalink
🐛 Safeguard accessing potential nil properties of an ec2 image in the…
Browse files Browse the repository at this point in the history
… AWS provider.

Signed-off-by: Preslav <preslav@mondoo.com>
  • Loading branch information
preslavgerchev committed Jun 11, 2024
1 parent 9aac022 commit a4e05c7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
22 changes: 14 additions & 8 deletions providers/aws/resources/aws_ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -1104,17 +1104,23 @@ func initAwsEc2Image(runtime *plugin.Runtime, args map[string]*llx.RawData) (map
args["architecture"] = llx.StringData(string(image.Architecture))
args["ownerId"] = llx.StringData(convert.ToString(image.OwnerId))
args["ownerAlias"] = llx.StringData(convert.ToString(image.ImageOwnerAlias))
createTime, err := time.Parse(time.RFC3339, *image.CreationDate)
if err == nil {
args["createdAt"] = llx.TimeData(createTime)
} else {
if image.CreationDate == nil {
args["createdAt"] = llx.NilData
}
deprecateTime, err := time.Parse(time.RFC3339, *image.DeprecationTime)
if err == nil {
args["deprecatedAt"] = llx.TimeData(deprecateTime)
} else {
createdAt, err := time.Parse(time.RFC3339, *image.CreationDate)
if err != nil {
return nil, nil, err
}
args["createdAt"] = llx.TimeData(createdAt)
}
if image.DeprecationTime == nil {
args["deprecatedAt"] = llx.NilData
} else {
deprecateTime, err := time.Parse(time.RFC3339, *image.DeprecationTime)
if err != nil {
return nil, nil, err
}
args["deprecatedAt"] = llx.TimeData(deprecateTime)
}
return args, nil, nil
}
Expand Down
2 changes: 0 additions & 2 deletions providers/vsphere/resources/resourceclient/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
If you have direct access to the host, press Alt+F1 to open the log in page on the machine's physical console.
Provide credentials when prompted. To return to the Direct Console User Interface press Alt-F2.

see https://kb.vmware.com/s/article/2004746

## VCSIM simulator

```bash
Expand Down

0 comments on commit a4e05c7

Please sign in to comment.