Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⭐ Add missing technology segment urls #4557

Merged
merged 21 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions providers-sdk/v1/inventory/asset_url.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,18 +204,24 @@ func (a *AssetUrlBranch) validate() error {
continue
}

if err := validateKey(branch.Key); err != nil {
return err
}

for value, next := range branch.Values {
if err := validateValue(value); err != nil {
if branch.Key != "" {
if err := validateKey(branch.Key); err != nil {
return err
}
if next != nil {
branches = append(branches, next)
for value, next := range branch.Values {
if err := validateValue(value); err != nil {
return err
}
if next != nil {
branches = append(branches, next)
}
}
} else {
if len(branch.Values) != 0 {
return errors.New("asset url segment without key must not have values set")
}
}

}

return nil
Expand Down
11 changes: 11 additions & 0 deletions providers/ansible/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/v11/providers-sdk/v1/inventory"
"go.mondoo.com/cnquery/v11/providers-sdk/v1/plugin"
"go.mondoo.com/cnquery/v11/providers/ansible/provider"
)
Expand All @@ -24,4 +25,14 @@ var Config = plugin.Provider{
Flags: []plugin.Flag{},
},
},
AssetUrlTrees: []*inventory.AssetUrlBranch{
{
PathSegments: []string{"technology=iac", "category=ansible"},
Key: "kind",
Title: "Kind",
Values: map[string]*inventory.AssetUrlBranch{
"playbook": nil,
},
},
},
}
9 changes: 5 additions & 4 deletions providers/ansible/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,11 @@ func (s *Service) detect(asset *inventory.Asset, conn *connection.AnsibleConnect
asset.Name = conn.Conf.Host

asset.Platform = &inventory.Platform{
Name: "ansible-playbook",
Family: []string{"ansible"},
Kind: "api",
Title: "Ansible Playbook",
Name: "ansible-playbook",
Family: []string{"ansible"},
Kind: "api",
Title: "Ansible Playbook",
TechnologyUrlSegments: []string{"iac", "ansible", "playbook"},
}

projectPath, ok := asset.Connections[0].Options["path"]
Expand Down
6 changes: 6 additions & 0 deletions providers/arista/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/v11/providers-sdk/v1/inventory"
"go.mondoo.com/cnquery/v11/providers-sdk/v1/plugin"
"go.mondoo.com/cnquery/v11/providers/arista/provider"
)
Expand Down Expand Up @@ -41,4 +42,9 @@ var Config = plugin.Provider{
},
},
},
AssetUrlTrees: []*inventory.AssetUrlBranch{
{
PathSegments: []string{"technology=network", "category=arista"},
},
},
}
15 changes: 8 additions & 7 deletions providers/arista/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,14 @@ func (s *Service) detect(asset *inventory.Asset, conn *connection.AristaConnecti
}

asset.Platform = &inventory.Platform{
Name: "arista-eos",
Version: version,
Arch: arch,
Family: []string{"arista"},
Kind: "api",
Title: "Arista EOS",
Runtime: "arista",
Name: "arista-eos",
Version: version,
Arch: arch,
Family: []string{"arista"},
Kind: "api",
Title: "Arista EOS",
Runtime: "arista",
TechnologyUrlSegments: []string{"network", "arista"},
}

eosClient := eos.NewEos(conn.Client())
Expand Down
14 changes: 14 additions & 0 deletions providers/atlassian/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/v11/providers-sdk/v1/inventory"
"go.mondoo.com/cnquery/v11/providers-sdk/v1/plugin"
"go.mondoo.com/cnquery/v11/providers/atlassian/connection/confluence"
"go.mondoo.com/cnquery/v11/providers/atlassian/provider"
Expand Down Expand Up @@ -80,4 +81,17 @@ For the SCIM token and the directory-id values: Atlassian provides these values
},
},
},
AssetUrlTrees: []*inventory.AssetUrlBranch{
{
PathSegments: []string{"technology=saas", "provider=atlassian"},
Key: "kind",
Title: "Kind",
Values: map[string]*inventory.AssetUrlBranch{
"admin": nil,
"confluence": nil,
"jira": nil,
"scim": nil,
},
},
},
}
18 changes: 10 additions & 8 deletions providers/atlassian/connection/admin/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@ func (a *AdminConnection) PlatformInfo() *inventory.Platform {
func GetPlatformForObject(platformName string) *inventory.Platform {
if platformName != "atlassian-admin" && platformName != "" {
return &inventory.Platform{
Name: platformName,
Title: "Atlassian Admin",
Kind: "api",
Runtime: "atlassian",
Name: platformName,
Title: "Atlassian Admin",
Kind: "api",
Runtime: "atlassian",
TechnologyUrlSegments: []string{"saas", "atlassian", "admin"},
}
}
return &inventory.Platform{
Name: "atlassian-admin",
Title: "Atlassian Admin",
Kind: "api",
Runtime: "atlassian",
Name: "atlassian-admin",
Title: "Atlassian Admin",
Kind: "api",
Runtime: "atlassian",
TechnologyUrlSegments: []string{"saas", "atlassian", "admin"},
}
}

Expand Down
18 changes: 10 additions & 8 deletions providers/atlassian/connection/confluence/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@ func (a *ConfluenceConnection) PlatformInfo() *inventory.Platform {
func GetPlatformForObject(platformName string) *inventory.Platform {
if platformName != "atlassian-confluence" && platformName != "" {
return &inventory.Platform{
Name: platformName,
Title: "Atlassian Confluence",
Kind: "api",
Runtime: "atlassian",
Name: platformName,
Title: "Atlassian Confluence",
Kind: "api",
Runtime: "atlassian",
TechnologyUrlSegments: []string{"saas", "atlassian", "confluence"},
}
}
return &inventory.Platform{
Name: "atlassian-confluence",
Title: "Atlassian Confluence",
Kind: "api",
Runtime: "atlassian",
Name: "atlassian-confluence",
Title: "Atlassian Confluence",
Kind: "api",
Runtime: "atlassian",
TechnologyUrlSegments: []string{"saas", "atlassian", "confluence"},
}
}

Expand Down
18 changes: 10 additions & 8 deletions providers/atlassian/connection/jira/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@ func (a *JiraConnection) PlatformInfo() *inventory.Platform {
func GetPlatformForObject(platformName string) *inventory.Platform {
if platformName != "atlassian-jira" && platformName != "" {
return &inventory.Platform{
Name: platformName,
Title: "Atlassian Jira",
Kind: "api",
Runtime: "atlassian",
Name: platformName,
Title: "Atlassian Jira",
Kind: "api",
Runtime: "atlassian",
TechnologyUrlSegments: []string{"saas", "atlassian", "jira"},
}
}
return &inventory.Platform{
Name: "atlassian-jira",
Title: "Atlassian Jira",
Kind: "api",
Runtime: "atlassian",
Name: "atlassian-jira",
Title: "Atlassian Jira",
Kind: "api",
Runtime: "atlassian",
TechnologyUrlSegments: []string{"saas", "atlassian", "jira"},
}
}

Expand Down
18 changes: 10 additions & 8 deletions providers/atlassian/connection/scim/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@ func (a *ScimConnection) PlatformInfo() *inventory.Platform {
func GetPlatformForObject(platformName string) *inventory.Platform {
if platformName != "atlassian-scim" && platformName != "" {
return &inventory.Platform{
Name: platformName,
Title: "Atlassian SCIM",
Kind: "api",
Runtime: "atlassian",
Name: platformName,
Title: "Atlassian SCIM",
Kind: "api",
Runtime: "atlassian",
TechnologyUrlSegments: []string{"saas", "atlassian", "scim"},
}
}
return &inventory.Platform{
Name: "atlassian-scim",
Title: "Atlassian SCIM",
Kind: "api",
Runtime: "atlassian",
Name: "atlassian-scim",
Title: "Atlassian SCIM",
Kind: "api",
Runtime: "atlassian",
TechnologyUrlSegments: []string{"saas", "atlassian", "scim"},
}
}

Expand Down
11 changes: 11 additions & 0 deletions providers/cloudformation/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/v11/providers-sdk/v1/inventory"
"go.mondoo.com/cnquery/v11/providers-sdk/v1/plugin"
"go.mondoo.com/cnquery/v11/providers/cloudformation/provider"
)
Expand All @@ -24,4 +25,14 @@ var Config = plugin.Provider{
Flags: []plugin.Flag{},
},
},
AssetUrlTrees: []*inventory.AssetUrlBranch{
{
PathSegments: []string{"technology=iac", "category=cloudformation"},
Key: "kind",
Title: "Kind",
Values: map[string]*inventory.AssetUrlBranch{
"template": nil,
},
},
},
}
11 changes: 6 additions & 5 deletions providers/cloudformation/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,12 @@ func (s *Service) detect(asset *inventory.Asset, conn *connection.Cloudformation
asset.Name = conn.Conf.Host

asset.Platform = &inventory.Platform{
Name: "cloudformation",
Family: []string{"cloudformation"},
Runtime: "cloudformation",
Kind: "api",
Title: "AWS CloudFormation",
Name: "cloudformation",
Family: []string{"cloudformation"},
Runtime: "cloudformation",
Kind: "api",
Title: "AWS CloudFormation",
TechnologyUrlSegments: []string{"iac", "cloudformation", "template"},
}

projectPath, ok := asset.Connections[0].Options["path"]
Expand Down
2 changes: 1 addition & 1 deletion providers/github/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ var Config = plugin.Provider{
},
AssetUrlTrees: []*inventory.AssetUrlBranch{
{
PathSegments: []string{"technology=github"},
PathSegments: []string{"technology=saas", "provider=github"},
Key: "organization",
Title: "Organization",
Values: map[string]*inventory.AssetUrlBranch{
Expand Down
6 changes: 3 additions & 3 deletions providers/github/connection/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,19 @@ func (c *GithubConnection) PlatformInfo() (*inventory.Platform, error) {

func NewGithubOrgPlatform(orgId string) *inventory.Platform {
pf := GithubOrgPlatform
pf.TechnologyUrlSegments = []string{"github", "organization", orgId, "organization"}
pf.TechnologyUrlSegments = []string{"saas", "github", "organization", orgId, "organization"}
return &pf
}

func NewGithubUserPlatform(userId string) *inventory.Platform {
pf := GithubUserPlatform
pf.TechnologyUrlSegments = []string{"github", "user"}
pf.TechnologyUrlSegments = []string{"saas", "github", "user"}
return &pf
}

func NewGitHubRepoPlatform(owner, repo string) *inventory.Platform {
pf := GithubRepoPlatform
pf.TechnologyUrlSegments = []string{"github", "organization", owner, "repository"}
pf.TechnologyUrlSegments = []string{"saas", "github", "organization", owner, "repository"}
return &pf
}

Expand Down
12 changes: 12 additions & 0 deletions providers/gitlab/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/v11/providers-sdk/v1/inventory"
"go.mondoo.com/cnquery/v11/providers-sdk/v1/plugin"
"go.mondoo.com/cnquery/v11/providers/gitlab/provider"
)
Expand Down Expand Up @@ -57,4 +58,15 @@ var Config = plugin.Provider{
},
},
},
AssetUrlTrees: []*inventory.AssetUrlBranch{
{
PathSegments: []string{"technology=saas", "provider=gitlab"},
Key: "kind",
Title: "Kind",
Values: map[string]*inventory.AssetUrlBranch{
"project": nil,
"group": nil,
},
},
},
}
Loading
Loading