Documentation
¶
Index ¶
- func ValidateLocalPolicy(p *LocalPolicy) error
- func ValidatePolicy(p *RemotePolicy) error
- type Cache
- func (c *Cache) Clear() error
- func (c *Cache) GetFromDisk(url string) (*RemotePolicy, *CacheMetadata, error)
- func (c *Cache) GetFromMemory(url string) *RemotePolicy
- func (c *Cache) KeyFor(url string) string
- func (c *Cache) SaveToDisk(url string, policy *RemotePolicy, policyData []byte, etag string) error
- func (c *Cache) SetInMemory(url string, policy *RemotePolicy)
- type CacheMetadata
- type CommitMessageRule
- type EvalResult
- type Fetcher
- type ForbiddenContentPattern
- type LocalPolicy
- type MergedPolicy
- type PolicyRef
- type PolicyRules
- type Registry
- type RemotePolicy
- type UserConfig
- type Violation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateLocalPolicy ¶
func ValidateLocalPolicy(p *LocalPolicy) error
func ValidatePolicy ¶
func ValidatePolicy(p *RemotePolicy) error
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
func (*Cache) GetFromDisk ¶
func (c *Cache) GetFromDisk(url string) (*RemotePolicy, *CacheMetadata, error)
func (*Cache) GetFromMemory ¶
func (c *Cache) GetFromMemory(url string) *RemotePolicy
func (*Cache) SaveToDisk ¶
func (*Cache) SetInMemory ¶
func (c *Cache) SetInMemory(url string, policy *RemotePolicy)
type CacheMetadata ¶
type CommitMessageRule ¶
type EvalResult ¶
func Evaluate ¶
func Evaluate(rules *PolicyRules, files []string, commitMsg string) EvalResult
func (EvalResult) String ¶
func (r EvalResult) String() string
type Fetcher ¶
type Fetcher struct {
// contains filtered or unexported fields
}
func NewFetcher ¶
func (*Fetcher) ClearCache ¶
func (*Fetcher) LoadPolicy ¶
func (f *Fetcher) LoadPolicy(url string) (*RemotePolicy, error)
type ForbiddenContentPattern ¶
type LocalPolicy ¶
type LocalPolicy struct {
Name string `json:"name" yaml:"name"`
Version string `json:"version" yaml:"version"`
Description string `json:"description" yaml:"description"`
Rules PolicyRules `json:"rules" yaml:"rules"`
Metadata map[string]string `json:"metadata" yaml:"metadata"`
}
func (*LocalPolicy) Identifier ¶
func (p *LocalPolicy) Identifier() string
type MergedPolicy ¶
type MergedPolicy struct {
RemotePolicies []RemotePolicy
LocalPolicies []LocalPolicy
EffectiveRules PolicyRules
}
type PolicyRules ¶
type PolicyRules struct {
ForbidFiles []string `json:"forbid_files" yaml:"forbid_files"`
ForbidDirectories []string `json:"forbid_directories" yaml:"forbid_directories"`
ForbidFileExtensions []string `json:"forbid_file_extensions" yaml:"forbid_file_extensions"`
RequiredFiles []string `json:"required_files" yaml:"required_files"`
MaxFileSizeKB int `json:"max_file_size_kb" yaml:"max_file_size_kb"`
MaxFilesChanged int `json:"max_files_changed" yaml:"max_files_changed"`
ForbidFileContent []ForbiddenContentPattern `json:"forbid_file_content" yaml:"forbid_file_content"`
RegexBlock []string `json:"regex_block" yaml:"regex_block"`
CommitMessage *CommitMessageRule `json:"commit_message" yaml:"commit_message"`
EnforceHooks []string `json:"enforce_hooks" yaml:"enforce_hooks"`
HookTimeBudgetMs map[string]int `json:"hook_time_budget_ms" yaml:"hook_time_budget_ms"`
MaxParallelHooks int `json:"max_parallel_hooks" yaml:"max_parallel_hooks"`
}
func (*PolicyRules) Merge ¶
func (r *PolicyRules) Merge(other PolicyRules) PolicyRules
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func (*Registry) ClearCache ¶
func (*Registry) Load ¶
func (r *Registry) Load(config *UserConfig) (*MergedPolicy, error)
func (*Registry) Refresh ¶
func (r *Registry) Refresh(config *UserConfig) error
type RemotePolicy ¶
type RemotePolicy struct {
Name string `json:"name" yaml:"name"`
ID string `json:"id" yaml:"id"`
Version string `json:"version" yaml:"version"`
Description string `json:"description" yaml:"description"`
Severity string `json:"severity" yaml:"severity"`
Rules PolicyRules `json:"rules" yaml:"rules"`
Metadata map[string]string `json:"metadata" yaml:"metadata"`
}
func ParseRemotePolicy ¶
func ParseRemotePolicy(data []byte) (*RemotePolicy, error)
func (*RemotePolicy) Identifier ¶
func (p *RemotePolicy) Identifier() string
type UserConfig ¶
type UserConfig struct {
Type string `json:"type" yaml:"type"`
Policies []PolicyRef `json:"policies" yaml:"policies"`
LocalPolicies []LocalPolicy `json:"localPolicies" yaml:"localPolicies"`
}
Click to show internal directories.
Click to hide internal directories.