Skip to content

Commit

Permalink
Add additional fields to ECR resource
Browse files Browse the repository at this point in the history
- lastRecordedPullTime
- pushedAt
- sizeInBytes

```
...

  lastRecordedPullTime: 2024-11-14 15:23:42.949 -0800 PST
  pushedAt: 2024-03-19 11:50:13 -0700 PDT
  sizeInBytes: 83520228

...
```

Signed-off-by: Tim Smith <tsmith84@gmail.com>
  • Loading branch information
tas50 committed Dec 1, 2024
1 parent cef7bda commit 8b28357
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 8 deletions.
6 changes: 6 additions & 0 deletions providers/aws/resources/aws.lr
Original file line number Diff line number Diff line change
Expand Up @@ -2497,6 +2497,12 @@ private aws.ecr.image @defaults("uri region") {
arn string
// uri for the image repository
uri string
// The time the image was pushed
pushedAt time
// The size of the image in bytes
sizeInBytes int
// The last time Amazon recorded an image pull. Note: Amazon only refreshes this data once every 24 hours so it is not fully granular.
lastRecordedPullTime time
}

// AWS Database Migration Service (DMS)
Expand Down
36 changes: 36 additions & 0 deletions providers/aws/resources/aws.lr.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions providers/aws/resources/aws.lr.manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1294,10 +1294,16 @@ resources:
fields:
arn: {}
digest: {}
lastRecordedPullTime:
min_mondoo_version: 9.0.0
mediaType: {}
pushedAt:
min_mondoo_version: 9.0.0
region: {}
registryId: {}
repoName: {}
sizeInBytes:
min_mondoo_version: 9.0.0
tags: {}
uri: {}
is_private: true
Expand Down
19 changes: 11 additions & 8 deletions providers/aws/resources/aws_ecr.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,17 @@ func (a *mqlAwsEcrRepository) images() ([]interface{}, error) {
}
mqlImage, err := CreateResource(a.MqlRuntime, "aws.ecr.image",
map[string]*llx.RawData{
"digest": llx.StringDataPtr(image.ImageDigest),
"mediaType": llx.StringDataPtr(image.ImageManifestMediaType),
"tags": llx.ArrayData(tags, types.String),
"registryId": llx.StringDataPtr(image.RegistryId),
"repoName": llx.StringData(name),
"region": llx.StringData(region),
"arn": llx.StringData(ecrImageArn(ImageInfo{Region: region, RegistryId: convert.ToString(image.RegistryId), RepoName: name, Digest: convert.ToString(image.ImageDigest)})),
"uri": llx.StringData(uri),
"arn": llx.StringData(ecrImageArn(ImageInfo{Region: region, RegistryId: convert.ToString(image.RegistryId), RepoName: name, Digest: convert.ToString(image.ImageDigest)})),
"digest": llx.StringDataPtr(image.ImageDigest),
"lastRecordedPullTime": llx.TimeDataPtr(image.LastRecordedPullTime),
"mediaType": llx.StringDataPtr(image.ImageManifestMediaType),
"pushedAt": llx.TimeDataPtr(image.ImagePushedAt),
"region": llx.StringData(region),
"registryId": llx.StringDataPtr(image.RegistryId),
"repoName": llx.StringData(name),
"sizeInBytes": llx.IntDataPtr(image.ImageSizeInBytes),
"tags": llx.ArrayData(tags, types.String),
"uri": llx.StringData(uri),
})
if err != nil {
return nil, err
Expand Down

0 comments on commit 8b28357

Please sign in to comment.