Documentation
¶
Index ¶
- Constants
- func BuildResults(silent bool, hardMode bool, rulesetFlag string, specBytes []byte, ...) (*model.RuleResultSet, *motor.RuleSetExecutionResult, error)
- func BuildResultsWithDocCheckSkip(silent bool, hardMode bool, rulesetFlag string, specBytes []byte, ...) (*model.RuleResultSet, *motor.RuleSetExecutionResult, error)
- func BuildRuleSetFromUserSuppliedLocation(rulesetFlag string, rs rulesets.RuleSets, remote bool, httpClient *http.Client) (*rulesets.RuleSet, error)
- func BuildRuleSetFromUserSuppliedSet(rsBytes []byte, rs rulesets.RuleSets) (*rulesets.RuleSet, error)
- func BuildRuleSetFromUserSuppliedSetWithHTTPClient(rsBytes []byte, rs rulesets.RuleSets, httpClient *http.Client) (*rulesets.RuleSet, error)
- func CheckFailureSeverity(failSeverityFlag string, errors int, warnings int, informs int) error
- func CreateHTTPClientFromFlags(flags *LintFlags) (*http.Client, error)
- func Execute()
- func ExtractSpecFromReport(report *vacuum_report.VacuumReport) ([]byte, string, error)
- func GetBundleCommand() *cobra.Command
- func GetCommit() string
- func GetDashboardCommand() *cobra.Command
- func GetDate() string
- func GetGenerateIgnoreFileCommand() *cobra.Command
- func GetGenerateRulesetCommand() *cobra.Command
- func GetGenerateVersionCommand() *cobra.Command
- func GetHTMLReportCommand() *cobra.Command
- func GetHTTPClientConfig(flags *LintFlags) utils.HTTPClientConfig
- func GetLanguageServerCommand() *cobra.Command
- func GetLintCommand() *cobra.Command
- func GetRootCommand() *cobra.Command
- func GetSpectralReportCommand() *cobra.Command
- func GetVacuumReportCommand() *cobra.Command
- func GetVersion() string
- func IsVacuumReport(filePath string) bool
- func LoadCustomFunctions(functionsFlag string, silence bool) (map[string]model.RuleFunction, error)
- func LoadIgnoreFile(ignoreFile string, silent, pipeline, noStyle bool) (model.IgnoredItems, error)
- func LoadReportOnly(filePath string) (*vacuum_report.VacuumReport, error)
- func LoadRulesetWithConfig(flags *LintFlags, logger *slog.Logger) (*rulesets.RuleSet, error)
- func MergeOWASPRulesToRuleSet(selectedRS *rulesets.RuleSet, hardModeFlag bool) bool
- func PrintBanner(noStyle ...bool)
- func RenderBufferedLogs(bufferedLogger *logging.BufferedLogger, noStyle bool)
- func RenderMarkdownSummary(rso RenderSummaryOptions)
- func RenderTime(timeFlag bool, duration time.Duration, fi int64)
- func RenderTimeAndFiles(timeFlag bool, duration time.Duration, fileSize int64, totalFiles int)
- func ResolveBasePathForFile(specFilePath string, baseFlag string) (string, error)
- func SetupVacuumEnvironment(flags *LintFlags)
- type FileProcessingConfig
- type FileProcessingResult
- type LintFlags
- type RenderDetailsOptions
- type RenderSummaryOptions
- type ReportLoadResult
- type SeverityInfo
- type TableConfig
- type VersionInfo
Constants ¶
const ( // SummaryTableWidthFull is the width of summary tables for terminals >= 100 width // Calculated as: 40 (rule) + 12 (violations) + 50 (impact) + 4 (spacing) + 1 (leading) = 107 SummaryTableWidthFull = 107 // SummaryTableWidthMedium is the width for terminals 80-99 width // Calculated as: 25 (rule) + 10 (violations) + 30 (impact) + 4 (spacing) + 1 (leading) = 70 SummaryTableWidthMedium = 70 // SummaryTableWidthSmall is the width for terminals 60-79 width // Calculated as: 20 (rule) + 8 (violations) + 20 (impact) + 4 (spacing) + 1 (leading) = 53 SummaryTableWidthSmall = 53 )
Constants for summary table widths at different terminal sizes
const ( HardModeEnabled = "🚨 HARD MODE ENABLED 🚨" HardModeWithCustomRuleset = "🚨 OWASP Rules added to custom ruleset 🚨" )
Hard mode message constants
Variables ¶
This section is empty.
Functions ¶
func BuildResults ¶ added in v0.0.4
func BuildResults( silent bool, hardMode bool, rulesetFlag string, specBytes []byte, customFunctions map[string]model.RuleFunction, base string, remote bool, timeout time.Duration, httpClientConfig utils.HTTPClientConfig, ignoredItems model.IgnoredItems) (*model.RuleResultSet, *motor.RuleSetExecutionResult, error)
func BuildResultsWithDocCheckSkip ¶ added in v0.2.7
func BuildResultsWithDocCheckSkip( silent bool, hardMode bool, rulesetFlag string, specBytes []byte, customFunctions map[string]model.RuleFunction, base string, remote bool, skipCheck bool, timeout time.Duration, httpClientConfig utils.HTTPClientConfig, ignoredItems model.IgnoredItems) (*model.RuleResultSet, *motor.RuleSetExecutionResult, error)
func BuildRuleSetFromUserSuppliedLocation ¶ added in v0.17.8
func BuildRuleSetFromUserSuppliedLocation(rulesetFlag string, rs rulesets.RuleSets, remote bool, httpClient *http.Client) (*rulesets.RuleSet, error)
BuildRuleSetFromUserSuppliedLocation creates a ready to run ruleset from a location (file path or URL)
func BuildRuleSetFromUserSuppliedSet ¶ added in v0.0.5
func BuildRuleSetFromUserSuppliedSet(rsBytes []byte, rs rulesets.RuleSets) (*rulesets.RuleSet, error)
BuildRuleSetFromUserSuppliedSet creates a ready to run ruleset, augmented or provided by a user configured ruleset. This ruleset could be lifted directly from a Spectral configuration.
func BuildRuleSetFromUserSuppliedSetWithHTTPClient ¶ added in v0.17.8
func BuildRuleSetFromUserSuppliedSetWithHTTPClient(rsBytes []byte, rs rulesets.RuleSets, httpClient *http.Client) (*rulesets.RuleSet, error)
BuildRuleSetFromUserSuppliedSetWithHTTPClient creates a ready to run ruleset, augmented or provided by a user configured ruleset with HTTP client support for certificate authentication.
func CheckFailureSeverity ¶ added in v0.0.16
func CreateHTTPClientFromFlags ¶ added in v0.18.0
CreateHTTPClientFromFlags creates an HTTP client based on certificate flags
func ExtractSpecFromReport ¶ added in v0.18.0
func ExtractSpecFromReport(report *vacuum_report.VacuumReport) ([]byte, string, error)
ExtractSpecFromReport extracts the specification bytes from a vacuum report. Returns the spec bytes and the original filename if available.
func GetBundleCommand ¶ added in v0.8.0
func GetCommit ¶ added in v0.18.0
func GetCommit() string
GetCommit returns the current commit hash for compatibility
func GetDashboardCommand ¶
func GetDate ¶ added in v0.18.0
func GetDate() string
GetDate returns the current build date for compatibility
func GetGenerateIgnoreFileCommand ¶ added in v0.15.0
func GetGenerateRulesetCommand ¶ added in v0.0.5
func GetGenerateVersionCommand ¶ added in v0.6.0
func GetHTMLReportCommand ¶ added in v0.0.2
GetHTMLReportCommand returns a cobra command for generating an HTML Report.
func GetHTTPClientConfig ¶ added in v0.18.0
func GetHTTPClientConfig(flags *LintFlags) utils.HTTPClientConfig
GetHTTPClientConfig creates HTTPClientConfig from flags
func GetLanguageServerCommand ¶ added in v0.9.0
func GetLintCommand ¶ added in v0.0.5
func GetRootCommand ¶ added in v0.3.5
func GetVacuumReportCommand ¶ added in v0.0.4
func GetVersion ¶ added in v0.18.0
func GetVersion() string
GetVersion returns the current version string for compatibility
func IsVacuumReport ¶ added in v0.18.0
IsVacuumReport checks if a file is a vacuum report without fully loading it
func LoadCustomFunctions ¶ added in v0.0.11
LoadCustomFunctions will scan for (and load) custom functions defined as vacuum plugins.
func LoadIgnoreFile ¶ added in v0.18.0
func LoadIgnoreFile(ignoreFile string, silent, pipeline, noStyle bool) (model.IgnoredItems, error)
LoadIgnoreFile loads and parses the ignore file if specified
func LoadReportOnly ¶ added in v0.18.0
func LoadReportOnly(filePath string) (*vacuum_report.VacuumReport, error)
LoadReportOnly attempts to load a file specifically as a vacuum report. Returns an error if the file is not a valid vacuum report.
func LoadRulesetWithConfig ¶ added in v0.18.0
LoadRulesetWithConfig loads and configures the ruleset based on flags
func MergeOWASPRulesToRuleSet ¶ added in v0.17.11
MergeOWASPRulesToRuleSet merges OWASP rules into the provided ruleset when hard mode is enabled. This fixes issue #552 where -z flag was ignored when using -r flag. Returns true if OWASP rules were merged, false otherwise.
func PrintBanner ¶ added in v0.0.5
func PrintBanner(noStyle ...bool)
func RenderBufferedLogs ¶ added in v0.18.0
func RenderBufferedLogs(bufferedLogger *logging.BufferedLogger, noStyle bool)
RenderBufferedLogs renders the buffered logs with proper formatting and spacing
func RenderMarkdownSummary ¶ added in v0.18.0
func RenderMarkdownSummary(rso RenderSummaryOptions)
func RenderTime ¶ added in v0.0.5
RenderTime will render out the time taken to process a specification, and the size of the file in kb.
func RenderTimeAndFiles ¶ added in v0.5.1
RenderTimeAndFiles will render out the time taken to process a specification, and the size of the file in kb. it will also render out how many files were processed.
func ResolveBasePathForFile ¶ added in v0.18.1
ResolveBasePathForFile determines the base path to use for a given spec file. If baseFlag is explicitly set (not empty), it returns that value unchanged. If baseFlag is empty, it returns the absolute directory of the spec file.
func SetupVacuumEnvironment ¶ added in v0.18.0
func SetupVacuumEnvironment(flags *LintFlags)
SetupVacuumEnvironment configures the environment based on flags
Types ¶
type FileProcessingConfig ¶ added in v0.18.0
type FileProcessingConfig struct {
Flags *LintFlags
Logger *slog.Logger
BufferedLogger *logging.BufferedLogger
SelectedRuleset *rulesets.RuleSet
CustomFunctions map[string]model.RuleFunction
IgnoredItems model.IgnoredItems
}
FileProcessingConfig contains all configuration needed to process a file
type FileProcessingResult ¶ added in v0.18.0
type FileProcessingResult struct {
Results []*model.RuleFunctionResult
Errors int
Warnings int
Informs int
FileSize int64
Logs []string
Error error
}
FileProcessingResult contains the results of processing a single file
func ProcessSingleFileOptimized ¶ added in v0.18.0
func ProcessSingleFileOptimized(fileName string, config *FileProcessingConfig) *FileProcessingResult
ProcessSingleFileOptimized processes a single file using pre-loaded configuration
type LintFlags ¶ added in v0.18.0
type LintFlags struct {
GlobPattern string
DetailsFlag bool
SnippetsFlag bool
ErrorsFlag bool
CategoryFlag string
SilentFlag bool
NoStyleFlag bool
NoBannerFlag bool
NoMessageFlag bool
AllResultsFlag bool
ShowRules bool
PipelineOutput bool
FailSeverityFlag string
BaseFlag string
RemoteFlag bool
SkipCheckFlag bool
TimeoutFlag int
RulesetFlag string
FunctionsFlag string
TimeFlag bool
HardModeFlag bool
IgnoreFile string
NoClipFlag bool
ExtRefsFlag bool
IgnoreArrayCircleRef bool
IgnorePolymorphCircleRef bool
MinScore int
CertFile string
KeyFile string
CAFile string
Insecure bool
DebugFlag bool
}
LintFlags holds all the command line flags for lint operations
func ReadLintFlags ¶ added in v0.18.0
ReadLintFlags reads all lint-related flags from the command
type RenderDetailsOptions ¶ added in v0.18.0
type RenderDetailsOptions struct {
Results []*model.RuleFunctionResult
SpecData []string
Snippets bool
Errors bool
Silent bool
NoMessage bool
AllResults bool
NoClip bool
FileName string
NoStyle bool
}
RenderDetailsOptions contains all options for rendering detailed results
type RenderSummaryOptions ¶ added in v0.16.15
type RenderSummaryOptions struct {
RuleResultSet *model.RuleResultSet
RuleSet *rulesets.RuleSet
RuleCategories []*model.RuleCategory
Statistics *reports.ReportStatistics
Filename string
Silent bool
NoStyle bool
PipelineOutput bool
ShowRules bool
RenderRules bool
ReportStats *reports.ReportStatistics
TotalFiles int
Severity string
}
RenderSummaryOptions contains all options for rendering summary
type ReportLoadResult ¶ added in v0.18.0
type ReportLoadResult struct {
// If the file was a pre-compiled report
IsReport bool
Report *vacuum_report.VacuumReport
// The raw spec bytes (either from file or extracted from report)
SpecBytes []byte
// The filename/path for display
FileName string
// Pre-processed results if from a report
ResultSet *model.RuleResultSet
}
ReportLoadResult contains the results of attempting to load a file as either a pre-compiled vacuum report or raw OpenAPI spec
func LoadFileAsReportOrSpec ¶ added in v0.18.0
func LoadFileAsReportOrSpec(filePath string) (*ReportLoadResult, error)
LoadFileAsReportOrSpec attempts to load a file as either a pre-compiled vacuum report or as a raw OpenAPI specification. It returns a ReportLoadResult with all the necessary data for either case.
type SeverityInfo ¶ added in v0.18.0
SeverityInfo holds severity display information
type TableConfig ¶ added in v0.18.0
type TableConfig struct {
Width int
ShowCategory bool
ShowPath bool
ShowRule bool
UseTreeFormat bool
LocationWidth int
SeverityWidth int
MessageWidth int
RuleWidth int
CategoryWidth int
PathWidth int
NoMessage bool
NoClip bool
NoStyle bool
}
TableConfig holds all table configuration and column widths
type VersionInfo ¶ added in v0.18.0
func GetVersionInfo ¶ added in v0.18.0
func GetVersionInfo() VersionInfo
GetVersionInfo returns version information using modern debug.ReadBuildInfo approach this works correctly with go install unlike the old ldflags method
Source Files
¶
- build_results.go
- bundle.go
- dashboard.go
- generate_ignorefile.go
- generate_ruleset.go
- html_report.go
- language_server.go
- lint_cmd.go
- lint_details_view_render.go
- lint_process_multifile.go
- lint_render_summary_markdown.go
- lint_render_summary_view.go
- lint_shared.go
- render_options.go
- report_loader.go
- root.go
- shared_functions.go
- spectral_report.go
- vacuum_report.go
- version.go
- version_info.go