cli

package
v0.0.0-...-3ee2f2b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package cli provides implementations for handling the Snyk CLI There is OS-specific code, see https://www.digitalocean.com/community/tutorials/building-go-applications-for-different-operating-systems-and-architectures for more information on how that works

Index

Constants

View Source
const (
	ApiEnvVar                           = "SNYK_API"
	TokenEnvVar                         = "SNYK_TOKEN"
	DisableAnalyticsEnvVar              = "SNYK_CFG_DISABLE_ANALYTICS"
	IntegrationNameEnvVarKey            = "SNYK_INTEGRATION_NAME"
	IntegrationVersionEnvVarKey         = "SNYK_INTEGRATION_VERSION"
	IntegrationEnvironmentEnvVarKey     = "SNYK_INTEGRATION_ENVIRONMENT"
	IntegrationEnvironmentVersionEnvVar = "SNYK_INTEGRATION_ENVIRONMENT_VERSION"
	IntegrationEnvironmentEnvVarValue   = "language-server"
	SnykOauthTokenEnvVar                = "SNYK_OAUTH_TOKEN"
)

Variables

View Source
var Mutex = &sync.Mutex{}

Functions

func AppendCliEnvironmentVariables

func AppendCliEnvironmentVariables(currentEnv []string, appendToken bool) []string

AppendCliEnvironmentVariables Returns the input array with additional variables used in the CLI run in the form of "key=value". Since we append, our values are overwriting existing env variables (because exec.Cmd.Env chooses the last value in case of key duplications). appendToken indicates whether we should append the token or not. No token should be appended in cases such as authentication.

Types

type Executor

type Executor interface {
	Execute(ctx context.Context, cmd []string, workingDir string) (resp []byte, err error)
	ExpandParametersFromConfig(base []string) []string
}

func NewExecutor

func NewExecutor(
	authenticationService snyk.AuthenticationService,
	errorReporter error_reporting.ErrorReporter,
	analytics ux.Analytics,
	notifier noti.Notifier,
) Executor

func NewExtensionExecutor

func NewExtensionExecutor() Executor

type ExtensionExecutor

type ExtensionExecutor struct {
	// contains filtered or unexported fields
}

func (ExtensionExecutor) CliVersion

func (c ExtensionExecutor) CliVersion() string

func (ExtensionExecutor) Execute

func (c ExtensionExecutor) Execute(ctx context.Context, cmd []string, workingDir string) (resp []byte, err error)

func (ExtensionExecutor) ExpandParametersFromConfig

func (c ExtensionExecutor) ExpandParametersFromConfig(base []string) []string

type Initializer

type Initializer struct {
	// contains filtered or unexported fields
}

func NewInitializer

func NewInitializer(errorReporter error_reporting.ErrorReporter,
	installer install.Installer,
	notifier noti.Notifier,
	cli Executor,
) *Initializer

func (*Initializer) Init

func (i *Initializer) Init() error

type SnykCli

type SnykCli struct {
	// contains filtered or unexported fields
}

func (SnykCli) CliVersion

func (c SnykCli) CliVersion() string

func (SnykCli) Execute

func (c SnykCli) Execute(ctx context.Context, cmd []string, workingDir string) (resp []byte, err error)

func (SnykCli) ExpandParametersFromConfig

func (c SnykCli) ExpandParametersFromConfig(base []string) []string

ExpandParametersFromConfig adds configuration parameters to the base command todo no need to export that, we could have a simpler interface that looks more like an actual CLI

type TestExecutor

type TestExecutor struct {
	ExecuteResponse []byte

	ExecuteDuration time.Duration
	// contains filtered or unexported fields
}

func NewTestExecutor

func NewTestExecutor() *TestExecutor

func NewTestExecutorWithResponse

func NewTestExecutorWithResponse(executeResponse string) *TestExecutor

func NewTestExecutorWithResponseFromFile

func NewTestExecutorWithResponseFromFile(executeResponsePath string) *TestExecutor

func (*TestExecutor) Execute

func (t *TestExecutor) Execute(ctx context.Context, cmd []string, _ string) (resp []byte, err error)

func (*TestExecutor) ExpandParametersFromConfig

func (t *TestExecutor) ExpandParametersFromConfig(_ []string) []string

func (*TestExecutor) GetCommand

func (t *TestExecutor) GetCommand() []string

func (*TestExecutor) GetFinishedScans

func (t *TestExecutor) GetFinishedScans() int

func (*TestExecutor) GetStartedScans

func (t *TestExecutor) GetStartedScans() int

func (*TestExecutor) HandleErrors

func (t *TestExecutor) HandleErrors(_ context.Context, _ string) (fail bool)

func (*TestExecutor) WasExecuted

func (t *TestExecutor) WasExecuted() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL