Documentation ¶
Overview ¶
Package content provides API to get rule's content by its `rule id` and `error key`. It takes all the work of caching rules taken from content service
Package content provides API to get rule's content by its `rule id` and `error key`. It takes all the work of caching rules taken from content service
Index ¶
- func FetchRuleContent(rule *ctypes.RuleOnReport, OSDEligible bool) (ruleWithContentResponse *types.RuleWithContentResponse, osdFiltered bool, ...)
- func GetAllContentV1() ([]types.RuleContentV1, error)
- func GetAllContentV2() ([]types.RuleContentV2, error)
- func GetContentForRecommendation(ruleID ctypes.RuleID) (*types.RuleWithContent, error)
- func GetExternalRuleIDs() ([]ctypes.RuleID, error)
- func GetExternalRuleSeverities() (map[ctypes.RuleID]int, []int, error)
- func GetExternalRulesManagedInfo() (map[ctypes.RuleID]bool, error)
- func GetInternalRuleIDs() ([]ctypes.RuleID, error)
- func GetRuleContentV1(ruleID ctypes.RuleID) (*types.RuleContentV1, error)
- func GetRuleContentV2(ruleID ctypes.RuleID) (*types.RuleContentV2, error)
- func GetRuleIDs() ([]string, error)
- func GetRuleWithErrorKeyContent(ruleID ctypes.RuleID, errorKey ctypes.ErrorKey) (*types.RuleWithContent, error)
- func IsRuleInternal(ruleID ctypes.RuleID) bool
- func LoadRuleContent(contentDir *ctypes.RuleContentDirectory)
- func RuleContentToV1(res *ctypes.RuleContent) types.RuleContentV1
- func RuleContentToV2(res *ctypes.RuleContent) types.RuleContentV2
- func RunUpdateContentLoop(servicesConf services.Configuration)
- func SetContentDirectoryTimeout(timeout time.Duration)
- func SetRuleContentDirectory(contentDir *ctypes.RuleContentDirectory)
- func StopUpdateContentLoop()
- func UpdateContent(servicesConf services.Configuration)
- func WaitForContentDirectoryToBeReady() error
- type RuleContentDirectoryTimeoutError
- type RulesWithContentStorage
- func (s *RulesWithContentStorage) GetAllContentV1() []types.RuleContentV1
- func (s *RulesWithContentStorage) GetAllContentV2() []types.RuleContentV2
- func (s *RulesWithContentStorage) GetContentForRecommendation(ruleID ctypes.RuleID) (*types.RuleWithContent, bool)
- func (s *RulesWithContentStorage) GetExternalRuleIDs() []ctypes.RuleID
- func (s *RulesWithContentStorage) GetExternalRuleSeverities() (severityMap map[ctypes.RuleID]int, uniqueSeverities []int)
- func (s *RulesWithContentStorage) GetExternalRulesManagedInfo() (managedMap map[ctypes.RuleID]bool)
- func (s *RulesWithContentStorage) GetInternalRuleIDs() []ctypes.RuleID
- func (s *RulesWithContentStorage) GetRuleIDs() []string
- func (s *RulesWithContentStorage) GetRuleWithErrorKeyContent(ruleID ctypes.RuleID, errorKey ctypes.ErrorKey) (*types.RuleWithContent, bool)
- func (s *RulesWithContentStorage) SetRule(ruleID ctypes.RuleID, ruleContent *ctypes.RuleContent)
- func (s *RulesWithContentStorage) SetRuleWithContent(ruleID ctypes.RuleID, errorKey ctypes.ErrorKey, ...)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FetchRuleContent ¶
func FetchRuleContent(rule *ctypes.RuleOnReport, OSDEligible bool) ( ruleWithContentResponse *types.RuleWithContentResponse, osdFiltered bool, err error, )
FetchRuleContent - fetching content for particular rule Return values:
- Structure with rules and content
- return true if the rule has been filtered by OSDElegible field. False otherwise
- return error if the one occurred during retrieval
func GetAllContentV1 ¶
func GetAllContentV1() ([]types.RuleContentV1, error)
GetAllContentV1 returns content for all the loaded rules.
func GetAllContentV2 ¶
func GetAllContentV2() ([]types.RuleContentV2, error)
GetAllContentV2 returns content for api v2
func GetContentForRecommendation ¶
func GetContentForRecommendation( ruleID ctypes.RuleID, ) (*types.RuleWithContent, error)
GetContentForRecommendation returns content for rule with provided composite rule ID
func GetExternalRuleIDs ¶
GetExternalRuleIDs returns a list of composite rule IDs ("| format") of external rules
func GetExternalRuleSeverities ¶
GetExternalRuleSeverities returns a map of rule IDs and their severity (total risk), along with a list of unique severities
func GetExternalRulesManagedInfo ¶
GetExternalRulesManagedInfo returns a map of rule IDs and the information whether a rule is managed (has osd_customer tag) or not
func GetInternalRuleIDs ¶
GetInternalRuleIDs returns a list of composite rule IDs ("| format") of internal rules
func GetRuleContentV1 ¶
func GetRuleContentV1(ruleID ctypes.RuleID) (*types.RuleContentV1, error)
GetRuleContentV1 returns content for rule with provided `rule id` Caching is done under the hood, don't worry about it.
func GetRuleContentV2 ¶
func GetRuleContentV2(ruleID ctypes.RuleID) (*types.RuleContentV2, error)
GetRuleContentV2 provides single rule for api v2
func GetRuleIDs ¶
GetRuleIDs returns a list of rule IDs (rule modules)
func GetRuleWithErrorKeyContent ¶
func GetRuleWithErrorKeyContent( ruleID ctypes.RuleID, errorKey ctypes.ErrorKey, ) (*types.RuleWithContent, error)
GetRuleWithErrorKeyContent returns content for rule with provided `rule id` and `error key`. Caching is done under the hood, don't worry about it.
func IsRuleInternal ¶
IsRuleInternal tries to look for the word "internal" in the ruleID / rule module, because it's currently not specified anywhere on it's own
func LoadRuleContent ¶
func LoadRuleContent(contentDir *ctypes.RuleContentDirectory)
LoadRuleContent loads the parsed rule content into the storage
func RuleContentToV1 ¶
func RuleContentToV1(res *ctypes.RuleContent) types.RuleContentV1
RuleContentToV1 parses insights-results-types.RuleContent to RuleContentV1
func RuleContentToV2 ¶
func RuleContentToV2(res *ctypes.RuleContent) types.RuleContentV2
RuleContentToV2 parses insights-results-types.RuleContent to RuleContentV2
func RunUpdateContentLoop ¶
func RunUpdateContentLoop(servicesConf services.Configuration)
RunUpdateContentLoop runs loop which updates rules content by ticker
func SetContentDirectoryTimeout ¶
SetContentDirectoryTimeout sets the maximum duration for which the smart proxy waits if the content directory is empty
func SetRuleContentDirectory ¶
func SetRuleContentDirectory(contentDir *ctypes.RuleContentDirectory)
SetRuleContentDirectory is made for easy testing fake rules etc. from other directories
func UpdateContent ¶
func UpdateContent(servicesConf services.Configuration)
UpdateContent function updates rule content
func WaitForContentDirectoryToBeReady ¶
func WaitForContentDirectoryToBeReady() error
WaitForContentDirectoryToBeReady ensures the rule content directory is safe to read/write
Types ¶
type RuleContentDirectoryTimeoutError ¶
type RuleContentDirectoryTimeoutError struct{}
RuleContentDirectoryTimeoutError is used, when the content directory is empty for too long time
func (*RuleContentDirectoryTimeoutError) Error ¶
func (e *RuleContentDirectoryTimeoutError) Error() string
type RulesWithContentStorage ¶
type RulesWithContentStorage struct {
// contains filtered or unexported fields
}
RulesWithContentStorage is a key:value structure to store processed rules. It's thread safe
func (*RulesWithContentStorage) GetAllContentV1 ¶
func (s *RulesWithContentStorage) GetAllContentV1() []types.RuleContentV1
GetAllContentV1 returns content for rule for api v1
func (*RulesWithContentStorage) GetAllContentV2 ¶
func (s *RulesWithContentStorage) GetAllContentV2() []types.RuleContentV2
GetAllContentV2 returns content for api/v2
func (*RulesWithContentStorage) GetContentForRecommendation ¶
func (s *RulesWithContentStorage) GetContentForRecommendation( ruleID ctypes.RuleID, ) (*types.RuleWithContent, bool)
GetContentForRecommendation returns content for rule with error key
func (*RulesWithContentStorage) GetExternalRuleIDs ¶
func (s *RulesWithContentStorage) GetExternalRuleIDs() []ctypes.RuleID
GetExternalRuleIDs returns the composite rule IDs ("| format") of external rules
func (*RulesWithContentStorage) GetExternalRuleSeverities ¶
func (s *RulesWithContentStorage) GetExternalRuleSeverities() ( severityMap map[ctypes.RuleID]int, uniqueSeverities []int, )
GetExternalRuleSeverities returns a map of external rule IDs and their severity (total risk) along with a list of unique severities
func (*RulesWithContentStorage) GetExternalRulesManagedInfo ¶
func (s *RulesWithContentStorage) GetExternalRulesManagedInfo() (managedMap map[ctypes.RuleID]bool)
GetExternalRulesManagedInfo returns a map of rule IDs and the information whether a rule is managed (has osd_customer tag) or not
func (*RulesWithContentStorage) GetInternalRuleIDs ¶
func (s *RulesWithContentStorage) GetInternalRuleIDs() []ctypes.RuleID
GetInternalRuleIDs returns the composite rule IDs ("| format") of internal rules
func (*RulesWithContentStorage) GetRuleIDs ¶
func (s *RulesWithContentStorage) GetRuleIDs() []string
GetRuleIDs gets rule IDs for rules (rule modules)
func (*RulesWithContentStorage) GetRuleWithErrorKeyContent ¶
func (s *RulesWithContentStorage) GetRuleWithErrorKeyContent( ruleID ctypes.RuleID, errorKey ctypes.ErrorKey, ) (*types.RuleWithContent, bool)
GetRuleWithErrorKeyContent returns content for rule with error key
func (*RulesWithContentStorage) SetRule ¶
func (s *RulesWithContentStorage) SetRule( ruleID ctypes.RuleID, ruleContent *ctypes.RuleContent, )
SetRule sets content for rule
func (*RulesWithContentStorage) SetRuleWithContent ¶
func (s *RulesWithContentStorage) SetRuleWithContent( ruleID ctypes.RuleID, errorKey ctypes.ErrorKey, ruleWithContent *types.RuleWithContent, )
SetRuleWithContent sets content for rule with error key