-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Fix docker/container registry scanning. Start cleaning code up.
Signed-off-by: Preslav <[email protected]>
- Loading branch information
1 parent
68b55dc
commit d44418c
Showing
9 changed files
with
184 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// Copyright (c) Mondoo, Inc. | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
package registry | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/spf13/afero" | ||
"go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" | ||
"go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" | ||
"go.mondoo.com/cnquery/v10/providers/os/connection/shared" | ||
"go.mondoo.com/cnquery/v10/providers/os/resources/discovery/container_registry" | ||
) | ||
|
||
var _ shared.Connection = &RegistryConnection{} | ||
|
||
type RegistryConnection struct { | ||
plugin.Connection | ||
asset *inventory.Asset | ||
} | ||
|
||
func (r *RegistryConnection) Capabilities() shared.Capabilities { | ||
return 0 | ||
} | ||
|
||
func (r *RegistryConnection) FileInfo(path string) (shared.FileInfoDetails, error) { | ||
panic("unimplemented") | ||
} | ||
|
||
func (r *RegistryConnection) FileSystem() afero.Fs { | ||
panic("unimplemented") | ||
} | ||
|
||
func (r *RegistryConnection) RunCommand(command string) (*shared.Command, error) { | ||
return nil, errors.New("unimplemented") | ||
} | ||
|
||
func (r *RegistryConnection) Type() shared.ConnectionType { | ||
return shared.Type_ContainerRegistry | ||
} | ||
|
||
func (r *RegistryConnection) UpdateAsset(asset *inventory.Asset) { | ||
r.asset = asset | ||
} | ||
|
||
func NewRegistryConnection(id uint32, conf *inventory.Config, asset *inventory.Asset) (*RegistryConnection, error) { | ||
conn := &RegistryConnection{ | ||
Connection: plugin.NewConnection(id, asset), | ||
asset: asset, | ||
} | ||
|
||
return conn, nil | ||
} | ||
|
||
func (r *RegistryConnection) Name() string { | ||
return "container-registry" | ||
} | ||
|
||
func (r *RegistryConnection) ID() uint32 { | ||
return r.Connection.ID() | ||
} | ||
|
||
func (r *RegistryConnection) ParentID() uint32 { | ||
return r.Connection.ParentID() | ||
} | ||
|
||
func (r *RegistryConnection) Close() error { | ||
return nil | ||
} | ||
|
||
func (r *RegistryConnection) Asset() *inventory.Asset { | ||
return r.asset | ||
} | ||
|
||
func (r *RegistryConnection) DiscoverImages() (*inventory.Inventory, error) { | ||
resolver := container_registry.NewContainerRegistryResolver() | ||
host := r.Asset().Connections[0].Host | ||
assets, err := resolver.ListImages(host) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return inventory.New(inventory.WithAssets(assets...)), nil | ||
} |
Oops, something went wrong.