Skip to content

Commit

Permalink
Showing 4 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
@@ -398,4 +398,5 @@ type Container struct {
ContainerID string
Name string
Type string
Image string
}
1 change: 1 addition & 0 deletions models/models.go
Original file line number Diff line number Diff line change
@@ -452,6 +452,7 @@ type DistroAdvisory struct {
type Container struct {
ContainerID string
Name string
Image string
}

// Platform has platform information
10 changes: 6 additions & 4 deletions scan/base.go
Original file line number Diff line number Diff line change
@@ -84,7 +84,7 @@ func (l base) getLackDependencies() []string {
func (l base) allContainers() (containers []config.Container, err error) {
switch l.ServerInfo.Container.Type {
case "", "docker":
stdout, err := l.dockerPs("-a --format '{{.ID}} {{.Names}}'")
stdout, err := l.dockerPs("-a --format '{{.ID}} {{.Names}} {{.Image}}'")
if err != nil {
return containers, err
}
@@ -104,7 +104,7 @@ func (l base) allContainers() (containers []config.Container, err error) {
func (l *base) runningContainers() (containers []config.Container, err error) {
switch l.ServerInfo.Container.Type {
case "", "docker":
stdout, err := l.dockerPs("--format '{{.ID}} {{.Names}}'")
stdout, err := l.dockerPs("--format '{{.ID}} {{.Names}} {{.Image}}'")
if err != nil {
return containers, err
}
@@ -124,7 +124,7 @@ func (l *base) runningContainers() (containers []config.Container, err error) {
func (l *base) exitedContainers() (containers []config.Container, err error) {
switch l.ServerInfo.Container.Type {
case "", "docker":
stdout, err := l.dockerPs("--filter 'status=exited' --format '{{.ID}} {{.Names}}'")
stdout, err := l.dockerPs("--filter 'status=exited' --format '{{.ID}} {{.Names}} {{.Image}}'")
if err != nil {
return containers, err
}
@@ -166,12 +166,13 @@ func (l *base) parseDockerPs(stdout string) (containers []config.Container, err
if len(fields) == 0 {
break
}
if len(fields) != 2 {
if len(fields) != 3 {
return containers, fmt.Errorf("Unknown format: %s", line)
}
containers = append(containers, config.Container{
ContainerID: fields[0],
Name: fields[1],
Image: fields[2],
})
}
return
@@ -279,6 +280,7 @@ func (l *base) convertToModel() (models.ScanResult, error) {
container := models.Container{
ContainerID: l.ServerInfo.Container.ContainerID,
Name: l.ServerInfo.Container.Name,
Image: l.ServerInfo.Container.Image,
}

return models.ScanResult{
1 change: 1 addition & 0 deletions scan/serverapi.go
Original file line number Diff line number Diff line change
@@ -284,6 +284,7 @@ func detectContainerOSesOnServer(containerHost osTypeInterface) (oses []osTypeIn
copied.SetContainer(config.Container{
ContainerID: containerInfo.ContainerID,
Name: containerInfo.Name,
Image: containerInfo.Image,
Type: containerHostInfo.Container.Type,
})
os := detectOS(copied)

0 comments on commit 1e8f24d

Please sign in to comment.