shared

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PluginTypeVCS     = "vcs"
	PluginTypeScanner = "scanner"
)

Variables

View Source
var HandshakeConfig = plugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "SCANIO",
	MagicCookieValue: "a65de33ff91e68ab6f5cd1fd5abb1235294816f5",
}
View Source
var PluginMap = map[string]plugin.Plugin{
	PluginTypeVCS:     &VCSPlugin{},
	PluginTypeScanner: &ScannerPlugin{},
}

PluginMap defines the available plugins.

Functions

func ContainsSubstring

func ContainsSubstring(target string, substrings []string) bool

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 HasFlags added in v0.2.0

func HasFlags(flags *pflag.FlagSet) bool

hasFlags checks if any flags have been set.

func IsInList added in v0.2.0

func IsInList(target string, list []string) bool

IsInList checks if the target string is in the list of strings.

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

func StructToMap(data interface{}) (map[string]string, error)

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

type PluginMeta struct {
	Version    string `json:"version"`
	PluginType string `json:"plugin_type"`
}

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

Scan calls the Scan method on the RPC client.

func (*ScannerRPCClient) Setup added in v0.2.0

func (c *ScannerRPCClient) Setup(configData config.Config) (bool, error)

Setup calls the Setup 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

Scan calls the Scan method on the Scanner implementation.

func (*ScannerRPCServer) Setup added in v0.2.0

func (s *ScannerRPCServer) Setup(configData config.Config, resp *bool) error

Setup calls the Setup 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 User added in v0.2.0

type User struct {
	UserName string `json:"user_name"`
	Email    string `json:"email"`
}

User holds the details of a user.

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.

func (*VCSPlugin) Client

func (p *VCSPlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error)

Client returns an RPC client for the VCS plugin.

func (*VCSPlugin) Server

func (p *VCSPlugin) Server(*plugin.MuxBroker) (interface{}, error)

Server returns an RPC server for the VCS plugin.

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

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.

func (*VCSRPCClient) Setup added in v0.2.0

func (c *VCSRPCClient) Setup(configData config.Config) (bool, error)

Setup calls the Setup 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

ListRepositories calls the ListRepositories method on the VCS implementation.

func (*VCSRPCServer) RetrievePRInformation added in v0.2.0

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.

func (*VCSRPCServer) Setup added in v0.2.0

func (s *VCSRPCServer) Setup(configData config.Config, resp *bool) error

Setup calls the Setup 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.

type Versions added in v0.2.0

type Versions struct {
	Version       string `json:"version"`
	GolangVersion string `json:"golang_version"`
	BuildTime     string `json:"build_time"`
}

Versions holds meta information for binaries.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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