Documentation
¶
Index ¶
- type Registry
- func (r *Registry) AcceptRule(ctx context.Context, project, ruleID string) error
- func (r *Registry) Delete(ctx context.Context, project, name string) error
- func (r *Registry) DeleteRule(ctx context.Context, project, ruleID string) error
- func (r *Registry) ExportRules(ctx context.Context, sources []string) ([]Rule, error)
- func (r *Registry) Get(ctx context.Context, project, name string) (*Spec, error)
- func (r *Registry) GetRule(ctx context.Context, project, ruleID string) (*Rule, error)
- func (r *Registry) ImportRules(ctx context.Context, rules []Rule) (int, error)
- func (r *Registry) List(ctx context.Context, project string) ([]Summary, error)
- func (r *Registry) ListAllRules(ctx context.Context, project, stack, source, status string) ([]Rule, error)
- func (r *Registry) ListRules(ctx context.Context, project string) ([]Rule, error)
- func (r *Registry) ProposeRule(ctx context.Context, rule Rule) error
- func (r *Registry) Put(ctx context.Context, project, name string, data []byte) (*Spec, error)
- func (r *Registry) PutRules(ctx context.Context, project string, rules []Rule) error
- func (r *Registry) RejectRule(ctx context.Context, project, ruleID string) error
- func (r *Registry) Validate(ctx context.Context, project string, req ValidateRequest) ([]Violation, error)
- type Rule
- type Spec
- type Summary
- type ValidateRequest
- type Violation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry provides CRUD operations on the specs table.
func (*Registry) AcceptRule ¶
AcceptRule sets a proposed rule's status to accepted.
func (*Registry) DeleteRule ¶
DeleteRule removes a single validation rule.
func (*Registry) ExportRules ¶
ExportRules returns all rules matching the given sources across all projects.
func (*Registry) Get ¶
Get retrieves a spec by project and name. Returns sql.ErrNoRows if not found.
func (*Registry) ImportRules ¶
ImportRules bulk-inserts rules, using UPSERT to avoid conflicts.
func (*Registry) ListAllRules ¶
func (r *Registry) ListAllRules(ctx context.Context, project, stack, source, status string) ([]Rule, error)
ListAllRules returns rules across all projects with optional filters.
func (*Registry) ProposeRule ¶
ProposeRule inserts a rule with source=learned, status=proposed.
func (*Registry) RejectRule ¶
RejectRule sets a proposed rule's status to rejected.
type Rule ¶
type Rule struct {
Project string `json:"project"`
RuleID string `json:"rule_id"`
Severity string `json:"severity"`
MatchType string `json:"match_type"`
Pattern string `json:"pattern"`
Message string `json:"message"`
Stack string `json:"stack"`
AppliesTo []string `json:"applies_to"`
Source string `json:"source"`
Status string `json:"status"`
ProposedBy string `json:"proposed_by,omitempty"`
Context string `json:"context,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
}
Rule is a validation rule.
type Spec ¶
type Spec struct {
Project string `json:"project"`
Name string `json:"name"`
Data []byte `json:"-"`
Version int64 `json:"version"`
Hash string `json:"hash"`
UpdatedAt time.Time `json:"updated_at"`
}
Spec is a full specification entry including its data.
type Summary ¶
type Summary struct {
Name string `json:"name"`
Version int64 `json:"version"`
UpdatedAt time.Time `json:"updated_at"`
}
Summary is a spec entry without its data, used for listing.
type ValidateRequest ¶
type ValidateRequest struct {
Filename string `json:"filename"`
Content string `json:"content"`
Stack string `json:"stack"`
}
ValidateRequest holds the content to validate.