linter

package
v1.11.2 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ACL_SYNTAX                           = "acl/syntax"
	ACL_DUPLICATED                       = "acl/duplicated"
	BACKEND_SYNTAX                       = "backend/syntax"
	BACKEND_DUPLICATED                   = "backend/duplicated"
	BACKEND_NOTFOUND                     = "backend/notfound"
	BACKEND_PROBER_CONFIGURATION         = "backend/prober-configuration"
	DIRECTOR_SYNTAX                      = "director/syntax"
	DIRECTOR_DUPLICATED                  = "director/duplicated"
	DIRECTOR_PROPS_RANDOM                = "director/props-random"
	DIRECTOR_PROPS_FALLBACK              = "director/props-fallback"
	DIRECTOR_PROPS_HASH                  = "director/props-hash"
	DIRECTOR_PROPS_CLIENT                = "director/props-client"
	DIRECTOR_PROPS_CHASH                 = "director/props-chash"
	DIRECTOR_BACKEND_REQUIRED            = "director/backend-required"
	TABLE_SYNTAX                         = "table/syntax"
	TABLE_TYPE_VARIATION                 = "table/type-variation"
	TABLE_ITEM_LIMITATION                = "table/item-limitation"
	TABLE_DUPLICATED                     = "table/duplicated"
	SUBROUTINE_SYNTAX                    = "subroutine/syntax"
	SUBROUTINE_BOILERPLATE_MACRO         = "subroutine/boilerplate-macro"
	SUBROUTINE_DUPLICATED                = "subroutine/duplicated"
	SUBROUTINE_INVALID_RETURN_TYPE       = "subroutine/invalid-return-type"
	UNRECOGNIZE_CALL_SCOPE               = "subroutine/unrecognize-call-scope"
	FORBID_VCL_PIPE                      = "subroutine/forbid-vcl-pipe"
	PENALTYBOX_SYNTAX                    = "penaltybox/syntax"
	PENALTYBOX_DUPLICATED                = "penaltybox/duplicated"
	PENALTYBOX_NONEMPTY_BLOCK            = "penaltybox/nonempty-block"
	RATECOUNTER_SYNTAX                   = "ratecounter/syntax"
	RATECOUNTER_DUPLICATED               = "ratecounter/duplicated"
	RATECOUNTER_NONEMPTY_BLOCK           = "ratecounter/nonempty-block"
	DECLARE_STATEMENT_SYNTAX             = "declare-statement/syntax"
	DECLARE_STATEMENT_INVALID_TYPE       = "declare-statement/invalid-type"
	DECLARE_STATEMENT_DUPLICATED         = "declare-statement/duplicated"
	SET_STATEMENT_SYNTAX                 = "set-statement/syntax"
	OPERATOR_ASSIGNMENT                  = "operator/assignment"
	UNSET_STATEMENT_SYNTAX               = "unset-statement/syntax"
	REMOVE_STATEMENT_SYNTAX              = "remote-statement/syntax"
	OPERATOR_CONDITIONAL                 = "operator/conditional"
	RESTART_STATEMENT_SCOPE              = "restart-statement/scope"
	ADD_STATEMENT_SYNTAX                 = "add-statement/syntax"
	CALL_STATEMENT_SYNTAX                = "call-statement/syntax"
	CALL_STATEMENT_SUBROUTINE_NOTFOUND   = "call-statement/subroutine-notfound"
	ERROR_STATEMENT_SCOPE                = "error-statement/scope"
	ERROR_STATEMENT_CODE                 = "error-statement/code"
	SYNTHETIC_STATEMENT_SCOPE            = "synthetic-statement/scope"
	SYNTHETIC_BASE64_STATEMENT_SCOPE     = "synthetic-base64-statement/scope"
	GOTO_DUPLICATED                      = "goto/duplicated"
	GOTO_SYNTAX                          = "goto/syntax"
	CONDITION_LITERAL                    = "condition/literal"
	VALID_IP                             = "valid-ip"
	FUNCTION_ARGUMENTS                   = "function/arguments"
	FUNCTION_ARGUMENT_TYPE               = "function/argument-type"
	INCLUDE_STATEMENT_MODULE_NOT_FOUND   = "include/module-not-found"
	INCLUDE_STATEMENT_MODULE_LOAD_FAILED = "include/module-load-failed"
	REGEX_MATCHED_VALUE_MAY_OVERRIDE     = "regex/matched-value-override"
	UNUSED_DECLARATION                   = "unused/declaration"
	UNUSED_VARIABLE                      = "unused/variable"
	UNUSED_GOTO                          = "unused/goto"
	DISALLOW_EMPTY_RETURN                = "disallow-empty-return"
	FORBIDDEN_BACKWARD_JUMP              = "goto/forbidden-backward-jump"
	TIME_CALCULATION                     = "operator/time-calculation"
	DEPRECATED                           = "deprecated"
)
View Source
const CustomCommandPrefix = "falco-"

Variables

View Source
var BackendProbePropertyTypes = map[string]types.Type{
	"dummy":             types.BoolType,
	"request":           types.StringType,
	"expected_response": types.IntegerType,
	"interval":          types.RTimeType,
	"timeout":           types.RTimeType,
	"window":            types.IntegerType,
	"initial":           types.IntegerType,
	"threshold":         types.IntegerType,
	"url":               types.StringType,
}
View Source
var BackendPropertyTypes = map[string]types.Type{
	"dynamic":                  types.BoolType,
	"share_key":                types.StringType,
	"host":                     types.StringType,
	"port":                     types.StringType,
	"ssl":                      types.BoolType,
	"ssl_cert_hostname":        types.StringType,
	"max_tls_version":          types.StringType,
	"min_tls_version":          types.StringType,
	"ssl_check_cert":           types.IDType,
	"ssl_sni_hostname":         types.StringType,
	"between_bytes_timeout":    types.RTimeType,
	"connect_timeout":          types.RTimeType,
	"first_byte_timeout":       types.RTimeType,
	"keepalive_time":           types.RTimeType,
	"max_connections":          types.IntegerType,
	"host_header":              types.StringType,
	"always_use_host_header":   types.BoolType,
	"bypass_local_route_table": types.BoolType,
}
View Source
var DirectorPropertyTypes = map[string]DirectorProps{
	"random": {
		Rule: DIRECTOR_PROPS_RANDOM,
		Props: map[string]types.Type{
			"retries": types.IntegerType,
			"quorum":  types.IntegerType,
			"backend": types.BackendType,
			"weight":  types.IntegerType,
		},
		Requires: []string{"weight"},
	},
	"fallback": {
		Rule: DIRECTOR_PROPS_FALLBACK,
		Props: map[string]types.Type{
			"backend": types.BackendType,
		},
		Requires: []string{},
	},
	"hash": {
		Rule: DIRECTOR_PROPS_HASH,
		Props: map[string]types.Type{
			"quorum":  types.IntegerType,
			"backend": types.BackendType,
			"weight":  types.IntegerType,
		},
		Requires: []string{"weight"},
	},
	"client": {
		Rule: DIRECTOR_PROPS_CLIENT,
		Props: map[string]types.Type{
			"quorum":  types.IntegerType,
			"backend": types.BackendType,
			"weight":  types.IntegerType,
		},
		Requires: []string{"weight"},
	},
	"chash": {
		Rule: DIRECTOR_PROPS_CHASH,
		Props: map[string]types.Type{
			"key":             types.BackendType,
			"seed":            types.IntegerType,
			"vnodes_per_node": types.IntegerType,
			"quorum":          types.IntegerType,
			"weight":          types.IntegerType,
			"id":              types.StringType,
			"backend":         types.BackendType,
		},
		Requires: []string{"id"},
	},
	"shield": {

		Props: map[string]types.Type{
			"shield": types.StringType,
			"is_ssl": types.BoolType,
		},
		Requires: []string{"shield"},
	},
}

Functions

This section is empty.

Types

type CustomLinterCall added in v1.8.0

type CustomLinterCall struct {
	// contains filtered or unexported fields
}

func (CustomLinterCall) Rule added in v1.8.0

func (c CustomLinterCall) Rule() string

type DirectorProps

type DirectorProps struct {
	Rule     Rule
	Props    map[string]types.Type
	Requires []string
}

type FatalError added in v0.9.3

type FatalError struct {
	Lexer *lexer.Lexer
	Error error
}

type LintError

type LintError struct {
	Severity  Severity
	Token     token.Token
	Message   string
	Reference string
	Rule      Rule
}

func AccessDenied added in v0.9.3

func AccessDenied(m *ast.Meta, name, scope string) *LintError

func CustomLinterCommandFailed added in v1.8.0

func CustomLinterCommandFailed(message string, m *ast.Meta) *LintError

func CustomLinterCommandNotFound added in v1.8.0

func CustomLinterCommandNotFound(name string, m *ast.Meta) *LintError

func DeprecatedVariable added in v1.11.0

func DeprecatedVariable(name string, m *ast.Meta) *LintError

func Duplicated

func Duplicated(m *ast.Meta, name, ident string) *LintError

func DuplicatedUseForGotoDestination added in v0.9.3

func DuplicatedUseForGotoDestination(m *ast.Meta, name string) *LintError

func ErrorCodeRange

func ErrorCodeRange(m *ast.Meta, code int64) *LintError

func ForbiddenBackwardJump added in v1.7.0

func ForbiddenBackwardJump(gs *ast.GotoStatement) *LintError

func FromPluginError added in v1.8.0

func FromPluginError(pe *plugin.Error, m *ast.Meta) *LintError

func FunctionArgumentMismatch

func FunctionArgumentMismatch(m *ast.Meta, name string, expect, actual int) *LintError

func FunctionArgumentTypeMismatch

func FunctionArgumentTypeMismatch(m *ast.Meta, name string, num int, expect, actual types.Type) *LintError

func ImplicitTypeConversion

func ImplicitTypeConversion(m *ast.Meta, from, to types.Type) *LintError

func InvalidName

func InvalidName(m *ast.Meta, name, ident string) *LintError

func InvalidOperation

func InvalidOperation(m *ast.Meta, name, operation string) *LintError

func InvalidOperator

func InvalidOperator(m *ast.Meta, op string, left types.Type) *LintError

func InvalidReturnState

func InvalidReturnState(m *ast.Meta, scope, state string, expects ...string) *LintError

func InvalidStringConcatenation added in v1.11.0

func InvalidStringConcatenation(m *ast.Meta, ts string) *LintError

func InvalidType

func InvalidType(m *ast.Meta, name string, expect, actual types.Type) *LintError

InvalidType raises ERROR due to strict type assertion failed. Actually, it cause compile error for that VCL.

func InvalidTypeComparison

func InvalidTypeComparison(m *ast.Meta, left, right types.Type) *LintError

func InvalidTypeConversion

func InvalidTypeConversion(m *ast.Meta, vclType string) *LintError

func InvalidTypeExpression

func InvalidTypeExpression(m *ast.Meta, actual types.Type, expects ...types.Type) *LintError

func InvalidTypeOperator

func InvalidTypeOperator(m *ast.Meta, op string, left, right types.Type) *LintError

func InvalidValue

func InvalidValue(m *ast.Meta, tt, val string) *LintError

func NonEmptyPenaltyboxBlock added in v0.9.3

func NonEmptyPenaltyboxBlock(m *ast.Meta, name string) *LintError

func NonEmptyRatecounterBlock added in v0.9.3

func NonEmptyRatecounterBlock(m *ast.Meta, name string) *LintError

func NotFunction

func NotFunction(m *ast.Meta, name string) *LintError

func ProtectedHTTPHeader added in v0.9.3

func ProtectedHTTPHeader(m *ast.Meta, name string) *LintError

func TimeCalculatation added in v1.11.0

func TimeCalculatation(m *ast.Meta) *LintError

func UndefinedAcl

func UndefinedAcl(m *ast.Meta, name string) *LintError

func UndefinedBackend

func UndefinedBackend(m *ast.Meta, name string) *LintError

func UndefinedBackendProperty

func UndefinedBackendProperty(m *ast.Meta, name string) *LintError

func UndefinedDirectorProperty

func UndefinedDirectorProperty(m *ast.Meta, name, dt string) *LintError

func UndefinedFunction

func UndefinedFunction(m *ast.Meta, name string) *LintError

func UndefinedGotoDestination added in v0.9.3

func UndefinedGotoDestination(m *ast.Meta, name string) *LintError

func UndefinedSubroutine

func UndefinedSubroutine(m *ast.Meta, name string) *LintError

func UndefinedTableType

func UndefinedTableType(m *ast.Meta, name, tt string) *LintError

func UndefinedVariable

func UndefinedVariable(m *ast.Meta, name string) *LintError

func UnusedDeclaration added in v0.6.0

func UnusedDeclaration(m *ast.Meta, name, declType string) *LintError

func UnusedExternalDeclaration added in v0.9.3

func UnusedExternalDeclaration(name, declType string) *LintError

func UnusedVariable added in v0.6.0

func UnusedVariable(m *ast.Meta, name string) *LintError

func (*LintError) Error

func (e *LintError) Error() string

func (*LintError) Match

func (l *LintError) Match(r Rule) *LintError

func (*LintError) Ref

func (e *LintError) Ref(url string) *LintError

type Linter

type Linter struct {
	Errors     []*LintError
	FatalError *FatalError
	// contains filtered or unexported fields
}

func New

func New(c *config.LinterConfig, opts ...optionFunc) *Linter

func (*Linter) Error

func (l *Linter) Error(err error)

func (*Linter) Lexers added in v0.9.3

func (l *Linter) Lexers() map[string]*lexer.Lexer

func (*Linter) Lint

func (l *Linter) Lint(node ast.Node, ctx *context.Context) types.Type

Expose lint function to call from external program. It means this method is bootstrap, called only once.

type Rule

type Rule string

func (Rule) Reference

func (r Rule) Reference() string

type Series added in v1.11.0

type Series struct {
	Operator   string // Operator will accept either of "+" or "-" or empty string.
	Expression ast.Expression
}

Series expresses the series of string concatenation.

type Severity

type Severity string
const (
	WARNING Severity = "Warning"
	ERROR   Severity = "Error"
	INFO    Severity = "Info"
	IGNORE  Severity = "Ignore"
)

Jump to

Keyboard shortcuts

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