Documentation
¶
Index ¶
- type ActionType
- type CheckResult
- type CheckStatus
- type GitHubIntegration
- func (g *GitHubIntegration) AnalyzePR(ctx context.Context, blastResults []*analysis.EnhancedBlastRadius) (*PRAnalysisResult, error)
- func (g *GitHubIntegration) CreateCheckResult(result *PRAnalysisResult) CheckResult
- func (g *GitHubIntegration) FormatGitLabComment(result *PRAnalysisResult) string
- func (g *GitHubIntegration) FormatPRComment(result *PRAnalysisResult) string
- func (g *GitHubIntegration) GenerateActionOutput(result *PRAnalysisResult) map[string]string
- type PRAnalysisResult
- type RequiredAction
- type RiskLevel
- type SymbolAnalysis
- type ThresholdConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionType ¶
type ActionType string
ActionType represents the action to take for a symbol.
const ( ActionBlock ActionType = "BLOCK" ActionReview ActionType = "REVIEW" ActionOK ActionType = "OK" )
type CheckResult ¶
type CheckResult struct {
// Status is the check status.
Status CheckStatus `json:"status"`
// Title is the check title.
Title string `json:"title"`
// Summary is a brief summary.
Summary string `json:"summary"`
// Details is the full details.
Details string `json:"details"`
}
CheckResult represents the result of a CI check.
type CheckStatus ¶
type CheckStatus string
CheckStatus represents the status of a check.
const ( CheckStatusSuccess CheckStatus = "success" CheckStatusFailure CheckStatus = "failure" CheckStatusWarning CheckStatus = "warning" )
type GitHubIntegration ¶
type GitHubIntegration struct {
// contains filtered or unexported fields
}
GitHubIntegration provides GitHub Actions integration for blast radius.
func NewGitHubIntegration ¶
func NewGitHubIntegration(thresholds *ThresholdConfig) *GitHubIntegration
NewGitHubIntegration creates a new GitHub integration.
func (*GitHubIntegration) AnalyzePR ¶
func (g *GitHubIntegration) AnalyzePR(ctx context.Context, blastResults []*analysis.EnhancedBlastRadius) (*PRAnalysisResult, error)
AnalyzePR analyzes a pull request's blast radius.
Inputs ¶
- ctx: Context for cancellation.
- blastResults: Blast radius results for each changed symbol.
Outputs ¶
- *PRAnalysisResult: Analysis result for the PR.
- error: Non-nil on failure.
func (*GitHubIntegration) CreateCheckResult ¶
func (g *GitHubIntegration) CreateCheckResult(result *PRAnalysisResult) CheckResult
CreateCheckResult creates a check result from PR analysis.
func (*GitHubIntegration) FormatGitLabComment ¶
func (g *GitHubIntegration) FormatGitLabComment(result *PRAnalysisResult) string
FormatGitLabComment generates a GitLab MR comment.
func (*GitHubIntegration) FormatPRComment ¶
func (g *GitHubIntegration) FormatPRComment(result *PRAnalysisResult) string
FormatPRComment generates a GitHub PR comment with blast radius summary.
SECURITY: All symbol names are escaped in markdown code spans to prevent markdown injection attacks.
Inputs ¶
- result: The PR analysis result.
Outputs ¶
- string: Formatted markdown comment.
func (*GitHubIntegration) GenerateActionOutput ¶
func (g *GitHubIntegration) GenerateActionOutput(result *PRAnalysisResult) map[string]string
GenerateActionOutput generates GitHub Actions output variables.
Inputs ¶
- result: The PR analysis result.
Outputs ¶
- map[string]string: Output variables for GitHub Actions.
type PRAnalysisResult ¶
type PRAnalysisResult struct {
// ChangedSymbols are the symbols directly modified in the PR.
ChangedSymbols []SymbolAnalysis `json:"changed_symbols"`
// TotalCallers is the total number of affected callers.
TotalCallers int `json:"total_callers"`
// RiskLevel is the overall risk level of the PR.
RiskLevel RiskLevel `json:"risk_level"`
// SecurityPaths indicates if security-sensitive code is affected.
SecurityPaths []string `json:"security_paths,omitempty"`
// RequiredActions are actions that must be taken before merge.
RequiredActions []RequiredAction `json:"required_actions,omitempty"`
// Recommendations are suggested actions.
Recommendations []string `json:"recommendations,omitempty"`
// Blocked indicates if the PR should be blocked.
Blocked bool `json:"blocked"`
// BlockReason explains why the PR is blocked.
BlockReason string `json:"block_reason,omitempty"`
}
PRAnalysisResult contains the blast radius analysis for a pull request.
type RequiredAction ¶
type RequiredAction struct {
// Description of the action.
Description string `json:"description"`
// Assignee is who should take the action (if known).
Assignee string `json:"assignee,omitempty"`
// Reason explains why this action is required.
Reason string `json:"reason"`
}
RequiredAction represents an action that must be taken.
type SymbolAnalysis ¶
type SymbolAnalysis struct {
// SymbolID is the unique identifier.
SymbolID string `json:"symbol_id"`
// Name is the symbol name.
Name string `json:"name"`
// FilePath is the file containing the symbol.
FilePath string `json:"file_path"`
// CallerCount is the number of direct callers.
CallerCount int `json:"caller_count"`
// TransitiveCount is the number of transitive callers.
TransitiveCount int `json:"transitive_count"`
// RiskLevel is the risk level for this symbol.
RiskLevel RiskLevel `json:"risk_level"`
// SecurityPaths are security paths through this symbol.
SecurityPaths []string `json:"security_paths,omitempty"`
// Action is the recommended action.
Action ActionType `json:"action"`
}
SymbolAnalysis contains analysis for a single changed symbol.
type ThresholdConfig ¶
type ThresholdConfig struct {
// BlockCallerThreshold blocks if any symbol has more than this many callers.
// Default: 50
BlockCallerThreshold int `json:"block_caller_threshold"`
// WarnCallerThreshold warns if any symbol has more than this many callers.
// Default: 20
WarnCallerThreshold int `json:"warn_caller_threshold"`
// BlockSecurityPaths blocks if security-sensitive paths are affected.
// Default: true
BlockSecurityPaths bool `json:"block_security_paths"`
// RequireOwnerApproval requires CODEOWNERS approval for affected files.
// Default: true
RequireOwnerApproval bool `json:"require_owner_approval"`
// MaxTransitiveDepth limits transitive analysis depth.
// Default: 5
MaxTransitiveDepth int `json:"max_transitive_depth"`
}
ThresholdConfig configures block/warn thresholds.
func DefaultThresholdConfig ¶
func DefaultThresholdConfig() ThresholdConfig
DefaultThresholdConfig returns sensible defaults.