Documentation
¶
Index ¶
- func BuildInstallURL(appSlug string, state string, redirectURI string) (string, error)
- func NormalizeAppSlug(value string) (string, error)
- func NormalizeBaseURL(value string) (string, error)
- func ParsePrivateKey(privateKeyPEM string) (*rsa.PrivateKey, error)
- func SignAppJWT(creds AppCredentials, now time.Time) (string, error)
- func ValidatePATShape(token string) error
- func VerifyWebhookSignature(secret string, payload []byte, signature string) bool
- type AppCredentials
- type CodeScanningAlert
- type CodeScanningAlertInstance
- type CodeScanningLocation
- type CodeScanningMessage
- type CodeScanningRule
- type CodeScanningTool
- type GitHubRateLimitState
- type InstallationEvent
- type InstallationRepositoriesEvent
- type InstallationToken
- type InstallationTokenClient
- type InstallationTokenMinter
- type PATValidationResult
- type PATValidator
- type Repository
- type RepositoryClient
- func (c RepositoryClient) CollectRepositoryPosture(ctx context.Context, installationID int64, repository string) (RepositoryPosture, error)
- func (c RepositoryClient) ListCodeScanningAlerts(ctx context.Context, installationID int64, repository string) ([]CodeScanningAlert, error)
- func (c RepositoryClient) ListInstallationRepositories(ctx context.Context, installationID int64) ([]Repository, error)
- type RepositoryPosture
- type RepositoryPostureCheck
- type RepositoryPostureState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildInstallURL ¶
BuildInstallURL returns the GitHub App installation URL with an opaque state.
func NormalizeAppSlug ¶
NormalizeAppSlug validates the GitHub App slug used in install URLs.
func NormalizeBaseURL ¶
NormalizeBaseURL validates and canonicalizes the GitHub Enterprise base URL.
func ParsePrivateKey ¶
func ParsePrivateKey(privateKeyPEM string) (*rsa.PrivateKey, error)
ParsePrivateKey parses a PEM-encoded RSA private key in PKCS#1 or PKCS#8 form.
func SignAppJWT ¶
func SignAppJWT(creds AppCredentials, now time.Time) (string, error)
SignAppJWT signs a short-lived RS256 JWT accepted by GitHub App APIs.
func ValidatePATShape ¶
ValidatePATShape checks whether a token looks like a GitHub classic PAT.
Types ¶
type AppCredentials ¶
AppCredentials contains the non-tenant GitHub App credentials used by the hosted SaaS connector flow.
type CodeScanningAlert ¶
type CodeScanningAlert struct {
Number int `json:"number"`
State string `json:"state"`
Rule CodeScanningRule `json:"rule"`
Tool CodeScanningTool `json:"tool"`
MostRecentInstance CodeScanningAlertInstance `json:"most_recent_instance"`
HTMLURL string `json:"html_url"`
}
CodeScanningAlert is the GitHub API shape needed for repository finding ingestion.
type CodeScanningAlertInstance ¶
type CodeScanningAlertInstance struct {
Ref string `json:"ref"`
AnalysisKey string `json:"analysis_key"`
Category string `json:"category"`
State string `json:"state"`
CommitSHA string `json:"commit_sha"`
Message CodeScanningMessage `json:"message"`
Location CodeScanningLocation `json:"location"`
}
type CodeScanningLocation ¶
type CodeScanningMessage ¶
type CodeScanningMessage struct {
Text string `json:"text"`
}
type CodeScanningRule ¶
type CodeScanningTool ¶
type GitHubRateLimitState ¶
type GitHubRateLimitState struct {
Limit int `json:"limit,omitempty"`
Remaining int `json:"remaining,omitempty"`
ResetAt *time.Time `json:"reset_at,omitempty"`
}
GitHubRateLimitState captures the latest observed GitHub REST rate-limit headers for posture calls.
type InstallationEvent ¶
InstallationEvent is the subset of GitHub installation webhooks Identrail needs to bind and clean up GitHub App connectors.
func ParseInstallationEvent ¶
func ParseInstallationEvent(payload []byte) (InstallationEvent, error)
ParseInstallationEvent extracts the action, installation id, and account.
type InstallationRepositoriesEvent ¶
type InstallationRepositoriesEvent struct {
Action string
InstallationID int64
AddedRepositories []string
RemovedRepositories []string
}
InstallationRepositoriesEvent is the subset of GitHub repository-selection webhooks needed to keep connector repository allowlists current.
func ParseInstallationRepositoriesEvent ¶
func ParseInstallationRepositoriesEvent(payload []byte) (InstallationRepositoriesEvent, error)
ParseInstallationRepositoriesEvent extracts added and removed repositories from an installation_repositories webhook.
type InstallationToken ¶
InstallationToken represents one GitHub App installation token response.
type InstallationTokenClient ¶
type InstallationTokenClient struct {
Credentials AppCredentials
HTTPClient *http.Client
APIBaseURL string
Now func() time.Time
// contains filtered or unexported fields
}
InstallationTokenClient mints and caches installation tokens.
func (*InstallationTokenClient) Mint ¶
func (c *InstallationTokenClient) Mint(ctx context.Context, installationID int64) (InstallationToken, error)
Mint returns a cached token unless it is close to expiry.
type InstallationTokenMinter ¶
type InstallationTokenMinter interface {
Mint(ctx context.Context, installationID int64) (InstallationToken, error)
}
InstallationTokenMinter mints GitHub App installation access tokens.
type PATValidationResult ¶
PATValidationResult captures the minimum identity and scope proof for a PAT.
type PATValidator ¶
PATValidator validates classic GitHub PATs against GitHub.com or GHES.
func (PATValidator) Validate ¶
func (v PATValidator) Validate(ctx context.Context, baseURL string, token string) (PATValidationResult, error)
Validate confirms the token is accepted and has read-oriented repository scope.
func (PATValidator) ValidateGitHubPAT ¶
func (v PATValidator) ValidateGitHubPAT(ctx context.Context, baseURL string, token string) (PATValidationResult, error)
ValidateGitHubPAT adapts PATValidator to the API service dependency.
type Repository ¶
Repository describes the GitHub repository metadata Identrail needs for selection and scan target storage.
type RepositoryClient ¶
type RepositoryClient struct {
TokenClient InstallationTokenMinter
HTTPClient *http.Client
APIBaseURL string
Now func() time.Time
}
RepositoryClient lists repositories visible to one GitHub App installation.
func (RepositoryClient) CollectRepositoryPosture ¶
func (c RepositoryClient) CollectRepositoryPosture(ctx context.Context, installationID int64, repository string) (RepositoryPosture, error)
CollectRepositoryPosture collects normalized security posture from GitHub API endpoints that require an installation token. Each endpoint contributes a check even when the setting is unavailable or permission-limited.
func (RepositoryClient) ListCodeScanningAlerts ¶
func (c RepositoryClient) ListCodeScanningAlerts(ctx context.Context, installationID int64, repository string) ([]CodeScanningAlert, error)
ListCodeScanningAlerts returns all open GitHub code-scanning alerts for a repository.
func (RepositoryClient) ListInstallationRepositories ¶
func (c RepositoryClient) ListInstallationRepositories(ctx context.Context, installationID int64) ([]Repository, error)
ListInstallationRepositories returns all repositories available to the installation, following GitHub pagination.
type RepositoryPosture ¶
type RepositoryPosture struct {
Repository string `json:"repository"`
InstallationID int64 `json:"installation_id,omitempty"`
CollectedAt time.Time `json:"collected_at"`
Checks []RepositoryPostureCheck `json:"checks"`
RateLimit *GitHubRateLimitState `json:"rate_limit,omitempty"`
}
RepositoryPosture describes GitHub-hosted repository security settings that are not visible from git content alone.
type RepositoryPostureCheck ¶
type RepositoryPostureCheck struct {
ID string `json:"id"`
Category string `json:"category"`
State RepositoryPostureState `json:"state"`
Reason string `json:"reason,omitempty"`
Summary string `json:"summary"`
Evidence map[string]any `json:"evidence,omitempty"`
}
RepositoryPostureCheck is one normalized GitHub repository posture signal.
type RepositoryPostureState ¶
type RepositoryPostureState string
RepositoryPostureState is a normalized posture state for one GitHub control.
const ( RepositoryPostureStateSecure RepositoryPostureState = "secure" RepositoryPostureStateInsecure RepositoryPostureState = "insecure" RepositoryPostureStatePermissionLimited RepositoryPostureState = "permission_limited" )