Documentation
¶
Overview ¶
Package github provides a GitHub connector for the OpenCTEM SDK.
Index ¶
- Constants
- type CWE
- type CodeScanningAlert
- type Config
- type Connector
- func (c *Connector) Connect(ctx context.Context) error
- func (c *Connector) GetCodeScanningAlerts(ctx context.Context, owner, repo string, page, perPage int) ([]CodeScanningAlert, error)
- func (c *Connector) GetDependabotAlerts(ctx context.Context, owner, repo string, page, perPage int) ([]DependabotAlert, error)
- func (c *Connector) ListRepositories(ctx context.Context, page, perPage int) ([]Repository, error)
- func (c *Connector) Organization() string
- func (c *Connector) TestConnection(ctx context.Context) error
- type DependabotAlert
- type Dependency
- type Instance
- type Location
- type Message
- type Package
- type Repository
- type Rule
- type SecurityAdvisory
- type SecurityVulnerability
- type Tool
Constants ¶
const ( // DefaultBaseURL is the default GitHub API base URL. DefaultBaseURL = "https://api.github.com" // DefaultRateLimit is the default rate limit for GitHub API (5000 req/hour for authenticated). DefaultRateLimit = 5000 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CodeScanningAlert ¶
type CodeScanningAlert struct {
Number int `json:"number"`
State string `json:"state"`
Rule Rule `json:"rule"`
Tool Tool `json:"tool"`
MostRecentInstance Instance `json:"most_recent_instance"`
HTMLURL string `json:"html_url"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
CodeScanningAlert represents a GitHub code scanning alert.
type Config ¶
type Config struct {
// Token is the GitHub personal access token or app token.
Token string `yaml:"token" json:"token"`
// Organization to scope operations to (optional).
Organization string `yaml:"organization" json:"organization"`
// BaseURL for GitHub API (default: https://api.github.com).
BaseURL string `yaml:"base_url" json:"base_url"`
// RateLimit in requests per hour (default: 5000 for authenticated users).
RateLimit int `yaml:"rate_limit" json:"rate_limit"`
// Verbose enables debug logging.
Verbose bool `yaml:"verbose" json:"verbose"`
}
Config holds GitHub connector configuration.
type Connector ¶
type Connector struct {
*connectors.BaseConnector
// contains filtered or unexported fields
}
Connector is a GitHub API connector with rate limiting and authentication.
func NewConnector ¶
NewConnector creates a new GitHub connector.
func (*Connector) GetCodeScanningAlerts ¶
func (c *Connector) GetCodeScanningAlerts(ctx context.Context, owner, repo string, page, perPage int) ([]CodeScanningAlert, error)
GetCodeScanningAlerts retrieves code scanning alerts for a repository.
func (*Connector) GetDependabotAlerts ¶
func (c *Connector) GetDependabotAlerts(ctx context.Context, owner, repo string, page, perPage int) ([]DependabotAlert, error)
GetDependabotAlerts retrieves Dependabot alerts for a repository.
func (*Connector) ListRepositories ¶
ListRepositories lists repositories for the organization.
func (*Connector) Organization ¶
Organization returns the configured organization.
type DependabotAlert ¶
type DependabotAlert struct {
Number int `json:"number"`
State string `json:"state"`
Dependency Dependency `json:"dependency"`
SecurityAdvisory SecurityAdvisory `json:"security_advisory"`
SecurityVulnerability SecurityVulnerability `json:"security_vulnerability"`
HTMLURL string `json:"html_url"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
DependabotAlert represents a GitHub Dependabot alert.
type Dependency ¶
type Dependency struct {
Package Package `json:"package"`
ManifestPath string `json:"manifest_path"`
Scope string `json:"scope"`
}
Dependency in a Dependabot alert.
type Instance ¶
type Instance struct {
Ref string `json:"ref"`
State string `json:"state"`
CommitSHA string `json:"commit_sha"`
Message Message `json:"message"`
Location Location `json:"location"`
}
Instance represents a code scanning alert instance.
type Location ¶
type Location struct {
Path string `json:"path"`
StartLine int `json:"start_line"`
EndLine int `json:"end_line"`
StartColumn int `json:"start_column"`
EndColumn int `json:"end_column"`
}
Location of a code scanning alert.
type Repository ¶
type Repository struct {
ID int64 `json:"id"`
Name string `json:"name"`
FullName string `json:"full_name"`
Description string `json:"description"`
Private bool `json:"private"`
HTMLURL string `json:"html_url"`
CloneURL string `json:"clone_url"`
DefaultBranch string `json:"default_branch"`
Language string `json:"language"`
Archived bool `json:"archived"`
Disabled bool `json:"disabled"`
Visibility string `json:"visibility"`
}
Repository represents a GitHub repository.
type Rule ¶
type Rule struct {
ID string `json:"id"`
Severity string `json:"severity"`
Description string `json:"description"`
Name string `json:"name"`
Tags []string `json:"tags"`
}
Rule represents a code scanning rule.
type SecurityAdvisory ¶
type SecurityAdvisory struct {
GHSAID string `json:"ghsa_id"`
CVEID string `json:"cve_id"`
Summary string `json:"summary"`
Description string `json:"description"`
Severity string `json:"severity"`
CVSSScore float64 `json:"cvss_score,omitempty"`
CWEs []CWE `json:"cwes"`
}
SecurityAdvisory in a Dependabot alert.
type SecurityVulnerability ¶
type SecurityVulnerability struct {
Package Package `json:"package"`
Severity string `json:"severity"`
VulnerableVersionRange string `json:"vulnerable_version_range"`
FirstPatchedVersion *struct {
Identifier string `json:"identifier"`
} `json:"first_patched_version"`
}
SecurityVulnerability in a Dependabot alert.