mirror of
https://github.com/safedep/vet.git
synced 2025-12-11 17:44:20 -06:00
#7: Add support for verify auth before scan
This commit is contained in:
parent
115b7e4f0b
commit
430d002c3c
1
auth.go
1
auth.go
@ -51,6 +51,7 @@ func configureAuthCommand() *cobra.Command {
|
||||
err = auth.Configure(auth.Config{
|
||||
ApiUrl: authInsightApiBaseUrl,
|
||||
ApiKey: string(key),
|
||||
ControlPlaneApiUrl: authControlPlaneApiBaseUrl,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
|
||||
@ -23,6 +23,7 @@ const (
|
||||
type Config struct {
|
||||
ApiUrl string `yaml:"api_url"`
|
||||
ApiKey string `yaml:"api_key"`
|
||||
ControlPlaneApiUrl string `yaml:"cp_api_url"`
|
||||
}
|
||||
|
||||
// Global config to be used during runtime
|
||||
@ -42,6 +43,10 @@ func DefaultApiUrl() string {
|
||||
}
|
||||
|
||||
func DefaultControlPlaneApiUrl() string {
|
||||
if (globalConfig != nil) && (globalConfig.ControlPlaneApiUrl != "") {
|
||||
return globalConfig.ControlPlaneApiUrl
|
||||
}
|
||||
|
||||
return defaultControlPlaneApiUrl
|
||||
}
|
||||
|
||||
|
||||
10
scan.go
10
scan.go
@ -5,6 +5,7 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/safedep/dry/utils"
|
||||
"github.com/safedep/vet/internal/auth"
|
||||
"github.com/safedep/vet/internal/ui"
|
||||
"github.com/safedep/vet/pkg/analyzer"
|
||||
"github.com/safedep/vet/pkg/models"
|
||||
@ -29,6 +30,7 @@ var (
|
||||
consoleReport bool
|
||||
summaryReport bool
|
||||
silentScan bool
|
||||
disableAuthVerifyBeforeScan bool
|
||||
)
|
||||
|
||||
func newScanCommand() *cobra.Command {
|
||||
@ -68,6 +70,8 @@ func newScanCommand() *cobra.Command {
|
||||
"Filter packages using CEL Filter Suite from file")
|
||||
cmd.Flags().BoolVarP(&celFilterFailOnMatch, "filter-fail", "", false,
|
||||
"Fail the scan if the filter match any package (security gate)")
|
||||
cmd.Flags().BoolVarP(&disableAuthVerifyBeforeScan, "no-verify-auth", "", false,
|
||||
"Do not verify auth token before starting scan")
|
||||
cmd.Flags().StringVarP(&markdownReportPath, "report-markdown", "", "",
|
||||
"Generate consolidated markdown report to file")
|
||||
cmd.Flags().BoolVarP(&consoleReport, "report-console", "", false,
|
||||
@ -97,6 +101,12 @@ func listParsersCommand() *cobra.Command {
|
||||
}
|
||||
|
||||
func startScan() {
|
||||
if !disableAuthVerifyBeforeScan {
|
||||
failOnError("auth/verify", auth.Verify(&auth.VerifyConfig{
|
||||
ControlPlaneApiUrl: auth.DefaultControlPlaneApiUrl(),
|
||||
}))
|
||||
}
|
||||
|
||||
failOnError("scan", internalStartScan())
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user