Documentation
¶
Index ¶
- Variables
- func GenerateReport(org string, results []RepoResult) string
- type BranchProtection
- type Config
- type FileEntry
- type GitHubClient
- type HasBranchProtection
- type HasCIWorkflow
- type HasCodeowners
- type HasGitignore
- type HasLicense
- type HasRepoDescription
- type HasRequiredReviewers
- type HasRequiredStatusChecks
- type HasSecurityMd
- type HasSubstantialReadme
- type HasTestDirectory
- type Option
- type Repo
- type RepoResult
- type Rule
- type RuleResult
Constants ¶
This section is empty.
Variables ¶
var ( ErrEmptyRepo = errors.New("repository is empty") ErrTruncatedTree = errors.New("tree truncated by GitHub API") )
Sentinel errors for per-repo scan failures.
Functions ¶
func GenerateReport ¶
func GenerateReport(org string, results []RepoResult) string
GenerateReport produces a Markdown compliance report from scan results.
Types ¶
type BranchProtection ¶
BranchProtection holds the branch protection settings the scanner needs.
type FileEntry ¶
type FileEntry struct {
Path string // full path relative to repo root (e.g., ".github/workflows/ci.yml")
Size int
Type string // "blob" (file) or "tree" (directory)
}
FileEntry represents a file or directory in a repo.
type GitHubClient ¶
type GitHubClient interface {
ListRepos(ctx context.Context, org string) ([]Repo, error)
GetTree(ctx context.Context, owner, repo, branch string) ([]FileEntry, error)
GetBranchProtection(ctx context.Context, owner, repo, branch string) (*BranchProtection, error)
GetRulesets(ctx context.Context, owner, repo, branch string) (*BranchProtection, error)
}
GitHubClient is the interface for all GitHub API interactions. The scanner depends only on this interface, making it testable via mocks.
func NewGitHubClient ¶
func NewGitHubClient(token string) GitHubClient
NewGitHubClient creates a GitHubClient that calls the public GitHub REST API.
type HasBranchProtection ¶
type HasBranchProtection struct{}
HasBranchProtection checks that the default branch has protection rules enabled.
func (HasBranchProtection) Check ¶
func (r HasBranchProtection) Check(repo Repo) bool
func (HasBranchProtection) Name ¶
func (r HasBranchProtection) Name() string
type HasCIWorkflow ¶
type HasCIWorkflow struct{}
HasCIWorkflow checks that at least one .yml or .yaml file exists under .github/workflows/.
func (HasCIWorkflow) Check ¶
func (r HasCIWorkflow) Check(repo Repo) bool
func (HasCIWorkflow) Name ¶
func (r HasCIWorkflow) Name() string
type HasCodeowners ¶
type HasCodeowners struct{}
HasCodeowners checks that a CODEOWNERS file exists in root, docs/, or .github/.
func (HasCodeowners) Check ¶
func (r HasCodeowners) Check(repo Repo) bool
func (HasCodeowners) Name ¶
func (r HasCodeowners) Name() string
type HasGitignore ¶
type HasGitignore struct{}
HasGitignore checks that a .gitignore file exists in the repo root.
func (HasGitignore) Check ¶
func (r HasGitignore) Check(repo Repo) bool
func (HasGitignore) Name ¶
func (r HasGitignore) Name() string
type HasLicense ¶
type HasLicense struct{}
HasLicense checks that a LICENSE or LICENSE.md file exists in the repo root.
func (HasLicense) Check ¶
func (r HasLicense) Check(repo Repo) bool
func (HasLicense) Name ¶
func (r HasLicense) Name() string
type HasRepoDescription ¶
type HasRepoDescription struct{}
HasRepoDescription checks that the repo description field is not blank.
func (HasRepoDescription) Check ¶
func (r HasRepoDescription) Check(repo Repo) bool
func (HasRepoDescription) Name ¶
func (r HasRepoDescription) Name() string
type HasRequiredReviewers ¶
type HasRequiredReviewers struct{}
HasRequiredReviewers checks that at least one approving review is required.
func (HasRequiredReviewers) Check ¶
func (r HasRequiredReviewers) Check(repo Repo) bool
func (HasRequiredReviewers) Name ¶
func (r HasRequiredReviewers) Name() string
type HasRequiredStatusChecks ¶
type HasRequiredStatusChecks struct{}
HasRequiredStatusChecks checks that at least one status check is required before merging.
func (HasRequiredStatusChecks) Check ¶
func (r HasRequiredStatusChecks) Check(repo Repo) bool
func (HasRequiredStatusChecks) Name ¶
func (r HasRequiredStatusChecks) Name() string
type HasSecurityMd ¶
type HasSecurityMd struct{}
HasSecurityMd checks that SECURITY.md exists in the repo root or .github/.
func (HasSecurityMd) Check ¶
func (r HasSecurityMd) Check(repo Repo) bool
func (HasSecurityMd) Name ¶
func (r HasSecurityMd) Name() string
type HasSubstantialReadme ¶
type HasSubstantialReadme struct{}
HasSubstantialReadme checks that README.md exists and is larger than 2048 bytes.
func (HasSubstantialReadme) Check ¶
func (r HasSubstantialReadme) Check(repo Repo) bool
func (HasSubstantialReadme) Name ¶
func (r HasSubstantialReadme) Name() string
type HasTestDirectory ¶
type HasTestDirectory struct{}
HasTestDirectory checks that a recognized test directory exists at the repo root.
func (HasTestDirectory) Check ¶
func (r HasTestDirectory) Check(repo Repo) bool
func (HasTestDirectory) Name ¶
func (r HasTestDirectory) Name() string
type Option ¶ added in v0.2.0
type Option func(*scanOptions)
Option configures optional scan behavior.
func WithBaseURL ¶ added in v0.2.0
WithBaseURL sets a custom GitHub API base URL. Defaults to the public GitHub API when unset. Useful for testing against a mock server or pointing at a GitHub Enterprise instance.
type Repo ¶
type Repo struct {
Name string
Description string
DefaultBranch string
Archived bool
Files []FileEntry // all files and directories in the repo
BranchProtection *BranchProtection // nil if no protection configured
}
Repo represents a GitHub repository with the fields the scanner needs.
type RepoResult ¶
type RepoResult struct {
RepoName string
Results []RuleResult
KnownSkipReason string
UnknownSkipError string
}
RepoResult holds all rule results for a single repository. KnownSkipReason and UnknownSkipError are mutually exclusive.
func (RepoResult) Skipped ¶ added in v0.2.0
func (rr RepoResult) Skipped() bool
type RuleResult ¶
RuleResult holds the outcome of a single rule check for a single repo.