cli

package
v0.0.0-...-dfd24c6 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package cli provides implementations for handling the Vulnmap 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                           = "VULNMAP_API"
	TokenEnvVar                         = "VULNMAP_TOKEN"
	DisableAnalyticsEnvVar              = "VULNMAP_CFG_DISABLE_ANALYTICS"
	IntegrationNameEnvVarKey            = "VULNMAP_INTEGRATION_NAME"
	IntegrationVersionEnvVarKey         = "VULNMAP_INTEGRATION_VERSION"
	IntegrationEnvironmentEnvVarKey     = "VULNMAP_INTEGRATION_ENVIRONMENT"
	IntegrationEnvironmentVersionEnvVar = "VULNMAP_INTEGRATION_ENVIRONMENT_VERSION"
	IntegrationEnvironmentEnvVarValue   = "language-server"
	VulnmapOauthTokenEnvVar             = "VULNMAP_OAUTH_TOKEN"
)

Variables

View Source
var Mutex = &sync.Mutex{}

Functions

func AppendCliEnvironmentVariables

func AppendCliEnvironmentVariables(currentEnv []string, appendToken bool) (updatedEnv []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 vulnmap.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 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, _ []string, _ string) (resp []byte, err error)

func (*TestExecutor) ExpandParametersFromConfig

func (t *TestExecutor) ExpandParametersFromConfig(_ []string) []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

type VulnmapCli

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

func (VulnmapCli) CliVersion

func (c VulnmapCli) CliVersion() string

func (VulnmapCli) Execute

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

func (VulnmapCli) ExpandParametersFromConfig

func (c VulnmapCli) 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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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