Skip to content

Commit

Permalink
⭐ Basic asset url for aws (#3724)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaym authored Apr 8, 2024
1 parent 7aa7857 commit 74b1bb0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
17 changes: 17 additions & 0 deletions providers/aws/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package config

import (
"go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory"
"go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin"
"go.mondoo.com/cnquery/v10/providers/aws/connection/awsec2ebsconn"
"go.mondoo.com/cnquery/v10/providers/aws/provider"
Expand Down Expand Up @@ -102,4 +103,20 @@ var Config = plugin.Provider{
},
},
},
AssetUrlTrees: []*inventory.AssetUrlBranch{
{
PathSegments: []string{"technology=aws"},
Key: "account",
Title: "Account",
Values: map[string]*inventory.AssetUrlBranch{
"*": {
Key: "service",
Title: "Service",
Values: map[string]*inventory.AssetUrlBranch{
"account": nil,
},
},
},
},
},
}
22 changes: 12 additions & 10 deletions providers/aws/connection/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,25 @@ package connection
import "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory"

func (a *AwsConnection) PlatformInfo() *inventory.Platform {
return GetPlatformForObject(a.PlatformOverride)
return GetPlatformForObject(a.PlatformOverride, a.accountId)
}

func GetPlatformForObject(platformName string) *inventory.Platform {
func GetPlatformForObject(platformName string, accountId string) *inventory.Platform {
if platformName != "aws" && platformName != "" {
return &inventory.Platform{
Name: platformName,
Title: getTitleForPlatformName(platformName),
Kind: "aws-object",
Runtime: "aws",
Name: platformName,
Title: getTitleForPlatformName(platformName),
Kind: "aws-object",
Runtime: "aws",
TechnologyUrlSegments: []string{"aws", accountId, "account"},
}
}
return &inventory.Platform{
Name: "aws",
Title: "AWS Account",
Kind: "api",
Runtime: "aws",
Name: "aws",
Title: "AWS Account",
Kind: "api",
Runtime: "aws",
TechnologyUrlSegments: []string{"aws", accountId, "account"},
}
}

Expand Down
4 changes: 2 additions & 2 deletions providers/aws/resources/discovery_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func MqlObjectToAsset(account string, mqlObject mqlObject, conn *connection.AwsC
return &inventory.Asset{
PlatformIds: platformIds,
Name: mqlObject.name,
Platform: connection.GetPlatformForObject(platformName),
Platform: connection.GetPlatformForObject(platformName, account),
Labels: mqlObject.labels,
Connections: []*inventory.Config{t.Clone(inventory.WithoutDiscovery(), inventory.WithParentConnectionId(t.Id))},
Options: conn.ConnectionOptions(),
Expand Down Expand Up @@ -206,7 +206,7 @@ func accountAsset(conn *connection.AwsConnection, awsAccount *mqlAwsAccount) *in
return &inventory.Asset{
PlatformIds: []string{id},
Name: name,
Platform: connection.GetPlatformForObject(""),
Platform: connection.GetPlatformForObject("", accountId),
Connections: []*inventory.Config{conn.Conf.Clone(inventory.WithoutDiscovery(), inventory.WithParentConnectionId(conn.Conf.Id))},
Options: conn.ConnectionOptions(),
}
Expand Down

0 comments on commit 74b1bb0

Please sign in to comment.