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

⭐️ define proto for cnspec report #3697

Merged
merged 4 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ prep/tools/mockgen:

# 🌙 MQL/MOTOR #

cnquery/generate: clean/proto llx/generate shared/generate providers explorer/generate sbom/generate
cnquery/generate: clean/proto llx/generate shared/generate providers explorer/generate sbom/generate reporter/generate

cnquery/generate/core: clean/proto llx/generate shared/generate providers/proto providers/build/mock providers/build/core explorer/generate sbom/generate

Expand Down Expand Up @@ -557,6 +557,9 @@ explorer/generate:
sbom/generate:
go generate ./sbom

reporter/generate:
go generate ./cli/reporter

# 🏗 Binary / Build #

.PHONY: cnquery/build
Expand Down
2 changes: 1 addition & 1 deletion apps/cnquery/cmd/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (c *cnqueryPlugin) RunQuery(conf *run.RunQueryConfig, runtime *providers.Ru
if conf.Format != "json" {
sh.PrintResults(code, results)
} else {
reporter.BundleResultsToJSON(code, results, out)
_ = reporter.CodeBundleToJSON(code, results, out)
preslavgerchev marked this conversation as resolved.
Show resolved Hide resolved
if len(discoveredAssets.Assets) != i+1 {
out.WriteString(",")
}
Expand Down
11 changes: 5 additions & 6 deletions apps/cnquery/cmd/sbom.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"go.mondoo.com/cnquery/v10/providers"
"go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin"
sbom "go.mondoo.com/cnquery/v10/sbom"
"go.mondoo.com/cnquery/v10/shared"
)

func init() {
Expand Down Expand Up @@ -87,14 +86,14 @@ var sbomCmdRun = func(cmd *cobra.Command, runtime *providers.Runtime, cliRes *pl
log.Fatal().Err(err).Msg("failed to run scan")
}

buf := bytes.Buffer{}
w := shared.IOWriter{Writer: &buf}
err = reporter.ReportCollectionToJSON(report, &w)
cnspecReport, err := reporter.ConvertToProto(report)
if err == nil {
logger.DebugDumpJSON("mondoo-sbom-report", buf.Bytes())
log.Debug().Msg("converted report to proto")
data, _ := cnspecReport.ToJSON()
logger.DebugDumpJSON("mondoo-sbom-report", data)
}

boms, err := sbom.NewBom(buf.Bytes())
boms, err := sbom.NewBom(cnspecReport)
if err != nil {
log.Fatal().Err(err).Msg("failed to parse bom")
}
Expand Down
Loading
Loading