github

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package github provides a GitHub connector for the OpenCTEM SDK.

Index

Constants

View Source
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 CWE

type CWE struct {
	CWEID string `json:"cwe_id"`
	Name  string `json:"name"`
}

CWE in a security advisory.

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

func NewConnector(cfg *Config) *Connector

NewConnector creates a new GitHub connector.

func (*Connector) Connect

func (c *Connector) Connect(ctx context.Context) error

Connect establishes connection to GitHub.

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

func (c *Connector) ListRepositories(ctx context.Context, page, perPage int) ([]Repository, error)

ListRepositories lists repositories for the organization.

func (*Connector) Organization

func (c *Connector) Organization() string

Organization returns the configured organization.

func (*Connector) TestConnection

func (c *Connector) TestConnection(ctx context.Context) error

TestConnection verifies the GitHub API connection.

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 Message

type Message struct {
	Text string `json:"text"`
}

Message in a code scanning alert.

type Package

type Package struct {
	Ecosystem string `json:"ecosystem"`
	Name      string `json:"name"`
}

Package in a Dependabot 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.

type Tool

type Tool struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

Tool represents a code scanning tool.

Jump to

Keyboard shortcuts

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