@@ -33,7 +33,8 @@ func tableAwsEcrImageScanFinding(_ context.Context) *plugin.Table {
33
33
// image_digest as it's more common/friendly to use.
34
34
KeyColumns : []* plugin.KeyColumn {
35
35
{Name : "repository_name" , Require : plugin .Required },
36
- {Name : "image_tag" , Require : plugin .Required },
36
+ {Name : "image_tag" , Require : plugin .AnyOf },
37
+ {Name : "image_digest" , Require : plugin .AnyOf },
37
38
},
38
39
},
39
40
GetMatrixItemFunc : SupportedRegionMatrix (ecrv1 .EndpointsID ),
@@ -125,8 +126,8 @@ func listAwsEcrImageScanFindings(ctx context.Context, d *plugin.QueryData, _ *pl
125
126
}
126
127
127
128
imageTag := d .EqualsQuals ["image_tag" ]
129
+ imageDigest := d .EqualsQuals ["image_digest" ]
128
130
repositoryName := d .EqualsQuals ["repository_name" ]
129
-
130
131
131
132
// Limiting the results
132
133
maxLimit := int32 (1000 )
@@ -140,11 +141,27 @@ func listAwsEcrImageScanFindings(ctx context.Context, d *plugin.QueryData, _ *pl
140
141
input := & ecr.DescribeImageScanFindingsInput {
141
142
MaxResults : aws .Int32 (maxLimit ),
142
143
RepositoryName : aws .String (repositoryName .GetStringValue ()),
143
- ImageId : & types.ImageIdentifier {
144
- ImageTag : aws .String (imageTag .GetStringValue ()),
145
- },
146
144
}
147
145
146
+ imageInfo := & types.ImageIdentifier {}
147
+
148
+ // Ideally, both image_tag and image_digest could be used.
149
+ // However, they cannot be passed together simultaneously.
150
+ // 1. If ImageTag is provided, it takes precedence and is used as the input parameter.
151
+ // 2. If both ImageTag and ImageDigest are provided, ImageTag will be prioritized to keep the existing table behavior unchanged.
152
+ // 3. If only ImageDigest is provided, the ImageDigest value will be used as the input parameter.
153
+ if imageTag != nil {
154
+ imageInfo .ImageTag = aws .String (imageTag .GetStringValue ())
155
+ }
156
+ if imageTag != nil && imageDigest != nil {
157
+ imageInfo .ImageTag = aws .String (imageTag .GetStringValue ())
158
+ }
159
+ if imageTag == nil && imageDigest != nil {
160
+ imageInfo .ImageDigest = aws .String (imageDigest .GetStringValue ())
161
+ }
162
+
163
+ input .ImageId = imageInfo
164
+
148
165
paginator := ecr .NewDescribeImageScanFindingsPaginator (svc , input , func (o * ecr.DescribeImageScanFindingsPaginatorOptions ) {
149
166
o .Limit = maxLimit
150
167
o .StopOnDuplicateToken = true
0 commit comments