shared

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2024 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 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 Args

type Args interface {
}

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"`
}

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"`
}

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 ProjectParams

type ProjectParams struct {
	Key  string
	Name string
	Link string
}

type Reference added in v0.2.0

type Reference struct {
	ID           string
	DisplayId    string
	LatestCommit string
}

type RepositoryParams

type RepositoryParams struct {
	VCSUrl        string `json:"vcs_url,omitempty"`
	Namespace     string `json:"namespace"`
	Repository    string `json:"repository"`
	PullRequestId string `json:"pull_request_id,omitempty"`
	HTTPLink      string `json:"http_link,omitempty"`
	SSHLink       string `json:"ssh_link"`
}

type Result

type Result interface {
}

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   // Path to the target to scan
	ResultsPath    string   // Path to save the results of the scan
	ConfigPath     string   // Path to the configuration file for the scanner
	ReportFormat   string   // Format of the report to generate (e.g., JSON, Sarif)
	AdditionalArgs []string // Additional arguments for the scanner
}

ScannerScanRequest represents a single scan request.

type ScannerScanResponse

type ScannerScanResponse struct {
	ResultsPath string // 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 {
	DisplayName string `json:"display_name"`
	Email       string `json:"email"`
}

type VCS

type VCS interface {
	Setup(configData config.Config) (bool, error)
	Fetch(req VCSFetchRequest) (VCSFetchResponse, error)
	ListRepositories(args VCSListRepositoriesRequest) ([]RepositoryParams, error)
	RetrievePRInformation(req VCSRetrievePRInformationRequest) (PRParams, error)
	AddRoleToPR(req VCSAddRoleToPRRequest) (bool, error)
	SetStatusOfPR(req VCSSetStatusOfPRRequest) (bool, error)
	AddCommentToPR(req VCSAddCommentToPRRequest) (bool, error)
}

type VCSAddCommentToPRRequest

type VCSAddCommentToPRRequest struct {
	VCSRequestBase
	Comment   string
	FilePaths []string
}

type VCSAddRoleToPRRequest

type VCSAddRoleToPRRequest struct {
	VCSRequestBase
	Login string
	Role  string
}

type VCSFetchRequest

type VCSFetchRequest struct {
	CloneURL     string
	Branch       string
	AuthType     string
	SSHKey       string
	TargetFolder string
	Mode         string
	RepoParam    RepositoryParams
}

type VCSFetchResponse

type VCSFetchResponse struct {
	Path string
}

type VCSListRepositoriesRequest added in v0.2.0

type VCSListRepositoriesRequest struct {
	Namespace  string
	VCSURL     string
	Repository string
	Language   string
}

type VCSListRepositoriesResponse added in v0.2.0

type VCSListRepositoriesResponse struct {
	Repositories []RepositoryParams
}

type VCSPlugin

type VCSPlugin struct {
	Impl VCS
}

func (VCSPlugin) Client

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

func (*VCSPlugin) Server

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

type VCSRPCClient

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

func (*VCSRPCClient) AddCommentToPR added in v0.2.0

func (g *VCSRPCClient) AddCommentToPR(req VCSAddCommentToPRRequest) (bool, error)

func (*VCSRPCClient) AddRoleToPR

func (g *VCSRPCClient) AddRoleToPR(req VCSAddRoleToPRRequest) (bool, error)

func (*VCSRPCClient) Fetch

func (*VCSRPCClient) ListRepositories added in v0.2.0

func (g *VCSRPCClient) ListRepositories(req VCSListRepositoriesRequest) ([]RepositoryParams, error)

func (*VCSRPCClient) RetrievePRInformation added in v0.2.0

func (g *VCSRPCClient) RetrievePRInformation(req VCSRetrievePRInformationRequest) (PRParams, error)

func (*VCSRPCClient) SetStatusOfPR

func (g *VCSRPCClient) SetStatusOfPR(req VCSSetStatusOfPRRequest) (bool, error)

func (*VCSRPCClient) Setup added in v0.2.0

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

type VCSRPCServer

type VCSRPCServer struct {
	Impl VCS
}

func (*VCSRPCServer) AddCommentToPR added in v0.2.0

func (*VCSRPCServer) AddRoleToPR

func (*VCSRPCServer) Fetch

func (s *VCSRPCServer) Fetch(args VCSFetchRequest, resp *VCSFetchResponse) error

func (*VCSRPCServer) ListRepositories added in v0.2.0

func (*VCSRPCServer) RetrievePRInformation added in v0.2.0

func (*VCSRPCServer) SetStatusOfPR

func (*VCSRPCServer) Setup added in v0.2.0

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

type VCSRequestBase

type VCSRequestBase struct {
	Namespace     string
	VCSURL        string
	Action        string
	Repository    string
	PullRequestId int
}

type VCSRetrievePRInformationRequest added in v0.2.0

type VCSRetrievePRInformationRequest struct {
	VCSRequestBase
}

type VCSRetrievePRInformationResponse added in v0.2.0

type VCSRetrievePRInformationResponse struct {
	PR PRParams
}

type VCSSetStatusOfPRRequest

type VCSSetStatusOfPRRequest struct {
	VCSRequestBase
	Login  string
	Status string
}

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