Documentation ¶
Index ¶
- Constants
- func ListToMap(list []*Analyzer) map[SpecAnalyzer]*Analyzer
- type APIClarityConfig
- type APIClarityDriftResult
- type Analyzer
- func (m *Analyzer) BeforeCreate(tx *gorm.DB) (err error)
- func (m *Analyzer) BeforeSave(tx *gorm.DB) (err error)
- func (m *Analyzer) GetID() string
- func (m *Analyzer) GetIndex(field string) string
- func (m *Analyzer) GetIndexValue(field string) string
- func (m *Analyzer) GetIndexValues() map[string]string
- func (m *Analyzer) GetIndexes() map[string]string
- func (m *Analyzer) GetTags() []string
- func (m *Analyzer) Sortable(field string) bool
- func (m *Analyzer) SortableFields() map[string]struct{}
- func (m *Analyzer) String() string
- func (m *Analyzer) TableName() string
- type AnalyzersScoreConfigs
- type Config
- func (c Config) GetScoreConfig() *ScoreConfig
- func (c *Config) Scan(value interface{}) error
- func (c Config) ServiceNameID() string
- func (c Config) ServiceNameIDFromTemplate(serviceNameID string) string
- func (c Config) ServiceNameIDTemplate() string
- func (c Config) UnmarshalInto(v interface{}) error
- func (c Config) Value() (driver.Value, error)
- type Finding
- type FindingDiff
- type FindingPosition
- type FindingPositionRange
- type Findings
- type Result
- type ResultSummary
- type Resulter
- type Rule
- func (m *Rule) BeforeCreate(tx *gorm.DB) (err error)
- func (m *Rule) GetID() string
- func (m *Rule) GetIndex(field string) string
- func (m *Rule) GetIndexValue(field string) string
- func (m *Rule) GetIndexValues() map[string]string
- func (m *Rule) GetIndexes() map[string]string
- func (m *Rule) GetTags() []string
- func (m *Rule) Sortable(field string) bool
- func (m *Rule) SortableFields() map[string]struct{}
- func (m *Rule) String() string
- func (m *Rule) TableName() string
- type RuleFindings
- type RuleFindingsStats
- type ScoreConfig
- type SecurityConfig
- type SecurityFinding
- type SeverityRuleFindings
- type SeverityRuleFindingsStats
- type SpecAnalyzer
- type SpectralConfig
- type SpectralResult
- type SpectralResultItem
- type WokeConfig
- type WokeResult
Constants ¶
const ( AnalyzerTableName = "analyzers" AnalyzerStatusActive = "active" )
const ( CiscoAPIGuidelines = SpecAnalyzer("guidelines") InclusiveLanguage = SpecAnalyzer("inclusive-language") Drift = SpecAnalyzer("drift") Completeness = SpecAnalyzer("completeness") Security = SpecAnalyzer("security") )
const ( ConfigScoreConfig = "score_config" ConfigServiceNameID = "service_name_id" ConfigServiceNameIDTemplate = "service_name_id_template" )
const ( ScoreCategoryAPISecurity = "api-specification" SACSeverityCritical = "CRITICAL" SACSeverityHigh = "HIGH" SACSeverityMedium = "MEDIUM" SACSeverityLow = "LOW" SACSeverityUnknown = "UNKNOWN" )
const (
AnalyzerRuleTableName = "analyzer_rules"
)
Variables ¶
This section is empty.
Functions ¶
func ListToMap ¶
func ListToMap(list []*Analyzer) map[SpecAnalyzer]*Analyzer
Types ¶
type APIClarityConfig ¶
type APIClarityConfig struct { }
type APIClarityDriftResult ¶
type APIClarityDriftResult struct { Events []*models2.APIEvent EventProvidedSpecDiffs []*models2.APIEventSpecDiff }
func (*APIClarityDriftResult) Result ¶
func (m *APIClarityDriftResult) Result() (*Result, error)
type Analyzer ¶
type Analyzer struct { ID string `json:"id,omitempty" gorm:"column:id;primaryKey"` NameID string `json:"name_id" gorm:"column:name_id;unique;index"` Title string `json:"title" gorm:"column:title"` Description string `json:"description" gorm:"column:description"` Status string `json:"status" gorm:"column:status;index"` Meta datatypes.JSONMap `json:"meta" gorm:"column:meta"` Config Config `json:"config" gorm:"column:config"` CreatedAt time.Time `json:"created_at" gorm:"column:created_at"` UpdatedAt time.Time `json:"updated_at" gorm:"column:updated_at"` Position int `json:"position" gorm:"column:position"` Rules []*Rule `json:"rules" gorm:"foreignKey:AnalyzerNameID;references:NameID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"` }
Analyzer represents an analyzer
func (*Analyzer) GetIndexValue ¶
GetIndexValue return index value for specified field
func (*Analyzer) GetIndexValues ¶
GetIndexValues return all field index values
func (*Analyzer) GetIndexes ¶
GetIndexes returns all the field indexes
func (*Analyzer) SortableFields ¶
SortableFields returns all sortable fields
type AnalyzersScoreConfigs ¶
type AnalyzersScoreConfigs map[SpecAnalyzer]*ScoreConfig
func NewAnalyzersScoreConfigsFrom ¶
func NewAnalyzersScoreConfigsFrom(analyzers map[SpecAnalyzer]*Analyzer) (AnalyzersScoreConfigs, error)
type Config ¶
type Config map[string]interface{}
func (Config) GetScoreConfig ¶
func (c Config) GetScoreConfig() *ScoreConfig
func (*Config) Scan ¶
Scan implements sql.Scanner interface. See https://gorm.io/docs/data_types.html#Implements-Customized-Data-Type.
func (Config) ServiceNameID ¶
func (Config) ServiceNameIDFromTemplate ¶
func (Config) ServiceNameIDTemplate ¶
func (Config) UnmarshalInto ¶
type Finding ¶
type Finding struct { Type rule.FindingType `json:"type"` Path []string `json:"path"` Range *FindingPositionRange `json:"range,omitempty"` Diff *FindingDiff `json:"diff,omitempty"` }
type FindingDiff ¶
type FindingPosition ¶
type FindingPositionRange ¶
type FindingPositionRange struct { Start *FindingPosition `json:"start"` End *FindingPosition `json:"end"` }
FindingPositionRange represents
type Result ¶
type Result struct { Summary *ResultSummary `json:"summary" gorm:"column:summary"` Findings SeverityRuleFindings `json:"findings" gorm:"column:findings"` // contains filtered or unexported fields }
Result represents the result of a models.SpecAnalysis.
func GetSecurityResult ¶
func GetSecurityResult(spec string, in *models.APIServiceDrillDownExternal) (*Result, error)
func (Result) AddFinding ¶
type ResultSummary ¶
type ResultSummary struct {
Stats *SeverityRuleFindingsStats `json:"stats"`
}
ResultSummary represents a summary of Result.Findings.
func NewResultSummary ¶
func NewResultSummary() *ResultSummary
NewResultSummary constructs a new ResultSummary with default stats initialized.
type Rule ¶
type Rule struct { ID string `json:"id,omitempty" gorm:"column:id;primaryKey"` NameID string `json:"name_id" gorm:"column:name_id;unique;index"` AnalyzerNameID string `json:"analyzer_name_id" gorm:"column:analyzer_name_id;index"` Title string `json:"title" gorm:"column:title"` Description string `json:"description" gorm:"column:description"` Severity string `json:"severity" gorm:"column:severity"` Mitigation string `json:"mitigation" gorm:"column:mitigation"` Meta datatypes.JSONMap `json:"meta" gorm:"column:meta"` CreatedAt time.Time `json:"created_at" gorm:"column:created_at"` UpdatedAt time.Time `json:"updated_at" gorm:"column:updated_at"` }
Rule represents an analyzer rule
func (*Rule) GetIndexValue ¶
GetIndexValue return index value for specified field
func (*Rule) GetIndexValues ¶
GetIndexValues return all field index values
func (*Rule) GetIndexes ¶
GetIndexes returns all the field indexes
func (*Rule) SortableFields ¶
SortableFields returns all sortable fields
type RuleFindings ¶
type RuleFindingsStats ¶
type RuleFindingsStats struct { Count int `json:"count"` Occurrences int `json:"occurrences"` Data map[rule.NameID]int `json:"rules"` }
RuleFindingsStats contains stats of RuleFindings.
type ScoreConfig ¶
type ScoreConfig struct { AnalyzerWeight *float32 `json:"analyzer_weight"` SeverityWeights map[rule.SeverityName]int `json:"severity_weights"` }
func NewScoreConfig ¶
func NewScoreConfig(setDefaults bool) *ScoreConfig
type SecurityConfig ¶
type SecurityConfig struct {
Name string // composed sac external api name, e.g. carts.api.apiregistry
}
type SecurityFinding ¶
type SecurityFinding struct { Severity string `json:"severity"` Kind string `json:"kind"` Type string `json:"type"` Code string `json:"code"` Message string `json:"message"` Location []interface{} `json:"location"` CrRawFindingID string `json:"cr_raw_finding_id"` CrFindingIndex int `json:"cr_finding_index"` AffectedEndpoints []interface{} `json:"affected_endpoints"` Source string `json:"source"` SeverityCategory string `json:"severity_category"` CrankshaftClassID string `json:"crankshaft_class_id"` CrankshaftSeverity string `json:"crankshaft_severity"` CrankshaftCategory string `json:"crankshaft_category"` CrankshaftJsonpath string `json:"crankshaft_jsonpath"` }
func NewSecurityFindingData ¶
func NewSecurityFindingData(sf *models.ScoreFinding) (data []*SecurityFinding, err error)
func (*SecurityFinding) JSONPaths ¶
func (m *SecurityFinding) JSONPaths() []string
type SeverityRuleFindings ¶
type SeverityRuleFindings map[rule.SeverityName]*RuleFindings
SeverityRuleFindings defines a grouping of rule findings by their severities.
func NewSeverityRuleFindings ¶
func NewSeverityRuleFindings() SeverityRuleFindings
NewSeverityRuleFindings constructs a new SeverityRuleFindings with default severities initialized.
type SeverityRuleFindingsStats ¶
type SeverityRuleFindingsStats struct { Count int `json:"count"` Occurrences int `json:"occurrences"` Hint *RuleFindingsStats `json:"hint"` Info *RuleFindingsStats `json:"info"` Warning *RuleFindingsStats `json:"warning"` Error *RuleFindingsStats `json:"error"` }
SeverityRuleFindingsStats contains stats of SeverityRuleFindings.
type SpectralConfig ¶
type SpectralConfig struct {
Ruleset *string // choose a ruleset [string] [choices: "cisco", "cisco-without-oas", "cx", "cx-without-oas", "cx-dictionary"] [default: "cisco-without-oas"]
}
func (*SpectralConfig) SetDefaults ¶
func (c *SpectralConfig) SetDefaults()
func (*SpectralConfig) SetRuleset ¶
func (c *SpectralConfig) SetRuleset(ruleset string)
type SpectralResult ¶
type SpectralResult []*SpectralResultItem
func (SpectralResult) Result ¶
func (m SpectralResult) Result() (*Result, error)
type SpectralResultItem ¶
type SpectralResultItem struct { Code string `json:"code"` Path []string `json:"path"` Message string `json:"message"` Severity int `json:"severity"` Range struct { Start struct { Line int `json:"line"` Character int `json:"character"` } `json:"start"` End struct { Line int `json:"line"` Character int `json:"character"` } `json:"end"` } `json:"range"` Source string `json:"source"` }
type WokeConfig ¶
type WokeConfig struct { Config string // Config file (default is .woke.yaml in current directory, or $HOME) DisableDefaultRules bool // Disable the default ruleset ExitOneOnFailure bool // Exit with exit code 1 on failures NoIgnore bool // Ignored files in .gitignore, .ignore, .wokeignore, .git/info/exclude, and inline ignores are processed OutputName string // Output type [text,simple,github-actions,json,sonarqube] }
func (*WokeConfig) SetDefaults ¶
func (c *WokeConfig) SetDefaults()
type WokeResult ¶
type WokeResult struct { Filename string `json:"Filename"` Results []struct { Rule struct { Name string `json:"Name"` Terms []string `json:"Terms"` Alternatives []string `json:"Alternatives"` Note string `json:"Note"` Severity string `json:"Severity"` Options struct { WordBoundary bool `json:"WordBoundary"` WordBoundaryStart bool `json:"WordBoundaryStart"` WordBoundaryEnd bool `json:"WordBoundaryEnd"` IncludeNote bool `json:"IncludeNote"` Categories interface{} `json:"Categories"` } `json:"Options"` } `json:"Rule"` Finding string `json:"Finding"` Line string `json:"Line"` StartPosition struct { Filename string `json:"Filename"` Offset int `json:"Offset"` Line int `json:"Line"` Column int `json:"Column"` } `json:"StartPosition"` EndPosition struct { Filename string `json:"Filename"` Offset int `json:"Offset"` Line int `json:"Line"` Column int `json:"Column"` } `json:"EndPosition"` Reason string `json:"Reason"` } `json:"Results"` }
func (*WokeResult) Result ¶
func (m *WokeResult) Result() (*Result, error)