Documentation ¶
Index ¶
- Constants
- Variables
- func AuthenticationCheck() (string, error)
- func NoopResultProcessor(_ ScanData)
- type ActiveUser
- type AuthenticationFailedError
- type AuthenticationFunction
- type AuthenticationProvider
- type AuthenticationService
- type CodeAction
- func NewCodeAction(title string, edit *WorkspaceEdit, command *CommandData) (CodeAction, error)
- func NewDeferredCodeAction(title string, deferredEdit *func() *WorkspaceEdit, ...) (CodeAction, error)
- func NewPreferredCodeAction(title string, edit *WorkspaceEdit, command *CommandData) (CodeAction, error)
- type CodeIssueData
- type CodePoint
- type Command
- type CommandData
- type CommandName
- type CommandService
- type CommandServiceMock
- type CommitChangeLine
- type DelegatingConcurrentScanner
- func (sc *DelegatingConcurrentScanner) ClearInlineValues(path string)
- func (sc *DelegatingConcurrentScanner) GetInlineValues(path string, myRange Range) (values []InlineValue, err error)
- func (sc *DelegatingConcurrentScanner) Init() error
- func (sc *DelegatingConcurrentScanner) Scan(ctx context.Context, path string, processResults ScanResultProcessor, ...)
- func (sc *DelegatingConcurrentScanner) ScanPackages(ctx context.Context, config *config.Config, path string, content string)
- type ExampleCommitFix
- type FakeAuthenticationProvider
- func (a *FakeAuthenticationProvider) AuthURL(_ context.Context) string
- func (a *FakeAuthenticationProvider) Authenticate(_ context.Context) (string, error)
- func (a *FakeAuthenticationProvider) ClearAuthentication(_ context.Context) error
- func (a *FakeAuthenticationProvider) GetCheckAuthenticationFunction() AuthenticationFunction
- func (a *FakeAuthenticationProvider) SetAuthURL(url string)
- type IaCIssueData
- type InlineValue
- type InlineValueProvider
- type Issue
- type Marker
- type MarkerPosition
- type MessageAction
- type MessageType
- type MockScanNotifier
- func (m *MockScanNotifier) ErrorCalls() []string
- func (m *MockScanNotifier) InProgressCalls() []string
- func (m *MockScanNotifier) SendError(product product.Product, folderPath string)
- func (m *MockScanNotifier) SendInProgress(folderPath string)
- func (m *MockScanNotifier) SendSuccess(product product.Product, folderPath string, issues []Issue)
- func (m *MockScanNotifier) SendSuccessForAllProducts(folderPath string, issues []Issue)
- func (m *MockScanNotifier) SuccessCalls() []string
- type OssIssueData
- type PackageScanner
- type Position
- type ProductScanner
- type Range
- type Reference
- type ScanData
- type ScanNotifier
- type ScanResultProcessor
- type Scanner
- type Severity
- type SeverityCount
- type ShowMessageRequest
- type TestProductScanner
- func (t *TestProductScanner) GetInlineValues(_ string, _ Range) ([]InlineValue, error)
- func (t *TestProductScanner) IsEnabled() bool
- func (t *TestProductScanner) Product() product.Product
- func (t *TestProductScanner) Scan(ctx context.Context, _ string, _ string) (issues []Issue, err error)
- func (t *TestProductScanner) Scans() int
- func (t *TestProductScanner) SetScanDuration(duration time.Duration)
- type TestScanner
- func (s *TestScanner) AddTestIssue(issue Issue)
- func (s *TestScanner) Calls() int
- func (s *TestScanner) Init() error
- func (s *TestScanner) IsEnabled() bool
- func (s *TestScanner) Product() product.Product
- func (s *TestScanner) Scan(_ context.Context, _ string, processResults ScanResultProcessor, _ string)
- type TextEdit
- type Type
- type WorkspaceEdit
Constants ¶
const ( WorkspaceScanCommand = "vulnmap.workspace.scan" WorkspaceFolderScanCommand = "vulnmap.workspaceFolder.scan" OpenBrowserCommand = "vulnmap.openBrowser" LoginCommand = "vulnmap.login" CopyAuthLinkCommand = "vulnmap.copyAuthLink" LogoutCommand = "vulnmap.logout" TrustWorkspaceFoldersCommand = "vulnmap.trustWorkspaceFolders" OpenLearnLesson = "vulnmap.openLearnLesson" GetLearnLesson = "vulnmap.getLearnLesson" GetSettingsSastEnabled = "vulnmap.getSettingsSastEnabled" GetActiveUserCommand = "vulnmap.getActiveUser" ReportAnalyticsCommand = "vulnmap.reportAnalytics" // Vulnmap Code specific commands CodeFixCommand = "vulnmap.code.fix" CodeSubmitFixFeedback = "vulnmap.code.submitFixFeedback" )
const TestProduct product.Product = "Test Product"
Variables ¶
var (
DefaultOpenBrowserFunc = func(url string) { auth.OpenBrowser(url) }
)
var ErrEmptyAPIToken = errors.New("auth-provider: api token is not set")
Functions ¶
func AuthenticationCheck ¶
func NoopResultProcessor ¶
func NoopResultProcessor(_ ScanData)
Types ¶
type ActiveUser ¶
type ActiveUser struct { Id string `json:"id"` UserName string `json:"username,omitempty"` Orgs []struct { Name string `json:"name,omitempty"` Id string `json:"id,omitempty"` Group struct { Name string `json:"name,omitempty"` Id string `json:"id,omitempty"` } `json:"group,omitempty"` } `json:"orgs,omitempty"` }
func GetActiveUser ¶
func GetActiveUser() (*ActiveUser, error)
type AuthenticationFailedError ¶
type AuthenticationFailedError struct {
ManualAuthentication bool
}
func (*AuthenticationFailedError) Error ¶
func (e *AuthenticationFailedError) Error() string
type AuthenticationFunction ¶
type AuthenticationProvider ¶
type AuthenticationProvider interface { // Authenticate triggers the authentication. This may involve manual steps, like logging in using a browser Authenticate(ctx context.Context) (string, error) // ClearAuthentication removes all authentication information from the configuration ClearAuthentication(ctx context.Context) error // AuthURL returns the latest provided AuthenticationURL. This can be empty. AuthURL(ctx context.Context) string // SetAuthURL sets the latest provided Authentication URL. This is a temporary URL. SetAuthURL(url string) GetCheckAuthenticationFunction() AuthenticationFunction }
type AuthenticationService ¶
type AuthenticationService interface { // Authenticate attempts to authenticate the user, and sends a notification to the client when successful Authenticate(ctx context.Context) (string, error) Provider() AuthenticationProvider // UpdateCredentials stores the token in the configuration, and sends a $/vulnmap.hasAuthenticated notification to the // client if sendNotification is true UpdateCredentials(newToken string, sendNotification bool) Logout(ctx context.Context) // IsAuthenticated returns true if the token is verified IsAuthenticated() (bool, error) // SetProvider sets the authentication provider SetProvider(provider AuthenticationProvider) }
func NewAuthenticationService ¶
func NewAuthenticationService( authenticationProvider AuthenticationProvider, analytics ux.Analytics, errorReporter error_reporting.ErrorReporter, notifier noti.Notifier, ) AuthenticationService
type CodeAction ¶
type CodeAction struct { // Title is a short, human-readable, title for this code action. Title string IsPreferred *bool // Edit is an optional WorkspaceEdit literal that can be executed by the client. Edit *WorkspaceEdit // DeferredEdit is a function that returns a WorkspaceEdit. // Used for heavy calculations that shouldn't be done ahead of time. // A CodeAction cannot have both Edit and DeferredEdit. DeferredEdit *func() *WorkspaceEdit // Command that will be executed after the Edit (if present). Command *CommandData // DeferredCommand is a function that returns a Command. // Used for heavy calculations that shouldn't be done ahead of time. // A CodeAction cannot have both Command and DeferredCommand. DeferredCommand *func() *CommandData // UUID is a unique identifier for this code action. This is used for deferred resolution of a command or edit. Uuid *uuid.UUID }
CodeAction represents a code action that can be executed by the client using an in-document menu. This type should be created by the NewCodeAction or NewDeferredCodeAction functions.
There are 3 types of code actions: - No Edit + No CommandData - Deferred code action, which means that either DeferredEdit or DeferredCommand must be set. - Only edit/Only command - Resolved immediately to run the edit/command. - Both edit and command - Resolved immediately to run edit first and then command.
func NewCodeAction ¶
func NewCodeAction(title string, edit *WorkspaceEdit, command *CommandData) (CodeAction, error)
func NewDeferredCodeAction ¶
func NewDeferredCodeAction(title string, deferredEdit *func() *WorkspaceEdit, deferredCommand *func() *CommandData, ) (CodeAction, error)
func NewPreferredCodeAction ¶
func NewPreferredCodeAction(title string, edit *WorkspaceEdit, command *CommandData) (CodeAction, error)
type CodeIssueData ¶
type CodeIssueData struct { // Unique key identifying an issue in the whole result set Key string `json:"key"` Title string `json:"title"` Message string `json:"message"` Rule string `json:"rule"` RuleId string `json:"ruleId"` RepoDatasetSize int `json:"repoDatasetSize"` ExampleCommitFixes []ExampleCommitFix `json:"exampleCommitFixes"` CWE []string `json:"cwe"` Text string `json:"text"` Markers []Marker `json:"markers,omitempty"` Cols CodePoint `json:"cols"` Rows CodePoint `json:"rows"` IsSecurityType bool `json:"isSecurityType"` IsAutofixable bool `json:"isAutofixable"` }
type Command ¶
type Command interface { Command() CommandData Execute(ctx context.Context) (any, error) }
type CommandData ¶
type CommandName ¶
type CommandName string
type CommandService ¶
type CommandServiceMock ¶
type CommandServiceMock struct {
// contains filtered or unexported fields
}
func NewCommandServiceMock ¶
func NewCommandServiceMock() *CommandServiceMock
func (*CommandServiceMock) ExecuteCommandData ¶
func (service *CommandServiceMock) ExecuteCommandData(_ context.Context, command CommandData, server lsp.Server) (any, error)
todo:test
func (*CommandServiceMock) ExecutedCommands ¶
func (service *CommandServiceMock) ExecutedCommands() []CommandData
type CommitChangeLine ¶
type DelegatingConcurrentScanner ¶
type DelegatingConcurrentScanner struct {
// contains filtered or unexported fields
}
DelegatingConcurrentScanner is a simple Scanner Implementation that delegates on other scanners asynchronously
func (*DelegatingConcurrentScanner) ClearInlineValues ¶
func (sc *DelegatingConcurrentScanner) ClearInlineValues(path string)
func (*DelegatingConcurrentScanner) GetInlineValues ¶
func (sc *DelegatingConcurrentScanner) GetInlineValues(path string, myRange Range) (values []InlineValue, err error)
func (*DelegatingConcurrentScanner) Init ¶
func (sc *DelegatingConcurrentScanner) Init() error
func (*DelegatingConcurrentScanner) Scan ¶
func (sc *DelegatingConcurrentScanner) Scan( ctx context.Context, path string, processResults ScanResultProcessor, folderPath string, )
func (*DelegatingConcurrentScanner) ScanPackages ¶
type ExampleCommitFix ¶
type ExampleCommitFix struct { CommitURL string `json:"commitURL"` Lines []CommitChangeLine `json:"lines"` }
type FakeAuthenticationProvider ¶
type FakeAuthenticationProvider struct { ExpectedAuthURL string IsAuthenticated bool // contains filtered or unexported fields }
func NewFakeCliAuthenticationProvider ¶
func NewFakeCliAuthenticationProvider() *FakeAuthenticationProvider
func (*FakeAuthenticationProvider) AuthURL ¶
func (a *FakeAuthenticationProvider) AuthURL(_ context.Context) string
func (*FakeAuthenticationProvider) Authenticate ¶
func (a *FakeAuthenticationProvider) Authenticate(_ context.Context) (string, error)
func (*FakeAuthenticationProvider) ClearAuthentication ¶
func (a *FakeAuthenticationProvider) ClearAuthentication(_ context.Context) error
func (*FakeAuthenticationProvider) GetCheckAuthenticationFunction ¶
func (a *FakeAuthenticationProvider) GetCheckAuthenticationFunction() AuthenticationFunction
func (*FakeAuthenticationProvider) SetAuthURL ¶
func (a *FakeAuthenticationProvider) SetAuthURL(url string)
type IaCIssueData ¶
type IaCIssueData struct { // Unique key identifying an issue in the whole result set Key string `json:"key"` // Title: title of the issue Title string `json:"title"` // PublicID: unique identifier for the issue; it is the same as the ScanIssue.ID PublicId string `json:"publicId"` // Documentation is a URL which is constructed from the PublicID (e.g. https://security.vulnmap.khulnasoft.com/rules/cloud/VULNMAP-CC-K8S-13) Documentation string `json:"documentation"` // LineNumber: line number of the issue in the file LineNumber int `json:"lineNumber"` // Issue: will contain the issue description Issue string `json:"issue"` // Impact: will contain the impact description Impact string `json:"impact"` // Resolve: will contain the resolution description (not to be confused with Remediation) Resolve string `json:"resolve"` // Path: path to the issue in the file Path []string `json:"path"` // References: List of reference URLs References []string `json:"references,omitempty"` }
type InlineValue ¶
type InlineValueProvider ¶
type InlineValueProvider interface { // GetInlineValues returns inline values for a given path and range. // This should be a very fast operation. GetInlineValues(path string, myRange Range) ([]InlineValue, error) // ClearInlineValues clears inline values for a given path. ClearInlineValues(path string) }
InlineValueProvider provides inline values.
type Issue ¶
type Issue struct { // ID uniquely identifies the issue, it is intended to be human-readable ID string Severity Severity IssueType Type // Range identifies the location of this issue in its source of origin (e.g. line & character start & end) Range Range // Message is a human-readable description of the issue Message string // todo [jc] this contains a formatted longest message for hovers, this needs to be pushed up and rendered in presentation. [bd] shouldn't the content and formatting be decided by the product? FormattedMessage string // AffectedFilePath is the file path to the file where the issue was found AffectedFilePath string // Product is the Vulnmap product, e.g. Vulnmap Open Source Product product.Product // todo: can we avoid it, if it's part of a scanner interface already? // References deliver additional information References []Reference // IssueDescriptionURL contains a Uri to display more information IssueDescriptionURL *url.URL // CodeActions can contain workspace edits or commands to be executed CodeActions []CodeAction // CodelensCommands that can be executed via a codelens CodelensCommands []CommandData // The Ecosystem of the issue, e.g. npm, maven, nuget, etc. Ecosystem string // A slice of the CWEs of the issue, e.g. CWEs-79 CWEs []string // A slice of the CVEs of the issue CVEs []string // AdditionalData contains data that can be passed by the product (e.g. for presentation) AdditionalData any }
Issue models a problem, vulnerability, or situation within your code that requires your attention
func (Issue) GetFilterableIssueType ¶
func (i Issue) GetFilterableIssueType() product.FilterableIssueType
type Marker ¶
type Marker struct { Msg CodePoint `json:"msg"` Pos []MarkerPosition `json:"pos"` }
type MarkerPosition ¶
type MessageAction ¶
type MessageAction string
type MessageType ¶
type MessageType int
const ( Error MessageType = 1 Warning MessageType = 2 Info MessageType = 3 )
type MockScanNotifier ¶
type MockScanNotifier struct {
// contains filtered or unexported fields
}
func NewMockScanNotifier ¶
func NewMockScanNotifier() *MockScanNotifier
func (*MockScanNotifier) ErrorCalls ¶
func (m *MockScanNotifier) ErrorCalls() []string
func (*MockScanNotifier) InProgressCalls ¶
func (m *MockScanNotifier) InProgressCalls() []string
func (*MockScanNotifier) SendError ¶
func (m *MockScanNotifier) SendError(product product.Product, folderPath string)
func (*MockScanNotifier) SendInProgress ¶
func (m *MockScanNotifier) SendInProgress(folderPath string)
func (*MockScanNotifier) SendSuccess ¶
func (m *MockScanNotifier) SendSuccess(product product.Product, folderPath string, issues []Issue)
func (*MockScanNotifier) SendSuccessForAllProducts ¶
func (m *MockScanNotifier) SendSuccessForAllProducts(folderPath string, issues []Issue)
func (*MockScanNotifier) SuccessCalls ¶
func (m *MockScanNotifier) SuccessCalls() []string
type OssIssueData ¶
type OssIssueData struct { Key string `json:"key"` Title string `json:"title"` Name string `json:"name"` LineNumber int `json:"lineNumber"` Description string `json:"description"` References []Reference `json:"references,omitempty"` Version string `json:"version"` License string `json:"license,omitempty"` PackageManager string `json:"packageManager"` PackageName string `json:"packageName"` From []string `json:"from"` FixedIn []string `json:"fixedIn,omitempty"` UpgradePath []any `json:"upgradePath,omitempty"` IsUpgradable bool `json:"isUpgradable,omitempty"` CVSSv3 string `json:"CVSSv3,omitempty"` CvssScore float64 `json:"cvssScore,omitempty"` Exploit string `json:"exploit,omitempty"` IsPatchable bool `json:"isPatchable"` ProjectName string `json:"projectName"` DisplayTargetFile string `json:"displayTargetFile"` Language string `json:"language"` Details string `json:"details"` }
type PackageScanner ¶
type Position ¶
type ProductScanner ¶
type ProductScanner interface { // Scan scans a workspace folder or file for issues, given its path. 'folderPath' provides a path to a workspace folder, if a file needs to be scanned. Scan( ctx context.Context, path string, folderPath string, ) (issues []Issue, err error) IsEnabled() bool Product() product.Product }
type Range ¶
type Range struct { /** * The range's start position. */ Start Position /** * The range's end position. */ End Position }
type ScanNotifier ¶
type ScanResultProcessor ¶
type ScanResultProcessor = func(scanData ScanData)
type Scanner ¶
type Scanner interface { // Scan scans a workspace folder or file for issues, given its path. 'folderPath' provides a path to a workspace folder, if a file needs to be scanned. Scan( ctx context.Context, path string, processResults ScanResultProcessor, folderPath string, ) Init() error }
func NewDelegatingScanner ¶
func NewDelegatingScanner( initializer initialize.Initializer, instrumentor performance.Instrumentor, analytics ux2.Analytics, scanNotifier ScanNotifier, vulnmapApiClient vulnmap_api.VulnmapApiClient, authService AuthenticationService, notifier notification.Notifier, scanners ...ProductScanner, ) Scanner
type ShowMessageRequest ¶
type ShowMessageRequest struct { Message string `json:"message"` Type MessageType `json:"type"` Actions *data_structure.OrderedMap[MessageAction, CommandData] `json:"actions"` }
type TestProductScanner ¶
type TestProductScanner struct {
// contains filtered or unexported fields
}
func NewTestProductScanner ¶
func NewTestProductScanner(product product.Product, enabled bool) *TestProductScanner
func (*TestProductScanner) GetInlineValues ¶
func (t *TestProductScanner) GetInlineValues(_ string, _ Range) ([]InlineValue, error)
func (*TestProductScanner) IsEnabled ¶
func (t *TestProductScanner) IsEnabled() bool
func (*TestProductScanner) Product ¶
func (t *TestProductScanner) Product() product.Product
func (*TestProductScanner) Scans ¶
func (t *TestProductScanner) Scans() int
func (*TestProductScanner) SetScanDuration ¶
func (t *TestProductScanner) SetScanDuration(duration time.Duration)
type TestScanner ¶
type TestScanner struct { Issues []Issue // contains filtered or unexported fields }
func NewTestScanner ¶
func NewTestScanner() *TestScanner
func (*TestScanner) AddTestIssue ¶
func (s *TestScanner) AddTestIssue(issue Issue)
func (*TestScanner) Calls ¶
func (s *TestScanner) Calls() int
func (*TestScanner) Init ¶
func (s *TestScanner) Init() error
func (*TestScanner) IsEnabled ¶
func (s *TestScanner) IsEnabled() bool
func (*TestScanner) Product ¶
func (s *TestScanner) Product() product.Product
func (*TestScanner) Scan ¶
func (s *TestScanner) Scan( _ context.Context, _ string, processResults ScanResultProcessor, _ string, )
type Type ¶
type Type int8
Type of issue, these will typically match 1o1 to Vulnmap product lines but are not necessarily coupled to those.
type WorkspaceEdit ¶
Source Files ¶
- auth_provider.go
- auth_service.go
- auth_service_impl.go
- authentication_functions.go
- codeaction.go
- command.go
- edit.go
- inline_value.go
- issues.go
- message.go
- product.go
- provider_fake.go
- range.go
- scan_notifier.go
- scan_notifier_mock.go
- scan_result_processor.go
- scanner.go
- test_product_scanner.go
- test_scanner.go