client

package
v1.40.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScannerLabelKDT             = "kdt"
	ScannerLabelBind            = "bind"
	ScannerLabelAgent           = "agent"
	ScannerLabelDocker          = "docker"
	ScannerLabelImport          = "import"
	ScannerLabelTemplate        = "template"
	ScannerLabelCreatableOnTool = "creatable-on-tool"
)
View Source
const ReleaseStatusHistoryInprogress = "in_progress"

Variables

View Source
var (
	ProductNotFound = errors.New("product not found")
	ProjectNotFound = errors.New("project not found")
)

Functions

func IsRescanOnlyLabel added in v1.0.22

func IsRescanOnlyLabel(label string, isForkScan bool) bool

IsRescanOnlyLabel returns true if the given label is a rescan only label If fork scan is true, then the ScannerLabelTemplate label is not a rescan only label, it can be used for fork scan

Types

type ActiveScanners added in v1.0.22

type ActiveScanners []ScannerInfo

func (ActiveScanners) First added in v1.0.22

func (s ActiveScanners) First() *ScannerInfo

First returns the first element in the list.

type Agent added in v1.0.22

type Agent struct {
	ID       string `json:"id"`
	Label    string `json:"label"`
	Url      string `json:"url"`
	AgentId  string `json:"agent_id"`
	Password string `json:"password"`
	Insecure bool   `json:"insecure"`
	IsActive int    `json:"isActive"`
}

type AgentSearchParams added in v1.0.22

type AgentSearchParams struct {
	Limit int    `url:"limit"`
	Label string `url:"label"`
}

type Agents added in v1.0.22

type Agents []Agent

func (Agents) First added in v1.0.22

func (a Agents) First() Agent

type AgentsResponse added in v1.0.22

type AgentsResponse struct {
	ActiveAgents Agents `json:"active_agents"`
	Total        int    `json:"total"`
}

type Client

type Client struct {
	BaseURL *url.URL
	// contains filtered or unexported fields
}

func New

func New() (*Client, error)

func (*Client) CreateLabel added in v1.0.29

func (c *Client) CreateLabel(label Label) error

func (*Client) CreateNewScan added in v1.0.22

func (c *Client) CreateNewScan(scan *Scan) (string, error)

func (*Client) CreateProduct added in v1.0.22

func (c *Client) CreateProduct(pd ProductDetail) (*Product, error)

func (*Client) CreateProject added in v1.0.22

func (c *Client) CreateProject(pd ProjectDetail) (*Project, error)

func (*Client) CreateScanparams added in v1.0.22

func (c *Client) CreateScanparams(pID string, sp ScanparamsDetail) (*Scanparams, error)

func (*Client) CreateTeam added in v1.0.22

func (c *Client) CreateTeam(teamName string, issueResponsible IssueResponsible) error

func (*Client) FindAgentByLabel added in v1.0.22

func (c *Client) FindAgentByLabel(l string) (*Agent, error)

func (*Client) FindProductByName added in v1.0.22

func (c *Client) FindProductByName(name string) (*Product, error)

func (*Client) FindProjectByName added in v1.0.22

func (c *Client) FindProjectByName(name string) (*Project, error)

func (*Client) FindScan added in v1.0.9

func (c *Client) FindScan(project string, params *ScanSearchParams) (*ScanDetail, error)

func (*Client) FindScanByID added in v1.0.22

func (c *Client) FindScanByID(id string) (*ScanDetail, error)

func (*Client) FindScanparams added in v1.0.22

func (c *Client) FindScanparams(project string, params *ScanparamSearchParams) (*Scanparams, error)

func (*Client) GetLastResults added in v1.0.9

func (c *Client) GetLastResults(id string) (map[string]*ResultSet, error)

func (*Client) GetProductDetail added in v1.0.22

func (c *Client) GetProductDetail(id string) (*ProductDetail, error)

func (*Client) GetScanStatus

func (c *Client) GetScanStatus(eventId string) (*Event, error)

func (*Client) HealthCheck added in v1.0.22

func (c *Client) HealthCheck() error

HealthCheck is a healthcheck for Kondukto service Requires a valid API token

func (*Client) ImportSBOM added in v1.0.22

func (c *Client) ImportSBOM(file string, repo string, form ImportForm) error

func (*Client) ImportScanResult added in v1.0.9

func (c *Client) ImportScanResult(file string, form ImportForm) (string, error)

func (*Client) IsAvailable added in v1.0.22

func (c *Client) IsAvailable(project, almTool string) (bool, error)

func (*Client) IsValidTool added in v1.0.22

func (c *Client) IsValidTool(tool string) (*ScannerInfo, bool)

IsValidTool returns true if the given tool name is a valid tool

func (*Client) ListActiveAgents added in v1.0.22

func (c *Client) ListActiveAgents(params *AgentSearchParams) (*AgentsResponse, error)

func (*Client) ListActiveScanners added in v1.0.22

func (c *Client) ListActiveScanners(input *ListActiveScannersInput) (*ScannersResponse, error)

ListActiveScanners returns a list of active scanners

func (*Client) ListProducts added in v1.0.22

func (c *Client) ListProducts(name string) ([]Product, error)

func (*Client) ListProjects

func (c *Client) ListProjects(name, repo string) ([]Project, error)

func (*Client) ListScans

func (c *Client) ListScans(project string, params *ScanSearchParams) ([]ScanDetail, error)

func (*Client) Ping added in v1.0.22

func (c *Client) Ping() error

Ping is a healthcheck for Kondukto service Does not require a valid API token

func (*Client) ReleaseStatus added in v1.0.9

func (c *Client) ReleaseStatus(project, branch string, opts ...ReleaseStatusOpts) (*ReleaseStatus, error)

func (*Client) RestartScanByScanID added in v1.0.22

func (c *Client) RestartScanByScanID(id string) (string, error)

func (*Client) RestartScanWithOption added in v1.0.22

func (c *Client) RestartScanWithOption(id string, opt *ScanRestartOptions) (string, error)

func (*Client) ScanByImage added in v1.0.22

func (c *Client) ScanByImage(pr *ScanByImageInput) (string, error)

func (*Client) UpdateProduct added in v1.0.22

func (c *Client) UpdateProduct(id string, pd ProductDetail) (*Product, error)

type Custom added in v1.0.22

type Custom struct {
	Type   int                    `json:"type" bson:"type"`
	Params map[string]interface{} `json:"params" bson:"params"`
}

type Event

type Event struct {
	ID         string `json:"id"`
	Status     int    `json:"status"`
	Active     int    `json:"active"`
	ScanID     string `json:"scan_id"`
	StatusText string `json:"status_text"`
	Message    string `json:"message"`
	Links      struct {
		HTML string `json:"html"`
	} `json:"links"`
}

type ImageScanParams added in v1.0.22

type ImageScanParams struct {
	Project     string `json:"project"`
	Tool        string `json:"tool"`
	Branch      string `json:"branch"`
	Image       string `json:"image"`
	MetaData    string `json:"meta_data"`
	Environment string `json:"environment"`
}

type ImportForm added in v1.0.22

type ImportForm map[string]string

type IssueResponsible added in v1.0.22

type IssueResponsible struct {
	ID       string `json:"id,omitempty"`
	Username string `json:"username,omitempty"`
}

type KonduktoError added in v1.0.22

type KonduktoError struct {
	Error string `json:"error"`
}

type Label added in v1.0.29

type Label struct {
	Name  string `json:"name"`
	Color string `json:"color"`
}

type ListActiveScannersInput added in v1.0.33

type ListActiveScannersInput struct {
	Types  []ScannerType
	Labels string
	Name   string
	Limit  int
}

type PRInfo added in v1.0.22

type PRInfo struct {
	// OK means that the merge target is a valid branch to merge the source branch changes into.
	OK                       bool   `json:"ok" json:"ok"`
	MergeTarget              string `json:"target" bson:"target" valid:"Branch"`
	PRNumber                 string `json:"pr_number"`
	NoDecoration             bool   `json:"no_decoration"`
	PRDecorationScannerTypes string `json:"pr_decoration_scanner_types"`
}

type PathScope added in v1.0.34

type PathScope struct {
	IncludeEmpty  bool   `json:"include_empty"`
	IncludedPaths string `json:"included_paths"`
	IncludedFiles string `json:"included_files"`
}

type PlaybookTypeDetail added in v1.0.22

type PlaybookTypeDetail struct {
	Status string `json:"status" bson:"status"`
	ScanID string `json:"scan_id,omitempty" bson:"scan_id"`
}

type Product added in v1.0.22

type Product struct {
	ID            string `json:"id,omitempty"`
	Name          string `json:"name,omitempty"`
	ProjectsCount int    `json:"projects_count"`
	Links         struct {
		HTML string `json:"html"`
	} `json:"links"`
}

func (*Product) FieldsAsRow added in v1.0.22

func (p *Product) FieldsAsRow() []string

type ProductDetail added in v1.0.22

type ProductDetail struct {
	ID               string    `json:"id"`
	Name             string    `json:"name"`
	Projects         []Project `json:"projects"`
	BusinessUnitTags []struct {
		ID       string `json:"id"`
		Name     string `json:"name"`
		Color    string `json:"color"`
		IsActive int    `json:"isActive"`
		Required bool   `json:"required"`
	} `json:"business_unit_tags"`
	AccessibleFor struct {
		OwnerIDs []string `json:"owner_ids"`
		TeamIDs  []string `json:"team_ids"`
	} `json:"accessible_for"`
	DefaultTeam struct {
		ID string `json:"id"`
	} `json:"default_team"`
}

type Project

type Project struct {
	ID            string         `json:"id,omitempty"`
	Name          string         `json:"name,omitempty"`
	DefaultBranch string         `json:"default_branch"`
	Labels        []ProjectLabel `json:"labels"`
	Team          ProjectTeam    `json:"team"`
	Links         struct {
		HTML string `json:"html"`
	} `json:"links"`
}

func (*Project) FieldsAsRow added in v1.0.22

func (p *Project) FieldsAsRow() []string

func (*Project) LabelsAsString added in v1.0.22

func (p *Project) LabelsAsString() string

type ProjectDetail added in v1.0.22

type ProjectDetail struct {
	Name      string         `json:"name"`
	Source    ProjectSource  `json:"source"`
	Team      ProjectTeam    `json:"team"`
	Labels    []ProjectLabel `json:"labels"`
	Override  bool           `json:"override"`  // That means, if the project already exists, create a new one with suffix "-"
	Overwrite bool           `json:"overwrite"` // That means, if the project already exists, overwrite it
	// ForkSourceBranch holds the name of the branch to be used as the source for the fork scan.
	// It is only used for [feature] environment
	ForkSourceBranch string `json:"fork_source_branch"`
	// FeatureBranchRetention holds the number of days to delete the feature branch after the latest scan.
	FeatureBranchRetention uint `json:"feature_branch_retention"`
	// FeatureBranchInfiniteRetention holds a value that disables the feature branch retention period.
	FeatureBranchInfiniteRetention bool   `json:"feature_branch_no_retention"`
	DefaultBranch                  string `json:"default_branch"`
	CriticalityLevel               int    `json:"criticality_level"`
}

type ProjectLabel added in v1.0.22

type ProjectLabel struct {
	ID   string `json:"id,omitempty"`
	Name string `json:"name"`
}

type ProjectSource added in v1.0.22

type ProjectSource struct {
	Tool          string    `json:"tool"`
	ID            string    `json:"id"`
	URL           string    `json:"url"`
	CloneDisabled bool      `json:"clone_disabled"`
	PathScope     PathScope `json:"path_scope"`
}

type ProjectTeam added in v1.0.22

type ProjectTeam struct {
	ID   string `json:"id,omitempty"`
	Name string `json:"name"`
}

type ReleaseStatus added in v1.0.9

type ReleaseStatus struct {
	ProgressStatus string             `json:"progress_status"`
	Status         string             `json:"status"`
	SAST           PlaybookTypeDetail `json:"sast"`
	DAST           PlaybookTypeDetail `json:"dast"`
	PENTEST        PlaybookTypeDetail `json:"pentest"`
	IAST           PlaybookTypeDetail `json:"iast"`
	SCA            PlaybookTypeDetail `json:"sca"`
	CS             PlaybookTypeDetail `json:"cs"`
	IAC            PlaybookTypeDetail `json:"iac"`
	MAST           PlaybookTypeDetail `json:"mast"`
	INFRA          PlaybookTypeDetail `json:"infra"`
}

type ReleaseStatusOpts added in v1.0.35

type ReleaseStatusOpts struct {
	WaitTillComplete           bool
	TotalWaitDurationToTimeout time.Duration
	WaitDuration               time.Duration
}

type ResultSet added in v1.0.9

type ResultSet struct {
	Score   int      `json:"score"`
	Summary *Summary `json:"summary"`
}

type Scan

type Scan struct {
	// ScanparamsID is holding identifier of scanparams, when given, it will override other fields
	ScanparamsID string `json:"scanparams_id,omitempty"`
	// Branch is holding current branch value of scan
	Branch string `json:"branch"`
	// Project is holding ID or Name value of project
	Project string `json:"project"`
	// ToolID is holding ID value of selected scanner
	ToolID string `json:"tool_id,omitempty"`
	// AgentID is holding ID value of selected agent
	AgentID string `json:"agent_id,omitempty"`
	// PR is holding detail of pull requests branches to be scanned
	PR PRInfo `json:"pr"`
	// Custom is holding custom type of scanners that specified on the Kondukto side
	Custom Custom `json:"custom"`
	// MetaData is holding value of scanparam meta-data
	MetaData string `json:"meta_data"`
	// ForkScan is holding value of baseline scan
	ForkScan bool `json:"fork_scan"`
	// ForkSourceBranch is holding value of baseline scan branch
	ForkSourceBranch string `json:"fork_source_branch"`
	// OverrideForkSourceBranch is holding value of baseline scan branch
	OverrideForkSourceBranch bool `json:"override_fork_source_branch"`
	// Environment is holding value of application environment
	Environment string `json:"environment"`
}

type ScanByImageInput added in v1.0.33

type ScanByImageInput struct {
	Project     string
	Tool        string
	Branch      string
	Image       string
	MetaData    string
	Environment string
}

type ScanDetail added in v1.0.22

type ScanDetail struct {
	ID                   string     `json:"id"`
	Name                 string     `json:"name"`
	Branch               string     `json:"branch"`
	ScanType             string     `json:"scan_type"`
	MetaData             string     `json:"meta_data"`
	Tool                 string     `json:"tool"`
	ScannerType          string     `json:"scanner_type"`
	Date                 *time.Time `json:"date"`
	Project              string     `json:"project"`
	Score                int        `json:"score"`
	Summary              Summary    `json:"summary"`
	InfraSourceProjectID string     `json:"infra_source_project_id"`
	Links                struct {
		HTML string `json:"html"`
	} `json:"links"`
}

type ScanRestartOptions added in v1.0.38

type ScanRestartOptions struct {
	// MergeSourceBranch is source branch of the PR. It is required when PR is true
	MergeSourceBranch string `json:"from"`
	// MergeTargetBranch is target branch of the PR. It is required when PR is true
	MergeTargetBranch        string `json:"to"`
	OverrideOldAnalyze       bool   `json:"override_old_analyze"`
	PRNumber                 string `json:"pr_number"`
	NoDecoration             bool   `json:"no_decoration"`
	PRDecorationScannerTypes string `json:"pr_decoration_scanner_types"`
	Custom                   Custom `json:"custom"`
	Environment              string `url:"environment"`
}

type ScanSearchParams added in v1.0.9

type ScanSearchParams struct {
	Branch           string `url:"branch,omitempty"`
	Tool             string `url:"tool,omitempty"`
	MetaData         string `url:"meta_data"`
	PR               bool   `url:"pr"`
	Manual           bool   `url:"manual"`
	AgentID          string `url:"agent_id"`
	Environment      string `url:"environment"`
	ForkScan         bool   `url:"fork_scan"`
	ForkSourceBranch string `url:"fork_source_branch"`
	Limit            int    `url:"limit,omitempty"`
}

type ScannerCustomParams added in v1.0.22

type ScannerCustomParams struct {
	Examples     string                  `json:"examples,omitempty"`
	Description  string                  `json:"description"`
	DefaultValue string                  `json:"default_value"`
	Optional     bool                    `json:"optional"`
	Type         scannerCustomParamsType `json:"type"`
}

ScannerCustomParams holds the details of a custom parameter

func (ScannerCustomParams) Parse added in v1.0.22

func (s ScannerCustomParams) Parse(k string) (interface{}, error)

Parse parses the given string into expected type

type ScannerInfo added in v1.0.22

type ScannerInfo struct {
	ID          string        `json:"id"`
	Type        string        `json:"type"`
	Slug        string        `json:"slug"`
	DisplayName string        `json:"display_name"`
	Labels      []string      `json:"labels"`
	CustomType  int           `json:"custom_type"`
	Disabled    bool          `json:"disabled"`
	Params      ScannerParams `json:"params"`
}

func (ScannerInfo) HasLabel added in v1.0.22

func (s ScannerInfo) HasLabel(l string) bool

HasLabel returns true if the given label is present in the receiver's labels

type ScannerParams added in v1.0.22

type ScannerParams map[string]ScannerCustomParams

ScannerParams holds the custom parameters for a scanner

func (ScannerParams) Find added in v1.0.22

Find returns the given key detail when present, otherwise nil.

func (ScannerParams) RequiredParamsLen added in v1.0.22

func (s ScannerParams) RequiredParamsLen() int

RequiredParamsLen returns the required params length.

type ScannerType added in v1.0.33

type ScannerType string
const (
	ScannerTypeSAST  ScannerType = "sast"
	ScannerTypeDAST  ScannerType = "dast"
	ScannerTypeSCA   ScannerType = "sca"
	ScannerTypeCS    ScannerType = "cs"
	ScannerTypeIAC   ScannerType = "iac"
	ScannerTypeIAST  ScannerType = "iast"
	ScannerTypeCSPM  ScannerType = "cspm"
	ScannerTypeMAST  ScannerType = "mast"
	ScannerTypeINFRA ScannerType = "infra"
)

func ScannerTypes added in v1.0.33

func ScannerTypes() []ScannerType

func (ScannerType) String added in v1.0.33

func (s ScannerType) String() string

type ScannersResponse added in v1.0.22

type ScannersResponse struct {
	ActiveScanners ActiveScanners `json:"active_scanners"`
	Total          int            `json:"total"`
}

type ScannersSearchParams added in v1.0.22

type ScannersSearchParams struct {
	Types  string `url:"types"`
	Labels string `url:"labels"`
	Name   string `url:"name"`
	Limit  int    `url:"limit"`
}

type ScanparamResponse added in v1.0.22

type ScanparamResponse struct {
	Scanparams []Scanparams `json:"scanparams"`
	Limit      int          `json:"limit"`
	Start      int          `json:"start"`
	Total      int          `json:"total"`
}

type ScanparamSearchParams added in v1.0.22

type ScanparamSearchParams struct {
	ToolID           string `url:"tool_id"`
	Branch           string `url:"branch"`
	Limit            int    `url:"limit"`
	MetaData         string `url:"meta_data"`
	Target           string `url:"target"`
	Manual           bool   `url:"manual"`
	Agent            string `url:"agent"`
	Environment      string `url:"environment"`
	ForkScan         bool   `url:"fork_scan"`
	ForkSourceBranch string `url:"fork_source_branch"`
	PR               bool   `url:"pr"`
}

type Scanparams added in v1.0.22

type Scanparams struct {
	ID       string  `json:"id"`
	Branch   string  `json:"branch"`
	BindName string  `json:"bind_name"`
	Custom   *Custom `json:"custom"`
}

type ScanparamsDetail added in v1.0.22

type ScanparamsDetail struct {
	Tool        *ScanparamsItem `json:"tool"`
	Project     *ScanparamsItem `json:"project"`
	Agent       *ScanparamsItem `json:"agent"`
	BindName    string          `json:"bind_name"`
	Branch      string          `json:"branch"`
	ScanType    string          `json:"scan_type"`
	MetaData    string          `json:"meta_data"`
	ForkScan    bool            `json:"fork_scan"`
	PR          PRInfo          `json:"pr"`
	Manual      bool            `json:"manual"`
	Custom      Custom          `json:"custom"`
	Environment string          `json:"environment"`
}

type ScanparamsItem added in v1.0.22

type ScanparamsItem struct {
	ID string `json:"id,omitempty"`
}

type Summary added in v1.0.9

type Summary struct {
	Critical int `json:"critical"`
	High     int `json:"high"`
	Medium   int `json:"medium"`
	Low      int `json:"low"`
	Info     int `json:"info"`
}

type Team added in v1.0.22

type Team struct {
	Name             string           `json:"name"`
	IssueResponsible IssueResponsible `json:"issue_responsible"`
}

Jump to

Keyboard shortcuts

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