connectivity

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SnykHosts = []string{
	"api.snyk.io",
	"app.snyk.io",
	"api.eu.snyk.io",
	"app.eu.snyk.io",
	"api.us.snyk.io",
	"app.us.snyk.io",
	"api.au.snyk.io",
	"app.au.snyk.io",
	"api.snykgov.io",
	"app.snykgov.io",
	"deeproxy.snyk.io/filters",
	"downloads.snyk.io:443/cli/wasm/bundle.tar.gz",
	"learn.snyk.io",
	"static.snyk.io/cli/latest/version",
	"snyk.io",
	"sentry.io",
}

SnykHosts contains all the Snyk endpoints to test

Functions

func GetSnykHosts

func GetSnykHosts() []string

GetSnykHosts returns a copy of the current SnykHosts slice in a thread-safe manner

func SetSnykHosts

func SetSnykHosts(hosts []string)

SetSnykHosts sets the SnykHosts slice in a thread-safe manner

func SetSnykHostsForTesting

func SetSnykHostsForTesting(hosts []string) func()

SetSnykHostsForTesting is a helper for tests that sets hosts and returns a cleanup function

Types

type Checker

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

Checker performs connectivity checks to Snyk endpoints

func NewChecker

func NewChecker(networkAccess networking.NetworkAccess, logger *zerolog.Logger, config configuration.Configuration, ui ...ui.UserInterface) *Checker

NewChecker creates a new connectivity checker

func NewCheckerWithApiClient

func NewCheckerWithApiClient(networkAccess networking.NetworkAccess, logger *zerolog.Logger, config configuration.Configuration, apiClient api.ApiClient, ui ...ui.UserInterface) *Checker

NewCheckerWithApiClient creates a new connectivity checker with a custom API client (mainly for testing)

func (*Checker) CheckConnectivity

func (c *Checker) CheckConnectivity() (*ConnectivityCheckResult, error)

CheckConnectivity performs connectivity checks to all Snyk endpoints

func (*Checker) CheckOrganizations

func (c *Checker) CheckOrganizations(limit int) ([]Organization, error)

CheckOrganizations checks if authentication token is configured and fetches organizations

func (*Checker) DetectProxyConfig

func (c *Checker) DetectProxyConfig() ProxyConfig

DetectProxyConfig detects proxy configuration from environment variables

type ConnectionStatus

type ConnectionStatus int

ConnectionStatus represents the status of a connection test

const (
	StatusOK ConnectionStatus = iota
	StatusReachable
	StatusProxyAuthSupported
	StatusProxyAuthUnsupported
	StatusServerError
	StatusBlocked
	StatusDNSError
	StatusTLSError
	StatusTimeout
)

func (ConnectionStatus) String

func (s ConnectionStatus) String() string

type ConnectivityCheckResult

type ConnectivityCheckResult struct {
	ProxyConfig   ProxyConfig    `json:"proxyConfig"`
	HostResults   []HostResult   `json:"hostResults"`
	TODOs         []TODO         `json:"todos"`
	StartTime     time.Time      `json:"startTime"`
	EndTime       time.Time      `json:"endTime"`
	Organizations []Organization `json:"organizations"`
	TokenPresent  bool           `json:"tokenPresent"`
	OrgCheckError error          `json:"orgCheckError,omitempty"`
}

ConnectivityCheckResult represents the complete result of connectivity checks

func (*ConnectivityCheckResult) AddTODOf

func (r *ConnectivityCheckResult) AddTODOf(level TodoLevel, format string, args ...interface{})

AddTODO adds a new TODO item to the result AddTODOf adds a TODO item to the result with printf-style formatting

type Formatter

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

Formatter formats connectivity check results using GAF UI components

func NewFormatter

func NewFormatter(writer io.Writer, useColor bool) *Formatter

NewFormatter creates a new formatter using an io.Writer

func (*Formatter) FormatResult

func (f *Formatter) FormatResult(result *ConnectivityCheckResult) error

FormatResult formats the complete connectivity check result using GAF presenters

type HostResult

type HostResult struct {
	Host         string           `json:"host"`
	DisplayHost  string           `json:"displayHost"`
	URL          string           `json:"url"`
	StatusCode   int              `json:"statusCode"`
	Status       ConnectionStatus `json:"status"`
	Message      string           `json:"message,omitempty"`
	ProxyAuth    string           `json:"proxyAuth,omitempty"`
	ResponseTime time.Duration    `json:"responseTime"`
	Error        error            `json:"error,omitempty"`
}

HostResult represents the connectivity test result for a single host

type Organization

type Organization struct {
	ID        string `json:"id"`
	GroupID   string `json:"groupId"`
	Name      string `json:"name"`
	Slug      string `json:"slug"`
	IsDefault bool   `json:"isDefault"`
}

Organization represents a Snyk organization

type ProxyConfig

type ProxyConfig struct {
	Detected         bool   `json:"detected"`
	URL              string `json:"url,omitempty"`
	Variable         string `json:"variable,omitempty"`
	NoProxy          string `json:"noProxy,omitempty"`
	NodeExtraCACerts string `json:"nodeExtraCACerts,omitempty"`
	KRB5Config       string `json:"krb5Config,omitempty"`
	KRB5CCName       string `json:"krb5CCName,omitempty"`
}

ProxyConfig represents proxy configuration detected from environment

type TODO

type TODO struct {
	Level   TodoLevel `json:"level"`
	Message string    `json:"message"`
}

TODO represents an actionable item from the connectivity check

type TodoLevel

type TodoLevel int

TodoLevel represents the severity level of a TODO item

const (
	TodoInfo TodoLevel = iota
	TodoWarn
	TodoFail
)

func (TodoLevel) String

func (l TodoLevel) String() string

Jump to

Keyboard shortcuts

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