Documentation
¶
Index ¶
- Constants
- type Action
- type Analyzer
- type AnalyzerConfig
- type AnalyzerConfigMap
- type AnalyzerList
- type AnalyzerRule
- type AnalyzerRuleList
- type Config
- type EndpointSummary
- type Finding
- type FindingDiff
- type FindingPosition
- type FindingPositionRange
- type FindingType
- type Findings
- type JSONResult
- type ModifiedSummary
- type NameID
- type OperationSummary
- type ParameterSummary
- type ParametersSummary
- type PropertiesSummary
- type RequestBodySummary
- type RequestBodySummaryDetail
- type ResponseSummaryDetail
- type ResponsesSummary
- type ResponsesSummaryDetail
- type Result
- type ResultSummary
- type RuleFindings
- type RuleFindingsStats
- type SecuritySummary
- type SecuritySummaryDetail
- type Service
- type ServiceList
- type ServiceSummary
- type Severity
- type SeverityName
- type SeverityRuleFindings
- type SeverityRuleFindingsStats
- type Spec
- type SpecAnalysis
- type SpecAnalysisList
- type SpecAnalysisRequest
- type SpecAnalysisResponse
- type SpecAnalyzer
- type SpecDiff
- type SpecDiffConfig
- type SpecDiffList
- type SpecDiffRequest
- type SpecDiffResult
- type SpecDoc
- type SpecList
Constants ¶
const ( SeverityHint Severity = iota + 1 SeverityInfo SeverityWarning SeverityError SeverityNameHint SeverityName = "hint" SeverityNameInfo SeverityName = "info" SeverityNameWarning SeverityName = "warning" SeverityNameError SeverityName = "error" )
const ( DiffOutputJSON = "json" DiffOutputHTML = "html" DiffOutputMarkdown = "markdown" DiffOutputText = "text" )
const ( ActionAdded = Action("added") ActionDeleted = Action("deleted") ActionModified = Action("modified") )
const (
SpecAnalyzerCiscoAPIGuidelines = SpecAnalyzer("guidelines")
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Analyzer ¶
type Analyzer struct { ID string `json:"id,omitempty"` NameID string `json:"name_id"` Title string `json:"title"` Description string `json:"description"` Status string `json:"status"` Meta map[string]interface{} `json:"meta"` Position uint8 `json:"position"` Config Config `json:"config"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` Rules []AnalyzerRule `json:"rules"` }
Analyzer represents an analyzer
type AnalyzerConfig ¶
type AnalyzerConfig map[string]interface{}
AnalyzerConfig represents configs for an analyzer (SpecAnalysis.Analyzer)
type AnalyzerConfigMap ¶
type AnalyzerConfigMap map[SpecAnalyzer]Config
type AnalyzerList ¶
type AnalyzerList []*Analyzer
func (AnalyzerList) Print ¶
func (m AnalyzerList) Print(w io.Writer)
type AnalyzerRule ¶
type AnalyzerRule struct { ID string `json:"id,omitempty"` NameID string `json:"name_id"` AnalyzerNameID string `json:"analyzer_name_id"` Title string `json:"title"` Description string `json:"description"` Severity string `json:"severity"` Mitigation string `json:"mitigation"` Meta map[string]interface{} `json:"meta"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
AnalyzerRule represents an analyzer rule
type AnalyzerRuleList ¶
type AnalyzerRuleList []*AnalyzerRule
func (AnalyzerRuleList) Print ¶
func (m AnalyzerRuleList) Print(w io.Writer)
type EndpointSummary ¶
type Finding ¶
type Finding struct { Type 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 FindingType ¶
type FindingType string
const ( FindingTypeRange FindingType = "range" FindingTypeDiff = "diff" )
type JSONResult ¶
type JSONResult struct { Added []*EndpointSummary `json:"added"` Deleted []*EndpointSummary `json:"deleted"` Deprecated []*EndpointSummary `json:"deprecated"` Modified []*ModifiedSummary `json:"modified"` Breaking bool `json:"breaking"` Message string `json:"message"` }
type ModifiedSummary ¶
type ModifiedSummary struct { Old *OperationSummary `json:"old"` New *OperationSummary `json:"new"` Path string `json:"path"` Method string `json:"method"` Summary string `json:"summary"` Description string `json:"description"` Breaking bool `json:"breaking"` Message string `json:"message"` ParametersSummary *ParametersSummary `json:"parameters"` RequestBodySummary *RequestBodySummary `json:"requestBody"` ResponsesSummary *ResponsesSummary `json:"responses"` SecuritySummary *SecuritySummary `json:"security"` }
type OperationSummary ¶
type ParameterSummary ¶
type ParameterSummary struct {
Parameter, OldParameter, NewParameter *openapi3.Parameter `json:"-"`
Name string `json:"name"`
In string `json:"in"`
Description string `json:"description"`
Deprecated bool `json:"deprecated"` // TODO
Breaking bool `json:"breaking"`
Action Action `json:"action"`
Message string `json:"message"`
}
type ParametersSummary ¶
type ParametersSummary struct { Breaking bool `json:"breaking"` Message string `json:"message"` Details []*ParameterSummary `json:"details"` }
type PropertiesSummary ¶
type PropertiesSummary struct { Name string `json:"name"` Type string `json:"type"` Description string `json:"description"` Action Action `json:"action"` Breaking bool `json:"breaking"` Message string `json:"message"` Nested []*PropertiesSummary `json:"properties"` Group string `json:"-"` // group that this property belongs to, e.g. items }
type RequestBodySummary ¶
type RequestBodySummary struct { Breaking bool `json:"breaking"` Message string `json:"message"` Description string `json:"description"` Details []*RequestBodySummaryDetail `json:"details"` }
type RequestBodySummaryDetail ¶
type RequestBodySummaryDetail struct {
ReqBody, OldReqBody, NewReqBody *openapi3.RequestBody `json:"-"`
Properties []*PropertiesSummary `json:"properties"`
Breaking bool `json:"breaking"`
Action Action `json:"action"`
Message string `json:"message"`
Name string `json:"name"`
}
type ResponseSummaryDetail ¶
type ResponsesSummary ¶
type ResponsesSummary struct { Breaking bool `json:"breaking"` Message string `json:"message"` Details []*ResponsesSummaryDetail `json:"details"` }
type ResponsesSummaryDetail ¶
type ResponsesSummaryDetail struct {
Res, OldRes, NewRes *openapi3.Response `json:"-"`
Details []*ResponseSummaryDetail `json:"details"`
Name string `json:"name"` // status code
Description string `json:"description"`
Action Action `json:"action"`
Breaking bool `json:"breaking"`
Message string `json:"message"`
}
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.
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.
func (*ResultSummary) String ¶
func (m *ResultSummary) String() string
type RuleFindings ¶
type RuleFindingsStats ¶
RuleFindingsStats contains stats of RuleFindings.
type SecuritySummary ¶
type SecuritySummary struct { Breaking bool `json:"breaking"` Message string `json:"message"` Details []*SecuritySummaryDetail `json:"details"` }
type SecuritySummaryDetail ¶
type Service ¶
type Service struct { ID string `json:"id,omitempty"` AdditionalInfo map[string]interface{} `json:"additional_info"` Contact interface{} `json:"contact"` Description string `json:"description"` NameID string `json:"name_id"` OrganizationID string `json:"organization_id"` ProductTag string `json:"product_tag"` Title string `json:"title"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` AnalyzersConfigs AnalyzerConfigMap `json:"analyzers_configs,omitempty"` Summary *ServiceSummary `json:"summary"` }
Service represents a service
type ServiceList ¶
type ServiceList []*Service
func (ServiceList) Print ¶
func (m ServiceList) Print(w io.Writer)
type ServiceSummary ¶
type SeverityName ¶
type SeverityName string
func (SeverityName) Severity ¶
func (n SeverityName) Severity() Severity
func (SeverityName) String ¶
func (n SeverityName) String() string
type SeverityRuleFindings ¶
type SeverityRuleFindings map[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"` Hint *RuleFindingsStats `json:"hint"` Info *RuleFindingsStats `json:"info"` Warning *RuleFindingsStats `json:"warning"` Error *RuleFindingsStats `json:"error"` }
SeverityRuleFindingsStats contains stats of SeverityRuleFindings.
func (*SeverityRuleFindingsStats) TotalError ¶
func (s *SeverityRuleFindingsStats) TotalError() int
func (*SeverityRuleFindingsStats) TotalHint ¶
func (s *SeverityRuleFindingsStats) TotalHint() int
func (*SeverityRuleFindingsStats) TotalInfo ¶
func (s *SeverityRuleFindingsStats) TotalInfo() int
func (*SeverityRuleFindingsStats) TotalWarning ¶
func (s *SeverityRuleFindingsStats) TotalWarning() int
type Spec ¶
type Spec struct { ID string `json:"id,omitempty" validate:"required"` Doc SpecDoc `json:"doc"` DocType string `json:"doc_type"` Revision string `json:"revision"` Score int `json:"score"` ServiceID string `json:"service_id"` State string `json:"state"` // Archive, Releases, Development, Latest Valid string `json:"valid"` Version string `json:"version"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
Spec represents a spec
type SpecAnalysis ¶
type SpecAnalysis struct { ID string `json:"id,omitempty" validate:"required"` Analyzer SpecAnalyzer `json:"analyzer"` Config *AnalyzerConfig `json:"config,omitempty"` Result *Result `json:"result"` Score int `json:"score"` ServiceID string `json:"service_id"` SpecID string `json:"spec_id"` Status string `json:"status"` // Submitted, Invalid, Analyzed CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
SpecAnalysis represents a specAnalysis
type SpecAnalysisList ¶
type SpecAnalysisList []*SpecAnalysis
func (SpecAnalysisList) Print ¶
func (m SpecAnalysisList) Print(w io.Writer)
type SpecAnalysisRequest ¶
type SpecAnalysisRequest struct { Analyzers []SpecAnalyzer `json:"analyzers"` AnalyzersConfigs map[SpecAnalyzer]*AnalyzerConfig `json:"analyzers_configs,omitempty"` Spec *Spec `json:"spec,omitempty"` Service *Service `json:"service,omitempty"` }
SpecAnalysisRequest represents a request for a SpecAnalysis
type SpecAnalysisResponse ¶
type SpecAnalysisResponse struct { Results map[SpecAnalyzer]*SpecAnalysis `json:"results,omitempty"` SpecScore int `json:"spec_score"` }
func (*SpecAnalysisResponse) ExitCode ¶
func (s *SpecAnalysisResponse) ExitCode() int
ExitCode returns exit code as per analysis findings
type SpecAnalyzer ¶
type SpecAnalyzer string
type SpecDiff ¶
type SpecDiff struct { ID string `json:"id,omitempty" validate:"required"` *SpecDiffRequest Result *SpecDiffResult `json:"result"` ServiceID string `json:"service_id,omitempty"` Status string `json:"status,omitempty"` // Submitted, Invalid, Diffed CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
SpecDiff represents a specDiff
func (*SpecDiff) HasBreakingChangesInJSON ¶
type SpecDiffConfig ¶
type SpecDiffConfig struct {
OutputFormat string `json:"output_format,omitempty"` // json, html, markdown, text
}
SpecDiffConfig represents configs for a SpecDiff (SpecDiff.Config)
type SpecDiffList ¶
type SpecDiffList []*SpecDiff
func (SpecDiffList) Print ¶
func (m SpecDiffList) Print(w io.Writer)
type SpecDiffRequest ¶
type SpecDiffRequest struct { NewSpecID string `json:"new_spec_id,omitempty"` OldSpecID string `json:"old_spec_id,omitempty"` OldSpecDoc SpecDoc `json:"old_spec_doc,omitempty"` NewSpecDoc SpecDoc `json:"new_spec_doc,omitempty"` Config *SpecDiffConfig `json:"config,omitempty"` }
type SpecDiffResult ¶
type SpecDiffResult struct { JSON *JSONResult `json:"json,omitempty"` HTML string `json:"html,omitempty"` Markdown string `json:"markdown,omitempty"` Text string `json:"text,omitempty"` }
SpecDiffResult represents the result for a models.SpecDiff (SpecDiff.JSONResult)