Documentation
¶
Index ¶
- Constants
- Variables
- func ContainsSubstring(target string, substrings []string) bool
- func ForEveryStringWithBoundedGoroutines(limit int, values []interface{}, f func(i int, value interface{}))
- func GetPluginVersions(pluginsDir, pluginType string) map[string]PluginMeta
- func HasFlags(flags *pflag.FlagSet) bool
- func IsInList(target string, list []string) bool
- func PrintResultAsJSON(logger hclog.Logger, result interface{})
- func StructToMap(data interface{}) (map[string]string, error)
- func WithPlugin(cfg *config.Config, loggerName, pluginType, pluginName string, ...) error
- func WriteGenericResult(cfg *config.Config, logger hclog.Logger, result GenericLaunchesResult, ...) error
- type GenericLaunchesResult
- type GenericResult
- type ListFuncResult
- type PRParams
- type PluginMeta
- type Reference
- type RepositoryParams
- type Scanner
- type ScannerPlugin
- type ScannerRPCClient
- type ScannerRPCServer
- type ScannerScanRequest
- type ScannerScanResponse
- type User
- type VCS
- type VCSAddCommentToPRRequest
- type VCSAddRoleToPRRequest
- type VCSFetchRequest
- type VCSFetchResponse
- type VCSListRepositoriesRequest
- type VCSListRepositoriesResponse
- type VCSPlugin
- type VCSRPCClient
- func (c *VCSRPCClient) AddCommentToPR(req VCSAddCommentToPRRequest) (bool, error)
- func (c *VCSRPCClient) AddRoleToPR(req VCSAddRoleToPRRequest) (bool, error)
- func (c *VCSRPCClient) Fetch(req VCSFetchRequest) (VCSFetchResponse, error)
- func (c *VCSRPCClient) ListRepositories(req VCSListRepositoriesRequest) ([]RepositoryParams, error)
- func (c *VCSRPCClient) RetrievePRInformation(req VCSRetrievePRInformationRequest) (PRParams, error)
- func (c *VCSRPCClient) SetStatusOfPR(req VCSSetStatusOfPRRequest) (bool, error)
- func (c *VCSRPCClient) Setup(configData config.Config) (bool, error)
- type VCSRPCServer
- func (s *VCSRPCServer) AddCommentToPR(args VCSAddCommentToPRRequest, resp *bool) error
- func (s *VCSRPCServer) AddRoleToPR(args VCSAddRoleToPRRequest, resp *bool) error
- func (s *VCSRPCServer) Fetch(args VCSFetchRequest, resp *VCSFetchResponse) error
- func (s *VCSRPCServer) ListRepositories(args VCSListRepositoriesRequest, resp *VCSListRepositoriesResponse) error
- func (s *VCSRPCServer) RetrievePRInformation(args VCSRetrievePRInformationRequest, resp *VCSRetrievePRInformationResponse) error
- func (s *VCSRPCServer) SetStatusOfPR(args VCSSetStatusOfPRRequest, resp *bool) error
- func (s *VCSRPCServer) Setup(configData config.Config, resp *bool) error
- type VCSRequestBase
- type VCSRetrievePRInformationRequest
- type VCSRetrievePRInformationResponse
- type VCSSetStatusOfPRRequest
- type Versions
Constants ¶
const ( PluginTypeVCS = "vcs" PluginTypeScanner = "scanner" )
Variables ¶
var HandshakeConfig = plugin.HandshakeConfig{
ProtocolVersion: 1,
MagicCookieKey: "SCANIO",
MagicCookieValue: "a65de33ff91e68ab6f5cd1fd5abb1235294816f5",
}
var PluginMap = map[string]plugin.Plugin{ PluginTypeVCS: &VCSPlugin{}, PluginTypeScanner: &ScannerPlugin{}, }
PluginMap defines the available plugins.
Functions ¶
func ContainsSubstring ¶
func ForEveryStringWithBoundedGoroutines ¶
func ForEveryStringWithBoundedGoroutines(limit int, values []interface{}, f func(i int, value interface{}))
ForEveryStringWithBoundedGoroutines limits the number of concurrent goroutines and executes the provided function.
func GetPluginVersions ¶ added in v0.2.0
func GetPluginVersions(pluginsDir, pluginType string) map[string]PluginMeta
GetPluginVersions iterates through the plugin directories and reads their version files.
func PrintResultAsJSON ¶ added in v0.3.0
func PrintResultAsJSON(logger hclog.Logger, result interface{})
PrintResultAsJSON serializes the result as JSON and prints it.
func StructToMap ¶ added in v0.2.0
StructToMap converts a struct to a map[string]string using reflection.
func WithPlugin ¶
func WithPlugin(cfg *config.Config, loggerName, pluginType, pluginName string, f func(interface{}) error) error
WithPlugin initializes the plugin client, sets up the plugin, and executes the provided function.
func WriteGenericResult ¶ added in v0.2.0
func WriteGenericResult(cfg *config.Config, logger hclog.Logger, result GenericLaunchesResult, commandName string) error
WriteGenericResult writes the provided result to a JSON file.
Types ¶
type GenericLaunchesResult ¶
type GenericLaunchesResult struct {
Launches []GenericResult `json:"launches"`
}
GenericLaunchesResult represents a list of launches.
type GenericResult ¶
type GenericResult struct { Args interface{} `json:"args"` Result interface{} `json:"result"` Status string `json:"status"` Message string `json:"message"` }
GenericResult represents the result of a generic operation.
type ListFuncResult ¶
type ListFuncResult struct { Args VCSListRepositoriesRequest `json:"args"` Result []RepositoryParams `json:"result"` Status string `json:"status"` Message string `json:"message"` }
ListFuncResult holds the result of a list function.
type PRParams ¶
type PRParams struct { ID int `json:"id"` Title string `json:"title"` Description string `json:"description"` State string `json:"state"` Author User `json:"author"` SelfLink string `json:"self_link"` Source Reference `json:"source"` Destination Reference `json:"destination"` CreatedDate int64 `json:"created_date"` UpdatedDate int64 `json:"updated_date"` }
PRParams holds the details of a pull request.
type PluginMeta ¶ added in v0.2.0
PluginMeta holds version information for a plugin.
type Reference ¶ added in v0.2.0
type Reference struct { ID string `json:"id"` DisplayID string `json:"display_id"` LatestCommit string `json:"latest_commit"` }
Reference holds the details of a reference in a repository.
type RepositoryParams ¶
type RepositoryParams struct { Domain string `json:"domain,omitempty"` Namespace string `json:"namespace,omitempty"` Repository string `json:"repository,omitempty"` Branch string `json:"branch,omitempty"` PullRequestID string `json:"pull_request_id,omitempty"` HTTPLink string `json:"http_link,omitempty"` SSHLink string `json:"ssh_link,omitempty"` }
RepositoryParams holds the details of a repository.
type Scanner ¶
type Scanner interface { Setup(configData config.Config) (bool, error) Scan(args ScannerScanRequest) (ScannerScanResponse, error) }
Scanner defines the interface for scanner-related operations.
type ScannerPlugin ¶
type ScannerPlugin struct {
Impl Scanner
}
ScannerPlugin is the implementation of the plugin.Plugin interface for scanners.
func (*ScannerPlugin) Client ¶
func (p *ScannerPlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error)
Client returns an RPC client for the Scanner plugin.
func (*ScannerPlugin) Server ¶
func (p *ScannerPlugin) Server(*plugin.MuxBroker) (interface{}, error)
Server returns an RPC server for the Scanner plugin.
type ScannerRPCClient ¶
type ScannerRPCClient struct {
// contains filtered or unexported fields
}
ScannerRPCClient implements the Scanner interface for RPC clients.
func (*ScannerRPCClient) Scan ¶
func (c *ScannerRPCClient) Scan(req ScannerScanRequest) (ScannerScanResponse, error)
Scan calls the Scan method on the RPC client.
type ScannerRPCServer ¶
type ScannerRPCServer struct {
Impl Scanner
}
ScannerRPCServer wraps a Scanner implementation to provide an RPC server.
func (*ScannerRPCServer) Scan ¶
func (s *ScannerRPCServer) Scan(args ScannerScanRequest, resp *ScannerScanResponse) error
Scan calls the Scan method on the Scanner implementation.
type ScannerScanRequest ¶
type ScannerScanRequest struct { TargetPath string `json:"target_path"` // Path to the target to scan ResultsPath string `json:"results_path"` // Path to save the results of the scan ConfigPath string `json:"config_path"` // Path to the configuration file for the scanner ReportFormat string `json:"report_path"` // Format of the report to generate (e.g., JSON, Sarif) AdditionalArgs []string `json:"additional_args"` // Additional arguments for the scanner }
ScannerScanRequest represents a single scan request.
type ScannerScanResponse ¶
type ScannerScanResponse struct {
ResultsPath string `json:"results_path"` // Path to the saved results of the scan
}
ScannerScanResponse represents the response from a scan plugin.
type VCS ¶
type VCS interface { Setup(configData config.Config) (bool, error) Fetch(req VCSFetchRequest) (VCSFetchResponse, error) ListRepositories(req VCSListRepositoriesRequest) ([]RepositoryParams, error) RetrievePRInformation(req VCSRetrievePRInformationRequest) (PRParams, error) AddRoleToPR(req VCSAddRoleToPRRequest) (bool, error) SetStatusOfPR(req VCSSetStatusOfPRRequest) (bool, error) AddCommentToPR(req VCSAddCommentToPRRequest) (bool, error) }
VCS defines the interface for VCS-related operations.
type VCSAddCommentToPRRequest ¶
type VCSAddCommentToPRRequest struct { VCSRequestBase Comment string `json:"comment"` FilePaths []string `json:"file_paths"` }
VCSAddCommentToPRRequest represents a request to add a comment to a PR.
type VCSAddRoleToPRRequest ¶
type VCSAddRoleToPRRequest struct { VCSRequestBase Login string `json:"login"` Role string `json:"role"` }
VCSAddRoleToPRRequest represents a request to add a role to a PR.
type VCSFetchRequest ¶
type VCSFetchRequest struct { CloneURL string `json:"clone_url"` Branch string `json:"branch"` AuthType string `json:"auth_type"` SSHKey string `json:"ssh_key"` TargetFolder string `json:"target_folder"` Mode string `json:"mode"` RepoParam RepositoryParams `json:"repo_param"` }
VCSFetchRequest represents a fetch request for a VCS.
type VCSFetchResponse ¶
type VCSFetchResponse struct {
Path string `json:"path"`
}
VCSFetchResponse represents a response from a fetch request.
type VCSListRepositoriesRequest ¶ added in v0.2.0
type VCSListRepositoriesRequest struct { VCSRequestBase Language string `json:"language"` }
VCSListRepositoriesRequest represents a request to list repositories.
type VCSListRepositoriesResponse ¶ added in v0.2.0
type VCSListRepositoriesResponse struct {
Repositories []RepositoryParams `json:"repositories"`
}
VCSListRepositoriesResponse represents a response from listing repositories.
type VCSPlugin ¶
type VCSPlugin struct {
Impl VCS
}
VCSPlugin is the implementation of the plugin.Plugin interface for VCS.
type VCSRPCClient ¶
type VCSRPCClient struct {
// contains filtered or unexported fields
}
VCSRPCClient implements the VCS interface for RPC clients.
func (*VCSRPCClient) AddCommentToPR ¶ added in v0.2.0
func (c *VCSRPCClient) AddCommentToPR(req VCSAddCommentToPRRequest) (bool, error)
AddCommentToPR calls the AddCommentToPR method on the RPC client.
func (*VCSRPCClient) AddRoleToPR ¶
func (c *VCSRPCClient) AddRoleToPR(req VCSAddRoleToPRRequest) (bool, error)
AddRoleToPR calls the AddRoleToPR method on the RPC client.
func (*VCSRPCClient) Fetch ¶
func (c *VCSRPCClient) Fetch(req VCSFetchRequest) (VCSFetchResponse, error)
Fetch calls the Fetch method on the RPC client.
func (*VCSRPCClient) ListRepositories ¶ added in v0.2.0
func (c *VCSRPCClient) ListRepositories(req VCSListRepositoriesRequest) ([]RepositoryParams, error)
ListRepositories calls the ListRepositories method on the RPC client.
func (*VCSRPCClient) RetrievePRInformation ¶ added in v0.2.0
func (c *VCSRPCClient) RetrievePRInformation(req VCSRetrievePRInformationRequest) (PRParams, error)
RetrievePRInformation calls the RetrievePRInformation method on the RPC client.
func (*VCSRPCClient) SetStatusOfPR ¶
func (c *VCSRPCClient) SetStatusOfPR(req VCSSetStatusOfPRRequest) (bool, error)
SetStatusOfPR calls the SetStatusOfPR method on the RPC client.
type VCSRPCServer ¶
type VCSRPCServer struct {
Impl VCS
}
VCSRPCServer wraps a VCS implementation to provide an RPC server.
func (*VCSRPCServer) AddCommentToPR ¶ added in v0.2.0
func (s *VCSRPCServer) AddCommentToPR(args VCSAddCommentToPRRequest, resp *bool) error
AddCommentToPR calls the AddCommentToPR method on the VCS implementation.
func (*VCSRPCServer) AddRoleToPR ¶
func (s *VCSRPCServer) AddRoleToPR(args VCSAddRoleToPRRequest, resp *bool) error
AddRoleToPR calls the AddRoleToPR method on the VCS implementation.
func (*VCSRPCServer) Fetch ¶
func (s *VCSRPCServer) Fetch(args VCSFetchRequest, resp *VCSFetchResponse) error
Fetch calls the Fetch method on the VCS implementation.
func (*VCSRPCServer) ListRepositories ¶ added in v0.2.0
func (s *VCSRPCServer) ListRepositories(args VCSListRepositoriesRequest, resp *VCSListRepositoriesResponse) error
ListRepositories calls the ListRepositories method on the VCS implementation.
func (*VCSRPCServer) RetrievePRInformation ¶ added in v0.2.0
func (s *VCSRPCServer) RetrievePRInformation(args VCSRetrievePRInformationRequest, resp *VCSRetrievePRInformationResponse) error
RetrievePRInformation calls the RetrievePRInformation method on the VCS implementation.
func (*VCSRPCServer) SetStatusOfPR ¶
func (s *VCSRPCServer) SetStatusOfPR(args VCSSetStatusOfPRRequest, resp *bool) error
SetStatusOfPR calls the SetStatusOfPR method on the VCS implementation.
type VCSRequestBase ¶
type VCSRequestBase struct { RepoParam RepositoryParams `json:"repo_param"` Action string `json:"action"` }
VCSRequestBase is the base structure for VCS requests.
type VCSRetrievePRInformationRequest ¶ added in v0.2.0
type VCSRetrievePRInformationRequest struct {
VCSRequestBase
}
VCSRetrievePRInformationRequest represents a request to retrieve PR information.
type VCSRetrievePRInformationResponse ¶ added in v0.2.0
type VCSRetrievePRInformationResponse struct {
PR PRParams `json:"pr"`
}
VCSRetrievePRInformationResponse represents a response from retrieving PR information.
type VCSSetStatusOfPRRequest ¶
type VCSSetStatusOfPRRequest struct { VCSRequestBase Login string `json:"login"` Status string `json:"status"` Comment string `json:"comment"` }
VCSSetStatusOfPRRequest represents a request to set the status of a PR.