Skip to content
Draft
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
35 changes: 35 additions & 0 deletions compliance/node/index/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/quay/claircore"
ccindexer "github.com/quay/claircore/indexer"
"github.com/quay/claircore/indexer/controller"
"github.com/quay/claircore/osrelease"
"github.com/quay/claircore/rhel"
"github.com/quay/zlog"
"github.com/rs/zerolog"
Expand Down Expand Up @@ -190,6 +191,13 @@ func (l *localNodeIndexer) IndexNode(ctx context.Context) (*v4.IndexReport, erro
return nil, errors.Wrap(err, "converting clair report to v4 report")
}

dists, err := runOSScanner(ctx, layer)
if err != nil {
return nil, errors.Wrap(err, "failed to scan os-release")
}
if len(dists) > 0 {
report.Distro = mapDistribution(dists[0])
}
return report, nil
}

Expand Down Expand Up @@ -283,3 +291,30 @@ func runCoalescer(ctx context.Context, layerDigest claircore.Digest, repos []*cl

return ir, nil
}

func runOSScanner(ctx context.Context, layer *claircore.Layer) ([]*claircore.Distribution, error) {
scanner := &osrelease.Scanner{}
dists, err := scanner.Scan(ctx, layer)
if err != nil {
return nil, err
}
// ID is required for the coalescer to link artifacts correctly
for i, d := range dists {
d.ID = strconv.Itoa(i)
}
return dists, nil
}

func mapDistribution(ccDist *claircore.Distribution) *v4.Distribution {
return &v4.Distribution{
Id: ccDist.ID,
Did: ccDist.DID,
Name: ccDist.Name,
Version: ccDist.Version,
VersionCodeName: ccDist.VersionCodeName,
VersionId: ccDist.VersionID,
Arch: ccDist.Arch,
Cpe: ccDist.CPE.BindFS(), // Converts WFN object to string
PrettyName: ccDist.PrettyName,
}
}
29 changes: 20 additions & 9 deletions generated/internalapi/scanner/v4/index_report.pb.go

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

90 changes: 90 additions & 0 deletions generated/internalapi/scanner/v4/index_report_vtproto.pb.go

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

3 changes: 2 additions & 1 deletion proto/internalapi/scanner/v4/index_report.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ message IndexReport {
bool success = 3;
string err = 4;
Contents contents = 5;
}
Distribution distro = 6;
}
2 changes: 1 addition & 1 deletion proto/storage/proto.lock
Original file line number Diff line number Diff line change
Expand Up @@ -20361,4 +20361,4 @@
}
}
]
}
}
Loading