Skip to content

Commit

Permalink
Add new aws.elb properties + fix createdTime consistency (#2067)
Browse files Browse the repository at this point in the history
* Add new aws.elb properties

- createdTime
- vpcID

Signed-off-by: Tim Smith <[email protected]>

* Be more consistent with create times

None of these properties have been released yet so this is our chance to
fix this

Signed-off-by: Tim Smith <[email protected]>

* Drop toTime, use TimDataPtr in AWS resources.

* Fix loadBalancers retrieval.

---------

Signed-off-by: Tim Smith <[email protected]>
Co-authored-by: Preslav <[email protected]>
  • Loading branch information
tas50 and preslavgerchev authored Oct 4, 2023
1 parent f0cccfe commit f2d8b29
Show file tree
Hide file tree
Showing 17 changed files with 95 additions and 66 deletions.
1 change: 1 addition & 0 deletions .github/actions/spelling/patterns.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,4 @@ uid:\s.*$
aws_session_token\s+\=(\s+)?.+
aws_access_key_id\s+\=(\s+)?.+
aws_secret_access_key\s+\=(\s+)?.+

8 changes: 6 additions & 2 deletions providers/aws/resources/aws.lr
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,10 @@ private aws.elb.loadbalancer @defaults("arn name") {
scheme string
// A list of attributes for the load balancer
attributes() []dict
// The ID of the VPC where the load balancer is located
vpcId string
// Date and time when the load balancer was created
createdTime time
}

// AWS CodeBuild for building and testing code
Expand Down Expand Up @@ -996,7 +1000,7 @@ private aws.s3.bucket @defaults("arn") {
// False if the bucket no longer exists (stale reference)
exists bool
// Date the bucket was created
creationDate time
createdTime time
}

// Amazon S3 Bucket Grant
Expand Down Expand Up @@ -1258,7 +1262,7 @@ private aws.rds.dbinstance @defaults("id region engine engineVersion") {
// Indicates whether minor version patches are applied automatically
autoMinorVersionUpgrade bool
// The creation date of the RDS instance
creationDate time
createdTime time
}

// Amazon ElastiCache
Expand Down
52 changes: 38 additions & 14 deletions providers/aws/resources/aws.lr.go

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

8 changes: 6 additions & 2 deletions providers/aws/resources/aws.lr.manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1375,10 +1375,14 @@ resources:
fields:
arn: {}
attributes: {}
createdTime:
min_mondoo_version: 9.0.0
dnsName: {}
listenerDescriptions: {}
name: {}
scheme: {}
vpcId:
min_mondoo_version: 9.0.0
is_private: true
min_mondoo_version: 5.15.0
platform:
Expand Down Expand Up @@ -1805,7 +1809,7 @@ resources:
availabilityZone:
min_mondoo_version: 9.0.0
backupRetentionPeriod: {}
creationDate:
createdTime:
min_mondoo_version: 9.0.0
dbInstanceClass:
min_mondoo_version: 5.19.1
Expand Down Expand Up @@ -1973,7 +1977,7 @@ resources:
acl: {}
arn: {}
cors: {}
creationDate:
createdTime:
min_mondoo_version: 9.0.0
defaultLock: {}
encryption: {}
Expand Down
6 changes: 3 additions & 3 deletions providers/aws/resources/aws_acm.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ func initAwsAcmCertificate(runtime *plugin.Runtime, args map[string]*llx.RawData
}

args["arn"] = llx.StringData(arnVal)
args["notBefore"] = llx.TimeData(toTime(certDetails.Certificate.NotBefore))
args["notAfter"] = llx.TimeData(toTime(certDetails.Certificate.NotAfter))
args["createdAt"] = llx.TimeData(toTime(certDetails.Certificate.CreatedAt))
args["notBefore"] = llx.TimeDataPtr(certDetails.Certificate.NotBefore)
args["notAfter"] = llx.TimeDataPtr(certDetails.Certificate.NotAfter)
args["createdAt"] = llx.TimeDataPtr(certDetails.Certificate.CreatedAt)
args["domainName"] = llx.StringData(convert.ToString(certDetails.Certificate.DomainName))
args["status"] = llx.StringData(string(certDetails.Certificate.Status))
args["subject"] = llx.StringData(convert.ToString(certDetails.Certificate.Subject))
Expand Down
2 changes: 1 addition & 1 deletion providers/aws/resources/aws_apigateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (a *mqlAwsApigateway) getRestApis(conn *connection.AwsConnection) []*jobpoo
"id": llx.StringData(convert.ToString(restApi.Id)),
"name": llx.StringData(convert.ToString(restApi.Name)),
"description": llx.StringData(convert.ToString(restApi.Description)),
"createdDate": llx.TimeData(toTime(restApi.CreatedDate)),
"createdDate": llx.TimeDataPtr(restApi.CreatedDate),
"region": llx.StringData(regionVal),
"tags": llx.MapData(strMapToInterface(restApi.Tags), types.String),
})
Expand Down
4 changes: 2 additions & 2 deletions providers/aws/resources/aws_backups.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ func (a *mqlAwsBackupVault) recoveryPoints() ([]interface{}, error) {
"createdBy": llx.MapData(createdBy, types.String),
"iamRoleArn": llx.StringData(convert.ToString(rp.IamRoleArn)),
"status": llx.StringData(string(rp.Status)),
"creationDate": llx.TimeData(toTime(rp.CreationDate)),
"completionDate": llx.TimeData(toTime(rp.CompletionDate)),
"creationDate": llx.TimeDataPtr(rp.CreationDate),
"completionDate": llx.TimeDataPtr(rp.CompletionDate),
"encryptionKeyArn": llx.StringData(convert.ToString(rp.EncryptionKeyArn)),
"isEncrypted": llx.BoolData(convert.ToBool(&rp.IsEncrypted)),
})
Expand Down
4 changes: 2 additions & 2 deletions providers/aws/resources/aws_cloudfront.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ func (a *mqlAwsCloudfront) functions() ([]interface{}, error) {
args := map[string]*llx.RawData{
"name": llx.StringData(convert.ToString(funct.Name)),
"status": llx.StringData(convert.ToString(funct.Status)),
"lastModifiedTime": llx.TimeData(toTime(lmTime)),
"createdTime": llx.TimeData(toTime(crTime)),
"lastModifiedTime": llx.TimeDataPtr(lmTime),
"createdTime": llx.TimeDataPtr(crTime),
"stage": llx.StringData(stage),
"comment": llx.StringData(comment),
"runtime": llx.StringData(runtime),
Expand Down
4 changes: 2 additions & 2 deletions providers/aws/resources/aws_cloudwatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ func initAwsCloudwatchMetricstatistics(runtime *plugin.Runtime, args map[string]
for _, datapoint := range statsResp.Datapoints {
mqlDatapoint, err := CreateResource(runtime, "aws.cloudwatch.metric.datapoint",
map[string]*llx.RawData{
"timestamp": llx.TimeData(toTime(datapoint.Timestamp)),
"timestamp": llx.TimeDataPtr(datapoint.Timestamp),
"maximum": llx.FloatData(convert.ToFloat64(datapoint.Maximum)),
"minimum": llx.FloatData(convert.ToFloat64(datapoint.Minimum)),
"average": llx.FloatData(convert.ToFloat64(datapoint.Average)),
Expand Down Expand Up @@ -369,7 +369,7 @@ func (a *mqlAwsCloudwatchMetric) statistics() (*mqlAwsCloudwatchMetricstatistics
mqlDatapoint, err := CreateResource(a.MqlRuntime, "aws.cloudwatch.metric.datapoint",
map[string]*llx.RawData{
"id": llx.StringData(formatDatapointId(datapoint)),
"timestamp": llx.TimeData(toTime(datapoint.Timestamp)),
"timestamp": llx.TimeDataPtr(datapoint.Timestamp),
"maximum": llx.FloatData(convert.ToFloat64(datapoint.Maximum)),
"minimum": llx.FloatData(convert.ToFloat64(datapoint.Minimum)),
"average": llx.FloatData(convert.ToFloat64(datapoint.Average)),
Expand Down
6 changes: 3 additions & 3 deletions providers/aws/resources/aws_ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ func (a *mqlAwsEc2) gatherInstanceInfo(instances []ec2types.Reservation, imdsvVe
"ebsOptimized": llx.BoolData(convert.ToBool(instance.EbsOptimized)),
"instanceType": llx.StringData(string(instance.InstanceType)),
"tags": llx.MapData(Ec2TagsToMap(instance.Tags), types.String),
"launchTime": llx.TimeData(toTime(instance.LaunchTime)),
"launchTime": llx.TimeDataPtr(instance.LaunchTime),
"privateIp": llx.StringData(convert.ToString(instance.PrivateIpAddress)),
"privateDnsName": llx.StringData(convert.ToString(instance.PrivateDnsName)),
"stateTransitionTime": llx.TimeData(stateTransitionTime),
Expand Down Expand Up @@ -1039,7 +1039,7 @@ func (a *mqlAwsEc2) getVolumes(conn *connection.AwsConnection) []*jobpool.Job {
"tags": llx.MapData(Ec2TagsToMap(vol.Tags), types.String),
"availabilityZone": llx.StringData(convert.ToString(vol.AvailabilityZone)),
"volumeType": llx.StringData(string(vol.VolumeType)),
"createTime": llx.TimeData(toTime(vol.CreateTime)),
"createTime": llx.TimeDataPtr(vol.CreateTime),
"region": llx.StringData(regionVal),
})
if err != nil {
Expand Down Expand Up @@ -1324,7 +1324,7 @@ func (a *mqlAwsEc2) getSnapshots(conn *connection.AwsConnection) []*jobpool.Job
"id": llx.StringData(convert.ToString(snapshot.SnapshotId)),
"region": llx.StringData(regionVal),
"volumeId": llx.StringData(convert.ToString(snapshot.VolumeId)),
"startTime": llx.TimeData(toTime(snapshot.StartTime)),
"startTime": llx.TimeDataPtr(snapshot.StartTime),
"tags": llx.MapData(Ec2TagsToMap(snapshot.Tags), types.String),
"state": llx.StringData(string(snapshot.State)),
})
Expand Down
2 changes: 1 addition & 1 deletion providers/aws/resources/aws_eks.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (a *mqlAwsEks) getClusters(conn *connection.AwsConnection) []*jobpool.Job {
"tags": llx.MapData(strMapToInterface(cluster.Tags), types.String),
"status": llx.StringData(string(cluster.Status)),
"encryptionConfig": llx.ArrayData(encryptionConfig, types.Any),
"createdAt": llx.TimeData(toTime(cluster.CreatedAt)),
"createdAt": llx.TimeDataPtr(cluster.CreatedAt),
"endpoint": llx.StringData(convert.ToString(cluster.Endpoint)),
"logging": llx.MapData(logging, types.Any),
"networkConfig": llx.MapData(kubernetesNetworkConfig, types.Any),
Expand Down
4 changes: 2 additions & 2 deletions providers/aws/resources/aws_elasticache.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ func (a *mqlAwsElasticache) getCacheClusters(conn *connection.AwsConnection) []*
"arn": llx.StringData(convert.ToString(cluster.ARN)),
"atRestEncryptionEnabled": llx.BoolData(convert.ToBool(cluster.AtRestEncryptionEnabled)),
"authTokenEnabled": llx.BoolData(convert.ToBool(cluster.AuthTokenEnabled)),
"authTokenLastModifiedDate": llx.TimeData(toTime(cluster.AuthTokenLastModifiedDate)),
"authTokenLastModifiedDate": llx.TimeDataPtr(cluster.AuthTokenLastModifiedDate),
"autoMinorVersionUpgrade": llx.BoolData(cluster.AutoMinorVersionUpgrade),
"cacheClusterCreateTime": llx.TimeData(toTime(cluster.CacheClusterCreateTime)),
"cacheClusterCreateTime": llx.TimeDataPtr(cluster.CacheClusterCreateTime),
"cacheClusterId": llx.StringData(convert.ToString(cluster.CacheClusterId)),
"cacheClusterStatus": llx.StringData(convert.ToString(cluster.CacheClusterStatus)),
"cacheNodeType": llx.StringData(convert.ToString(cluster.CacheNodeType)),
Expand Down
18 changes: 11 additions & 7 deletions providers/aws/resources/aws_elb.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ func (a *mqlAwsElb) getClassicLoadBalancers(conn *connection.AwsConnection) []*j
map[string]*llx.RawData{
"arn": llx.StringData(fmt.Sprintf(elbv1LbArnPattern, regionVal, conn.AccountId(), convert.ToString(lb.LoadBalancerName))),
"listenerDescriptions": llx.AnyData(jsonListeners),
"dnsName": llx.StringData(convert.ToString(lb.DNSName)),
"name": llx.StringData(convert.ToString(lb.LoadBalancerName)),
"scheme": llx.StringData(convert.ToString(lb.Scheme)),
"dnsName": llx.StringDataPtr(lb.DNSName),
"name": llx.StringDataPtr(lb.LoadBalancerName),
"scheme": llx.StringDataPtr(lb.Scheme),
"vpcId": llx.StringDataPtr(lb.VPCId),
"createdTime": llx.TimeDataPtr(lb.CreatedTime),
})
if err != nil {
return nil, err
Expand Down Expand Up @@ -144,10 +146,12 @@ func (a *mqlAwsElb) getLoadBalancers(conn *connection.AwsConnection) []*jobpool.
for _, lb := range lbs.LoadBalancers {
mqlLb, err := CreateResource(a.MqlRuntime, "aws.elb.loadbalancer",
map[string]*llx.RawData{
"arn": llx.StringData(convert.ToString(lb.LoadBalancerArn)),
"dnsName": llx.StringData(convert.ToString(lb.DNSName)),
"name": llx.StringData(convert.ToString(lb.LoadBalancerName)),
"scheme": llx.StringData(string(lb.Scheme)),
"arn": llx.StringData(convert.ToString(lb.LoadBalancerArn)),
"dnsName": llx.StringData(convert.ToString(lb.DNSName)),
"name": llx.StringData(convert.ToString(lb.LoadBalancerName)),
"scheme": llx.StringData(string(lb.Scheme)),
"vpcId": llx.StringDataPtr(lb.VpcId),
"createdTime": llx.TimeDataPtr(lb.CreatedTime),
})
if err != nil {
return nil, err
Expand Down
Loading

0 comments on commit f2d8b29

Please sign in to comment.