shared

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PluginTypeVCS     string = "vcs"
	PluginTypeScanner string = "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{},
}
View Source
var ResultBuffer bytes.Buffer
View Source
var ResultBufferMutex sync.Mutex

Functions

func CommentBuilder

func CommentBuilder(data interface{}, path string) (string, error)

func ContainsSubstring

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

func Copy

func Copy(srcPath, destPath string) error

func CopyDir

func CopyDir(srcDir, destDir string) error

func CopyFile

func CopyFile(srcFile, destFile string) error
func CopySymLink(srcLink, destLink string) error

func CreateIfNotExists

func CreateIfNotExists(path string, perm os.FileMode) error

func ExtractRepositoryInfoFromURL

func ExtractRepositoryInfoFromURL(Url string, VCSPlugName string) (string, string, string, string, string, string, error)

func ForEveryStringWithBoundedGoroutines

func ForEveryStringWithBoundedGoroutines(limit int, values []interface{}, f func(i int, value interface{}))

func GetProjectsHome

func GetProjectsHome() string

func GetRepoPath

func GetRepoPath(VCSURL, repoWithNamespace string) string

func GetResultsHome

func GetResultsHome() string

func GetScanioHome

func GetScanioHome() string

func GitClone

func GitClone(args VCSFetchRequest, variables EvnVariables, logger hclog.Logger) (string, error)

func IsCI

func IsCI() bool

func NewLogger

func NewLogger(name string) hclog.Logger

func WithPlugin

func WithPlugin(loggerName string, pluginType string, pluginName string, f func(interface{}) error) error

func WriteJsonFile

func WriteJsonFile(outputFile string, logger hclog.Logger, data ...CustomData)

Types

type Args

type Args interface {
}

type CustomData

type CustomData interface{}

type EvnVariables

type EvnVariables struct {
	Username, Token, VcsPort, SshKeyPassword string
}

type GenericLaunchesResult

type GenericLaunchesResult struct {
	Launches []GenericResult `json:"launches"`
}

type GenericResult

type GenericResult struct {
	Args    interface{} `json:"args"`
	Result  interface{} `json:"result"`
	Status  string      `json:"status"`
	Message string      `json:"message"`
}

type ListFuncResult

type ListFuncResult struct {
	Args    VCSListReposRequest `json:"args"`
	Result  []RepositoryParams  `json:"result"`
	Status  string              `json:"status"`
	Message string              `json:"message"`
}

type PRParams

type PRParams struct {
	PullRequestId int
	Title         string
	Description   string
	State         string
	AuthorEmail   string
	AuthorName    string
	SelfLink      string
	CreatedDate   int64
	UpdatedDate   int64
	FromRef       RefPRInf
	ToRef         RefPRInf
}

type ProjectParams

type ProjectParams struct {
	Key  string
	Name string
	Link string
}

type RefPRInf

type RefPRInf struct {
	ID           string
	DisplayId    string
	LatestCommit string
}

type RepositoryParams

type RepositoryParams struct {
	Namespace string `json:"namespace"`
	RepoName  string `json:"repo_name"`
	PRID      string `json:"pr_id"`
	VCSURL    string `json:"vcs_url"`
	HttpLink  string `json:"http_link"`
	SshLink   string `json:"ssh_link"`
}

type Result

type Result interface {
}

type ScanReportData

type ScanReportData struct {
	ScanStarted  bool
	ScanPassed   bool
	ScanFailed   bool
	ScanCrashed  bool
	ScanDetails  interface{}
	ScanResults  interface{}
	ErrorDetails interface{}
}

type Scanner

type Scanner interface {
	Scan(args ScannerScanRequest) (ScannerScanResponse, error)
}

type ScannerPlugin

type ScannerPlugin struct {
	Impl Scanner
}

func (ScannerPlugin) Client

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

func (*ScannerPlugin) Server

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

type ScannerRPCClient

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

func (*ScannerRPCClient) Scan

type ScannerRPCServer

type ScannerRPCServer struct {
	Impl Scanner
}

func (*ScannerRPCServer) Scan

type ScannerScanRequest

type ScannerScanRequest struct {
	RepoPath       string
	ReportFormat   string
	ConfigPath     string
	ResultsPath    string
	AdditionalArgs []string
}

type ScannerScanResponse

type ScannerScanResponse struct {
	ResultsPath string
}

type ScannerScanResult

type ScannerScanResult struct {
	Args    ScannerScanRequest
	Result  []string
	Status  string
	Message string
}

type VCS

type VCS interface {
	Fetch(req VCSFetchRequest) (VCSFetchResponse, error)
	ListRepos(args VCSListReposRequest) ([]RepositoryParams, error)
	RetrivePRInformation(req VCSRetrivePRInformationRequest) (PRParams, error)
	AddRoleToPR(req VCSAddRoleToPRRequest) (interface{}, error)
	SetStatusOfPR(req VCSSetStatusOfPRRequest) (bool, error)
	AddComment(req VCSAddCommentToPRRequest) (bool, error)
}

type VCSAddCommentToPRRequest

type VCSAddCommentToPRRequest struct {
	VCSRequestBase
	Comment 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 VCSListReposRequest

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

type VCSListReposResponse

type VCSListReposResponse 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) AddComment

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

func (*VCSRPCClient) AddRoleToPR

func (g *VCSRPCClient) AddRoleToPR(req VCSAddRoleToPRRequest) (interface{}, error)

func (*VCSRPCClient) Fetch

func (*VCSRPCClient) ListRepos

func (g *VCSRPCClient) ListRepos(req VCSListReposRequest) ([]RepositoryParams, error)

func (*VCSRPCClient) RetrivePRInformation

func (g *VCSRPCClient) RetrivePRInformation(req VCSRetrivePRInformationRequest) (PRParams, error)

func (*VCSRPCClient) SetStatusOfPR

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

type VCSRPCServer

type VCSRPCServer struct {
	Impl VCS
}

func (*VCSRPCServer) AddComment

func (*VCSRPCServer) AddRoleToPR

func (*VCSRPCServer) Fetch

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

func (*VCSRPCServer) ListRepos

func (s *VCSRPCServer) ListRepos(args VCSListReposRequest, resp *VCSListReposResponse) error

func (*VCSRPCServer) RetrivePRInformation

func (*VCSRPCServer) SetStatusOfPR

type VCSRequestBase

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

type VCSRetrivePRInformationRequest

type VCSRetrivePRInformationRequest struct {
	VCSRequestBase
}

type VCSRetrivePRInformationResponse

type VCSRetrivePRInformationResponse struct {
	PR PRParams
}

type VCSSetStatusOfPRRequest

type VCSSetStatusOfPRRequest struct {
	VCSRequestBase
	Login  string
	Status string
}

Jump to

Keyboard shortcuts

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