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
- Variables
- func AppendCliEnvironmentVariables(currentEnv []string, appendToken bool) (updatedEnv []string)
- type Executor
- type ExtensionExecutor
- type Initializer
- type TestExecutor
- func (t *TestExecutor) Execute(ctx context.Context, _ []string, _ string) (resp []byte, err error)
- func (t *TestExecutor) ExpandParametersFromConfig(_ []string) []string
- func (t *TestExecutor) GetFinishedScans() int
- func (t *TestExecutor) GetStartedScans() int
- func (t *TestExecutor) HandleErrors(_ context.Context, _ string) (fail bool)
- func (t *TestExecutor) WasExecuted() bool
- type VulnmapCli
Constants ¶
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 ¶
var Mutex = &sync.Mutex{}
Functions ¶
func AppendCliEnvironmentVariables ¶
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) 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) 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) 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