Documentation
¶
Index ¶
- Constants
- Variables
- func FloatPtr(v float64) *float64
- func GetMetricType(reference string) (string, error)
- type Category
- type CategoryScore
- type CategoryThresholds
- type CategoryWeights
- type ConfigLoader
- func (c *ConfigLoader) CreateDefaultConfigFiles() error
- func (c *ConfigLoader) CreateMetricFile(fileName string) error
- func (c *ConfigLoader) LoadLeversConfig() (*LeversConfig, error)
- func (c *ConfigLoader) LoadMetricsConfig() (*MetricsConfig, error)
- func (c *ConfigLoader) LoadMetricsData() (*MetricsData, error)
- func (c *ConfigLoader) MigrateMetricsData() error
- func (c *ConfigLoader) SaveMetricsData(metricsData *MetricsData) error
- type Global
- type KPI
- type KRI
- type LeversConfig
- type Metric
- type MetricScore
- type MetricsConfig
- type MetricsData
- type MetricsProcessor
- func (m *MetricsProcessor) GetAllCategories() []Category
- func (m *MetricsProcessor) GetAllMetrics() []Metric
- func (m *MetricsProcessor) GetCategoryByID(categoryID string) (*Category, error)
- func (m *MetricsProcessor) GetMetricByReference(reference string) (*Metric, error)
- func (m *MetricsProcessor) GetMetricDefinition(reference string) (interface{}, error)
- func (m *MetricsProcessor) GetMetricsByCategory(categoryID string) []Metric
- func (m *MetricsProcessor) UpdateMetric(reference string, value float64) error
- type OverallScore
- type ReportFormat
- type ReportGenerator
- type ScoreCalculator
- type ScoringBand
- type ScoringMethod
- type ThresholdLabelType
- type ThresholdRange
- type Thresholds
- type TrafficLightStatus
- type Weights
Constants ¶
const ApplicationName string = "pulse"
Variables ¶
var ( Version = "main" Build = "unknown" )
Version information set by build flags
Functions ¶
func FloatPtr ¶
FloatPtr creates a pointer to a float64 value This is useful for creating min/max values for scoring bands
func GetMetricType ¶
GetMetricType returns whether a metric is a KPI or KRI
Types ¶
type Category ¶
type Category struct {
ID string `yaml:"id"`
Name string `yaml:"name"`
Description string `yaml:"description"`
KPIs []KPI `yaml:"kpis"`
KRIs []KRI `yaml:"kris"`
}
Category represents a security program category with KPIs and KRIs
type CategoryScore ¶
type CategoryScore struct {
ID string
Name string
Score int
KPIScore int
KRIScore int
Status TrafficLightStatus
KPIStatus TrafficLightStatus
KRIStatus TrafficLightStatus
Metrics []MetricScore
}
CategoryScore represents a calculated score for a category
type CategoryThresholds ¶
type CategoryThresholds map[string]Thresholds
CategoryThresholds represents category-specific thresholds
type CategoryWeights ¶
CategoryWeights represents the weights for each category
type ConfigLoader ¶
ConfigLoader handles loading and parsing of configuration files
func NewConfigLoader ¶
func NewConfigLoader(configDir, dataDir string) *ConfigLoader
NewConfigLoader creates a new ConfigLoader with the specified directories
func (*ConfigLoader) CreateDefaultConfigFiles ¶
func (c *ConfigLoader) CreateDefaultConfigFiles() error
CreateDefaultConfigFiles creates default configuration files if they don't exist
func (*ConfigLoader) CreateMetricFile ¶
func (c *ConfigLoader) CreateMetricFile(fileName string) error
CreateMetricFile creates a new metric file with the given name
func (*ConfigLoader) LoadLeversConfig ¶
func (c *ConfigLoader) LoadLeversConfig() (*LeversConfig, error)
LoadLeversConfig loads the executive levers configuration from the YAML file
func (*ConfigLoader) LoadMetricsConfig ¶
func (c *ConfigLoader) LoadMetricsConfig() (*MetricsConfig, error)
LoadMetricsConfig loads the metrics configuration from the YAML file
func (*ConfigLoader) LoadMetricsData ¶
func (c *ConfigLoader) LoadMetricsData() (*MetricsData, error)
LoadMetricsData loads the metrics data from YAML files in the data directory
func (*ConfigLoader) MigrateMetricsData ¶ added in v1.1.0
func (c *ConfigLoader) MigrateMetricsData() error
MigrateMetricsData migrates metrics from both legacy formats to the new format
func (*ConfigLoader) SaveMetricsData ¶
func (c *ConfigLoader) SaveMetricsData(metricsData *MetricsData) error
SaveMetricsData saves the metrics data to YAML files in the data directory
type Global ¶
type Global struct {
Thresholds Thresholds `yaml:"thresholds"`
KPIThresholds Thresholds `yaml:"kpi_thresholds"`
KRIThresholds Thresholds `yaml:"kri_thresholds"`
}
Global represents global configuration settings
type KPI ¶
type KPI struct {
ID string `yaml:"id"`
Name string `yaml:"name"`
Description string `yaml:"description"`
Unit string `yaml:"unit"`
ScoringBands []ScoringBand `yaml:"scoring_bands"`
}
KPI represents a Key Performance Indicator
type KRI ¶
type KRI struct {
ID string `yaml:"id"`
Name string `yaml:"name"`
Description string `yaml:"description"`
Unit string `yaml:"unit"`
ScoringBands []ScoringBand `yaml:"scoring_bands"`
}
KRI represents a Key Risk Indicator
type LeversConfig ¶
LeversConfig represents the structure of the executive levers configuration file
type Metric ¶
type Metric struct {
Reference string `yaml:"reference"`
Value float64 `yaml:"value"`
Timestamp time.Time `yaml:"timestamp"`
SourceFile string `yaml:"-"` // Source file for the metric (not stored in YAML)
}
Metric represents a single metric measurement
type MetricScore ¶
type MetricScore struct {
Reference string
Score int
Status TrafficLightStatus
}
MetricScore represents a calculated score for a metric
type MetricsConfig ¶
type MetricsConfig struct {
Categories []Category `yaml:"categories"`
}
MetricsConfig represents the structure of the metrics configuration file
type MetricsData ¶
type MetricsData struct {
Metrics []Metric `yaml:"metrics"`
}
MetricsData represents the structure of the metrics data file
type MetricsProcessor ¶
type MetricsProcessor struct {
// contains filtered or unexported fields
}
MetricsProcessor handles processing and analysis of metrics
func NewMetricsProcessor ¶
func NewMetricsProcessor(metricsConfig *MetricsConfig, leversConfig *LeversConfig, metricsData *MetricsData) *MetricsProcessor
NewMetricsProcessor creates a new MetricsProcessor with the specified configurations
func (*MetricsProcessor) GetAllCategories ¶
func (m *MetricsProcessor) GetAllCategories() []Category
GetAllCategories returns all categories
func (*MetricsProcessor) GetAllMetrics ¶
func (m *MetricsProcessor) GetAllMetrics() []Metric
GetAllMetrics returns all metrics
func (*MetricsProcessor) GetCategoryByID ¶
func (m *MetricsProcessor) GetCategoryByID(categoryID string) (*Category, error)
GetCategoryByID returns a category by its ID
func (*MetricsProcessor) GetMetricByReference ¶
func (m *MetricsProcessor) GetMetricByReference(reference string) (*Metric, error)
GetMetricByReference returns a metric by its reference
func (*MetricsProcessor) GetMetricDefinition ¶
func (m *MetricsProcessor) GetMetricDefinition(reference string) (interface{}, error)
GetMetricDefinition returns the KPI or KRI definition for a metric
func (*MetricsProcessor) GetMetricsByCategory ¶
func (m *MetricsProcessor) GetMetricsByCategory(categoryID string) []Metric
GetMetricsByCategory returns metrics for a specific category
func (*MetricsProcessor) UpdateMetric ¶
func (m *MetricsProcessor) UpdateMetric(reference string, value float64) error
UpdateMetric updates a metric value or adds a new metric if it doesn't exist
type OverallScore ¶
type OverallScore struct {
Score int
KPIScore int
KRIScore int
Status TrafficLightStatus
KPIStatus TrafficLightStatus
KRIStatus TrafficLightStatus
Categories []CategoryScore
}
OverallScore represents the overall security posture score
type ReportFormat ¶
type ReportFormat string
ReportFormat defines the format of the report
const ( TextFormat ReportFormat = "text" JSONFormat ReportFormat = "json" TableFormat ReportFormat = "table" )
type ReportGenerator ¶
type ReportGenerator struct {
// contains filtered or unexported fields
}
ReportGenerator handles generation of reports
func NewReportGenerator ¶
func NewReportGenerator(scoreCalculator *ScoreCalculator, labelType ThresholdLabelType) *ReportGenerator
NewReportGenerator creates a new ReportGenerator
func (*ReportGenerator) GenerateCategoryReport ¶
func (r *ReportGenerator) GenerateCategoryReport(categoryID string, format ReportFormat) (string, error)
GenerateCategoryReport generates a report for a specific category
func (*ReportGenerator) GenerateOverallReport ¶
func (r *ReportGenerator) GenerateOverallReport(format ReportFormat) (string, error)
GenerateOverallReport generates an overall security posture report
type ScoreCalculator ¶
type ScoreCalculator struct {
// contains filtered or unexported fields
}
ScoreCalculator handles calculation of scores for metrics and categories
func NewScoreCalculator ¶
func NewScoreCalculator(metricsProcessor *MetricsProcessor, scoringMethod ScoringMethod) *ScoreCalculator
NewScoreCalculator creates a new ScoreCalculator
func (*ScoreCalculator) CalculateCategoryScore ¶
func (s *ScoreCalculator) CalculateCategoryScore(categoryID string) (*CategoryScore, error)
CalculateCategoryScore calculates the score for a category
func (*ScoreCalculator) CalculateMetricScore ¶
func (s *ScoreCalculator) CalculateMetricScore(metric Metric) (*MetricScore, error)
CalculateMetricScore calculates the score for a single metric
func (*ScoreCalculator) CalculateOverallScore ¶
func (s *ScoreCalculator) CalculateOverallScore() (*OverallScore, error)
CalculateOverallScore calculates the overall security posture score
type ScoringBand ¶
type ScoringBand struct {
Min *float64 `yaml:"min,omitempty"`
Max *float64 `yaml:"max,omitempty"`
Score int `yaml:"score"`
}
ScoringBand represents a single scoring band with min/max values and the resulting score
type ScoringMethod ¶
type ScoringMethod string
ScoringMethod defines the method used for score calculation
const ( // MedianScoring uses median for category scores and weighted median for overall score MedianScoring ScoringMethod = "median" // AverageScoring uses average for category scores and weighted average for overall score AverageScoring ScoringMethod = "average" )
type ThresholdLabelType ¶ added in v1.1.0
type ThresholdLabelType string
ThresholdLabelType defines the type of threshold labels to use
const ( // EmojiLabels uses emoji symbols for threshold labels EmojiLabels ThresholdLabelType = "emoji" // TextLabels uses text labels for thresholds TextLabels ThresholdLabelType = "text" )
type ThresholdRange ¶
type ThresholdRange struct {
Min int `yaml:"min"` // Minimum value (inclusive)
Max int `yaml:"max"` // Maximum value (inclusive)
}
ThresholdRange represents a range with min and max values
type Thresholds ¶
type Thresholds struct {
Green ThresholdRange `yaml:"green"` // Green threshold range
Yellow ThresholdRange `yaml:"yellow"` // Yellow threshold range
Red ThresholdRange `yaml:"red"` // Red threshold range
}
Thresholds represents the traffic light thresholds with ranges
type TrafficLightStatus ¶
type TrafficLightStatus string
TrafficLightStatus represents the status in the traffic light model
const ( Green TrafficLightStatus = "green" Yellow TrafficLightStatus = "yellow" Red TrafficLightStatus = "red" )
type Weights ¶
type Weights struct {
Categories CategoryWeights `yaml:"categories"`
CategoryThresholds CategoryThresholds `yaml:"category_thresholds"`
CategoryKPIThresholds CategoryThresholds `yaml:"category_kpi_thresholds"`
CategoryKRIThresholds CategoryThresholds `yaml:"category_kri_thresholds"`
}
Weights represents the weights configuration
