Skip to content

Commit

Permalink
Add createdAt to aws.ec2.keypair + cleanup ptrs (#2861)
Browse files Browse the repository at this point in the history
- Add createdAt to aws.ec2.keypair
- Improve defaults in aws.ec2.keypair
- Cleanup some incorrect min mondoo version fields
- Use StringDataPtr where we can

Signed-off-by: Tim Smith <[email protected]>
  • Loading branch information
tas50 authored Dec 18, 2023
1 parent d0749b0 commit a4759d2
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 35 deletions.
4 changes: 3 additions & 1 deletion providers/aws/resources/aws.lr
Original file line number Diff line number Diff line change
Expand Up @@ -2388,7 +2388,7 @@ private aws.ec2.instance @defaults("instanceId region state instanceType archite
}

// Amazon EC2 key pair
private aws.ec2.keypair @defaults("arn name") {
private aws.ec2.keypair @defaults("name type region") {
// ARN of the key pair
arn string
// Fingerprint for the key pair
Expand All @@ -2401,6 +2401,8 @@ private aws.ec2.keypair @defaults("arn name") {
tags map[string]string
// Region where the key pair exists
region string
// Date the keypair was created
createdAt time
}

// Amazon EC2 image (AMI)
Expand Down
12 changes: 12 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.

22 changes: 8 additions & 14 deletions providers/aws/resources/aws.lr.manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,7 @@ resources:
aws.ec2.keypair:
fields:
arn: {}
createdAt: {}
fingerprint: {}
name: {}
region: {}
Expand Down Expand Up @@ -2386,16 +2387,13 @@ resources:
- aws
aws.vpc.endpoint:
fields:
createdAt:
min_mondoo_version: 9.0.0
createdAt: {}
id: {}
policyDocument: {}
privateDnsEnabled:
min_mondoo_version: 9.0.0
privateDnsEnabled: {}
region: {}
serviceName: {}
state:
min_mondoo_version: 9.0.0
state: {}
subnets: {}
type: {}
vpc: {}
Expand Down Expand Up @@ -2438,17 +2436,13 @@ resources:
aws.vpc.subnet:
fields:
arn: {}
assignIpv6AddressOnCreation:
min_mondoo_version: 9.0.0
availabilityZone:
min_mondoo_version: latest
assignIpv6AddressOnCreation: {}
availabilityZone: {}
cidrs: {}
defaultForAvailabilityZone:
min_mondoo_version: latest
defaultForAvailabilityZone: {}
id: {}
mapPublicIpOnLaunch: {}
state:
min_mondoo_version: 9.0.0
state: {}
is_private: true
min_mondoo_version: 9.0.0
platform:
Expand Down
3 changes: 1 addition & 2 deletions providers/aws/resources/aws_acm.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/rs/zerolog/log"
"go.mondoo.com/cnquery/v9/llx"
"go.mondoo.com/cnquery/v9/providers-sdk/v1/plugin"
"go.mondoo.com/cnquery/v9/providers-sdk/v1/util/convert"
"go.mondoo.com/cnquery/v9/providers-sdk/v1/util/jobpool"
"go.mondoo.com/cnquery/v9/providers/aws/connection"

Expand Down Expand Up @@ -70,7 +69,7 @@ func (a *mqlAwsAcm) getCertificates(conn *connection.AwsConnection) []*jobpool.J
}
for _, cert := range certs.CertificateSummaryList {
mqlCert, err := NewResource(a.MqlRuntime, "aws.acm.certificate", map[string]*llx.RawData{
"arn": llx.StringData(convert.ToString(cert.CertificateArn)),
"arn": llx.StringDataPtr(cert.CertificateArn),
})
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion providers/aws/resources/aws_dynamodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func (a *mqlAwsDynamodb) globalTables() ([]interface{}, error) {
mqlTable, err := CreateResource(a.MqlRuntime, "aws.dynamodb.globaltable",
map[string]*llx.RawData{
"arn": llx.StringData(fmt.Sprintf(dynamoGlobalTableArnPattern, conn.AccountId(), convert.ToString(table.GlobalTableName))),
"name": llx.StringData(convert.ToString(table.GlobalTableName)),
"name": llx.StringDataPtr(table.GlobalTableName),
})
if err != nil {
return nil, err
Expand Down
5 changes: 3 additions & 2 deletions providers/aws/resources/aws_ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,11 +407,12 @@ func (a *mqlAwsEc2) getKeypairs(conn *connection.AwsConnection) []*jobpool.Job {
mqlKeypair, err := CreateResource(a.MqlRuntime, "aws.ec2.keypair",
map[string]*llx.RawData{
"arn": llx.StringData(fmt.Sprintf(keypairArnPattern, conn.AccountId(), regionVal, convert.ToString(kp.KeyPairId))),
"fingerprint": llx.StringData(convert.ToString(kp.KeyFingerprint)),
"name": llx.StringData(convert.ToString(kp.KeyName)),
"fingerprint": llx.StringDataPtr(kp.KeyFingerprint),
"name": llx.StringDataPtr(kp.KeyName),
"type": llx.StringData(string(kp.KeyType)),
"tags": llx.MapData(Ec2TagsToMap(kp.Tags), types.String),
"region": llx.StringData(regionVal),
"createdAt": llx.TimeDataPtr(kp.CreateTime),
})
if err != nil {
return nil, err
Expand Down
28 changes: 14 additions & 14 deletions providers/aws/resources/aws_ecr.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ func (a *mqlAwsEcr) getPrivateRepositories(conn *connection.AwsConnection) []*jo
}
mqlRepoResource, err := CreateResource(a.MqlRuntime, "aws.ecr.repository",
map[string]*llx.RawData{
"arn": llx.StringData(convert.ToString(r.RepositoryArn)),
"name": llx.StringData(convert.ToString(r.RepositoryName)),
"uri": llx.StringData(convert.ToString(r.RepositoryUri)),
"registryId": llx.StringData(convert.ToString(r.RegistryId)),
"arn": llx.StringDataPtr(r.RepositoryArn),
"name": llx.StringDataPtr(r.RepositoryName),
"uri": llx.StringDataPtr(r.RepositoryUri),
"registryId": llx.StringDataPtr(r.RegistryId),
"public": llx.BoolData(false),
"region": llx.StringData(region),
"imageScanOnPush": llx.BoolData(imageScanOnPush),
Expand Down Expand Up @@ -167,10 +167,10 @@ func (a *mqlAwsEcrRepository) images() ([]interface{}, error) {
}
mqlImage, err := CreateResource(a.MqlRuntime, "aws.ecr.image",
map[string]*llx.RawData{
"digest": llx.StringData(convert.ToString(image.ImageDigest)),
"mediaType": llx.StringData(convert.ToString(image.ImageManifestMediaType)),
"digest": llx.StringDataPtr(image.ImageDigest),
"mediaType": llx.StringDataPtr(image.ImageManifestMediaType),
"tags": llx.ArrayData(tags, types.String),
"registryId": llx.StringData(convert.ToString(image.RegistryId)),
"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)})),
Expand Down Expand Up @@ -199,10 +199,10 @@ func (a *mqlAwsEcrRepository) images() ([]interface{}, error) {
}
mqlImage, err := CreateResource(a.MqlRuntime, "aws.ecr.image",
map[string]*llx.RawData{
"digest": llx.StringData(convert.ToString(image.ImageDigest)),
"mediaType": llx.StringData(convert.ToString(image.ImageManifestMediaType)),
"digest": llx.StringDataPtr(image.ImageDigest),
"mediaType": llx.StringDataPtr(image.ImageManifestMediaType),
"tags": llx.ArrayData(tags, types.String),
"registryId": llx.StringData(convert.ToString(image.RegistryId)),
"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)})),
Expand Down Expand Up @@ -283,10 +283,10 @@ func (a *mqlAwsEcr) publicRepositories() ([]interface{}, error) {

mqlRepoResource, err := CreateResource(a.MqlRuntime, "aws.ecr.repository",
map[string]*llx.RawData{
"arn": llx.StringData(convert.ToString(r.RepositoryArn)),
"name": llx.StringData(convert.ToString(r.RepositoryName)),
"uri": llx.StringData(convert.ToString(r.RepositoryUri)),
"registryId": llx.StringData(convert.ToString(r.RegistryId)),
"arn": llx.StringDataPtr(r.RepositoryArn),
"name": llx.StringDataPtr(r.RepositoryName),
"uri": llx.StringDataPtr(r.RepositoryUri),
"registryId": llx.StringDataPtr(r.RegistryId),
"public": llx.BoolData(true),
"region": llx.StringData("us-east-1"),
"imageScanOnPush": llx.BoolData(false),
Expand Down
2 changes: 1 addition & 1 deletion providers/aws/resources/aws_s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (a *mqlAwsS3) buckets() ([]interface{}, error) {
}
mqlS3Bucket, err := CreateResource(a.MqlRuntime, "aws.s3.bucket",
map[string]*llx.RawData{
"name": llx.StringData(convert.ToString(bucket.Name)),
"name": llx.StringDataPtr(bucket.Name),
"arn": llx.StringData(fmt.Sprintf(s3ArnPattern, convert.ToString(bucket.Name))),
"exists": llx.BoolData(true),
"location": llx.StringData(region),
Expand Down

0 comments on commit a4759d2

Please sign in to comment.