Skip to content

Is Trivy go library can generate SBOMs with custom path? #8167

Closed Answered by pohanhuangtw
pohanhuangtw asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks @DmitriyLewen , just found out the root cause.

For those don't want to run the binary, Here is my example code

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/aquasecurity/trivy/pkg/commands"
	cmd "github.com/aquasecurity/trivy/pkg/commands/artifact"
	ftypes "github.com/aquasecurity/trivy/pkg/fanal/types"
	"github.com/aquasecurity/trivy/pkg/flag"
	"github.com/aquasecurity/trivy/pkg/types"
	"github.com/spf13/viper"
)

// able to run trivy with args without binary
func runTrivy(osArgs []string) {
	defer viper.Reset()
	ctx := context.Background()
	app := commands.NewApp()
	app.SetArgs(osArgs)
	// app.SetOut(io.Discard)

	// Run Trivy
	app.ExecuteContext(ctx)
}

// With Fo…

Replies: 4 comments 8 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@DmitriyLewen
Comment options

@pohanhuangtw
Comment options

@DmitriyLewen
Comment options

Comment options

You must be logged in to vote
5 replies
@DmitriyLewen
Comment options

@pohanhuangtw
Comment options

@DmitriyLewen
Comment options

@pohanhuangtw
Comment options

@DmitriyLewen
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by pohanhuangtw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
triage/support Indicates an issue that is a support question.
2 participants