content

package
v1.0.0 Latest Latest
Warning

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

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

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

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

func GetExternalRuleIDs() ([]ctypes.RuleID, error)

GetExternalRuleIDs returns a list of composite rule IDs ("| format") of external rules

func GetExternalRuleSeverities

func GetExternalRuleSeverities() (
	map[ctypes.RuleID]int,
	[]int,
	error,
)

GetExternalRuleSeverities returns a map of rule IDs and their severity (total risk), along with a list of unique severities

func GetExternalRulesManagedInfo

func GetExternalRulesManagedInfo() (
	map[ctypes.RuleID]bool, error,
)

GetExternalRulesManagedInfo returns a map of rule IDs and the information whether a rule is managed (has osd_customer tag) or not

func GetInternalRuleIDs

func GetInternalRuleIDs() ([]ctypes.RuleID, error)

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

func GetRuleIDs() ([]string, error)

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

func IsRuleInternal(ruleID ctypes.RuleID) bool

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

func SetContentDirectoryTimeout(timeout time.Duration)

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 StopUpdateContentLoop

func StopUpdateContentLoop()

StopUpdateContentLoop stops the loop

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

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

Jump to

Keyboard shortcuts

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