permissions

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDefaultPermissions

func GetDefaultPermissions() ([]byte, error)

GetDefaultPermissions returns the embedded default read-only permissions

func MergeFilters

func MergeFilters(userQuery, permissionFilters map[string]any) (map[string]any, bool)

MergeFilters ANDs permission filters into the user query; the bool reports whether any were applied.

func Validate

func Validate(config *Config) error

Validate validates a permissions configuration

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

type Config struct {
	Version     string  `yaml:"version"`
	Permissions Section `yaml:"permissions"`
}

Config represents the complete permissions configuration

func LoadAdminForTesting

func LoadAdminForTesting() *Config

LoadAdminForTesting returns an admin permissions configuration for testing purposes

func LoadDefault

func LoadDefault() (*Config, error)

LoadDefault loads the embedded default read-only permissions

func LoadFromFile

func LoadFromFile(path string) (*Config, error)

LoadFromFile loads and parses a permissions configuration from a file

func ParseYAML

func ParseYAML(data []byte) (*Config, error)

ParseYAML parses YAML data into a Config struct

func (*Config) GetAllowedAnalyzers

func (c *Config) GetAllowedAnalyzers(allAnalyzers []string) []string

GetAllowedAnalyzers returns list of allowed analyzer names

func (*Config) GetAllowedResponders

func (c *Config) GetAllowedResponders(allResponders []string) []string

GetAllowedResponders returns list of allowed responder names

func (*Config) GetToolFilters

func (c *Config) GetToolFilters(toolName string) map[string]any

GetToolFilters returns the filters for a specific tool

func (*Config) IsAnalyzerAllowed

func (c *Config) IsAnalyzerAllowed(analyzerName string) bool

IsAnalyzerAllowed checks if an analyzer is permitted based on global rules

func (*Config) IsEntityOperationAllowed

func (c *Config) IsEntityOperationAllowed(entityType, operation string) bool

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

func (c *Config) IsResponderAllowed(responderName string) bool

IsResponderAllowed checks if a responder is permitted based on global rules

func (*Config) IsToolAllowed

func (c *Config) IsToolAllowed(toolName string) bool

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL