cfgreader

package
v0.0.0-...-1a4da24 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadConfig

func LoadConfig(cfg interface{}, path string) (err error)

LoadConfig parses json configuration file into structure

Types

type AdjustedSeverityCategory

type AdjustedSeverityCategory struct {
	Category                string   `json:"category"`
	Patterns                []string `json:"patterns"`
	CompiledPatterns        []*regexp.Regexp
	AdjustedDisplaySeverity string `json:"adjusted_display_severity"`
	// If UseFilename is true the match will be based on hit.Filename
	UseFilename bool `json:"use_filename"`
	// If UseLineValue is true the match will be based on hit.LineValue
	UseLineValue bool `json:"use_line_value"`
}

type Configs

type Configs struct {
	LevelConfigs []struct {
		Name string `json:"level_name"`
		ID   int    `json:"level_id"`
	} `json:"finding_levels"`
	AnnotationsToSkip          []string                   `json:"text_ignore_patterns"`
	ConfigBaseUrl              string                     `json:"config_base_url"`
	ExtensionsToSkipTextScan   []string                   `json:"filename_skip_text_scanning_extensions"`
	FailThreshold              int                        `json:"fail_threshold_level"`
	DisplayThreshold           int                        `json:"display_threshold_level"`
	DisplayConfidenceThreshold int                        `json:"display_confidence_threshold_level"`
	ConfigFileURL              string                     `json:"earlybird_config_url"`
	Version                    string                     `json:"version"`
	AdjustedSeverityCategories []AdjustedSeverityCategory `json:"adjusted_severity_categories_patterns"`
}

Configs is the result of earlybird.json

var Settings Configs

Settings contains imported earlybird.json configuration

func (*Configs) GetLevelMap

func (cfg *Configs) GetLevelMap() (levelMap map[string]int)

GetLevelMap returns a map of severity levels

func (*Configs) GetLevelNames

func (cfg *Configs) GetLevelNames() (levels []string)

GetLevelNames returns a slice of strings for the level names

func (*Configs) TranslateLevelID

func (cfg *Configs) TranslateLevelID(level int) string

TranslateLevelID returns the text value of a level integer (e.g., 2 --> high)

func (*Configs) TranslateLevelName

func (cfg *Configs) TranslateLevelName(level string) int

TranslateLevelName returns the int level of a string value (e.g., high --> 2)

type EarlybirdConfig

type EarlybirdConfig struct {
	AvailableModules           []string
	RuleModulesFilenameMap     map[string]string
	SearchDir                  string
	Gitrepo                    string
	TargetType                 string
	EnabledModulesMap          map[string]string
	EnabledModules             []string
	WithConsole                bool
	OutputFormat               string
	OutputFile                 string
	IgnoreFile                 string
	SeverityFailLevel          int
	SeverityDisplayLevel       int
	ConfidenceFailLevel        int
	ConfidenceDisplayLevel     int
	ConfigDir                  string
	RulesConfigDir             string
	FalsePositivesConfigDir    string
	SolutionsConfigDir         string
	LabelsConfigDir            string
	LevelMap                   map[string]int
	Suppress                   bool
	VerboseEnabled             bool
	GitStream                  bool
	MaxFileSize                int64
	ShowFullLine               bool
	FailScan                   bool
	RulesOnly                  bool
	ExtensionsToSkipScan       []string
	AnnotationsToSkipLine      []string
	SkipComments               bool
	IgnoreFPRules              bool
	ShowSolutions              bool
	Version                    string
	WorkerCount                int
	WorkLength                 int
	HideMeta                   bool
	ModuleConfigs              ModuleConfigs
	AdjustedSeverityCategories []AdjustedSeverityCategory
}

EarlybirdConfig is the overall scan configs from config file and cli params

type ModuleConfig

type ModuleConfig struct {
	DisplaySeverity        string `json:"display_severity"`
	DisplayConfidence      string `json:"display_confidence"`
	DisplaySeverityLevel   int
	DisplayConfidenceLevel int
}

Config from -module-config-file flag

type ModuleConfigs

type ModuleConfigs struct {
	Modules map[string]ModuleConfig `json:"modules"`
}

type ServerConfig

type ServerConfig struct {
	WriteTimeout int `json:"write-timeout"`
	ReadTimeout  int `json:"read-timeout"`
	IdleTimeout  int `json:"idle-timeout"`
}

ServerConfig is the timeout configuration for the Earlybird REST API server

Jump to

Keyboard shortcuts

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