Documentation
¶
Overview ¶
Package permissions defines the permissions configuration model and the access-control checks (tools, entity operations, analyzers, responders and filters) applied to TheHive MCP requests.
Index ¶
- func GetDefaultPermissions() ([]byte, error)
- func MergeFilters(userQuery, permissionFilters map[string]any) (map[string]any, bool)
- func Validate(config *Config) error
- type AutomationPermissions
- type Config
- func (c *Config) GetAllowedAnalyzers(allAnalyzers []string) []string
- func (c *Config) GetAllowedResponders(allResponders []string) []string
- func (c *Config) GetToolFilters(toolName string) map[string]any
- func (c *Config) IsAnalyzerAllowed(analyzerName string) bool
- func (c *Config) IsEntityOperationAllowed(entityType, operation string) bool
- func (c *Config) IsResponderAllowed(responderName string) bool
- func (c *Config) IsToolAllowed(toolName string) bool
- type EntityOperation
- type PermissionInfo
- type Section
- type ToolPermission
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetDefaultPermissions ¶
GetDefaultPermissions returns the embedded default read-only permissions
func MergeFilters ¶
MergeFilters ANDs permission filters into the user query; the bool reports whether any were applied.
Types ¶
type AutomationPermissions ¶
type AutomationPermissions struct {
Mode string `yaml:"mode"` // "allow_list" or "block_list"
Allowed []string `yaml:"allowed"`
Blocked []string `yaml:"blocked"`
}
AutomationPermissions defines analyzer or responder access
type Config ¶
Config represents the complete permissions configuration
func LoadAdminForTesting ¶
func LoadAdminForTesting() *Config
LoadAdminForTesting returns an admin permissions configuration for testing purposes
func LoadDefault ¶
LoadDefault loads the embedded default read-only permissions
func LoadFromFile ¶
LoadFromFile loads and parses a permissions configuration from a file
func (*Config) GetAllowedAnalyzers ¶
GetAllowedAnalyzers returns list of allowed analyzer names
func (*Config) GetAllowedResponders ¶
GetAllowedResponders returns list of allowed responder names
func (*Config) GetToolFilters ¶
GetToolFilters returns the filters for a specific tool
func (*Config) IsAnalyzerAllowed ¶
IsAnalyzerAllowed checks if an analyzer is permitted based on global rules
func (*Config) IsEntityOperationAllowed ¶
IsEntityOperationAllowed reports whether operation is permitted on entityType. With no entity-specific permissions configured, defaults to the tool's general allowed setting.
func (*Config) IsResponderAllowed ¶
IsResponderAllowed checks if a responder is permitted based on global rules
func (*Config) IsToolAllowed ¶
IsToolAllowed reports whether toolName is permitted; unknown tools and a nil config deny.
type EntityOperation ¶
type EntityOperation struct {
Create bool `yaml:"create"`
Update bool `yaml:"update"`
Delete bool `yaml:"delete"`
Comment bool `yaml:"comment"`
Promote bool `yaml:"promote"`
Merge bool `yaml:"merge"`
ApplyTemplate bool `yaml:"apply-template"`
}
EntityOperation defines which operations are allowed for an entity type
type PermissionInfo ¶
type PermissionInfo struct {
Applied bool `json:"applied"`
FilterApplied bool `json:"filter_applied,omitempty"`
Message string `json:"message,omitempty"`
Restrictions []string `json:"restrictions,omitempty"`
}
PermissionInfo describes how permissions affected a response
func NewPermissionInfo ¶
func NewPermissionInfo() PermissionInfo
NewPermissionInfo creates a PermissionInfo with applied=false
func NewPermissionInfoDenied ¶
func NewPermissionInfoDenied(message string) PermissionInfo
NewPermissionInfoDenied creates a PermissionInfo for a denied operation
func NewPermissionInfoFiltered ¶
func NewPermissionInfoFiltered(message string) PermissionInfo
NewPermissionInfoFiltered creates a PermissionInfo for a filtered operation
func NewPermissionInfoRestricted ¶
func NewPermissionInfoRestricted(restrictions []string) PermissionInfo
NewPermissionInfoRestricted creates a PermissionInfo with restrictions list
type Section ¶ added in v1.0.0
type Section struct {
Tools map[string]ToolPermission `yaml:"tools"`
Analyzers AutomationPermissions `yaml:"analyzers"`
Responders AutomationPermissions `yaml:"responders"`
}
Section contains all permission categories
type ToolPermission ¶
type ToolPermission struct {
Allowed bool `yaml:"allowed"`
Filters map[string]any `yaml:"filters,omitempty"`
EntityPermissions map[string]EntityOperation `yaml:"entity_permissions,omitempty"` // For manage-entities tool
}
ToolPermission defines access and filtering for a specific tool