rule

package
v1.2210.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: MPL-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RuleTypeGlobalConfig       = "全局配置"
	RuleTypeNamingConvention   = "命名规范"
	RuleTypeIndexingConvention = "索引规范"
	RuleTypeDDLConvention      = "DDL规范"
	RuleTypeDMLConvention      = "DML规范"
	RuleTypeUsageSuggestion    = "使用建议"
	RuleTypeIndexOptimization  = "索引优化"
)

rule type

View Source
const (
	DDLCheckPKWithoutIfNotExists                       = "ddl_check_table_without_if_not_exists"
	DDLCheckObjectNameLength                           = "ddl_check_object_name_length"
	DDLCheckObjectNameUsingKeyword                     = "ddl_check_object_name_using_keyword"
	DDLCheckPKNotExist                                 = "ddl_check_pk_not_exist"
	DDLCheckPKWithoutBigintUnsigned                    = "ddl_check_pk_without_bigint_unsigned"
	DDLCheckPKWithoutAutoIncrement                     = "ddl_check_pk_without_auto_increment"
	DDLCheckPKProhibitAutoIncrement                    = "ddl_check_pk_prohibit_auto_increment"
	DDLCheckColumnCharLength                           = "ddl_check_column_char_length"
	DDLDisableFK                                       = "ddl_disable_fk"
	DDLCheckIndexCount                                 = "ddl_check_index_count"
	DDLCheckCompositeIndexMax                          = "ddl_check_composite_index_max"
	DDLCheckTableDBEngine                              = "ddl_check_table_db_engine"
	DDLCheckTableCharacterSet                          = "ddl_check_table_character_set"
	DDLCheckIndexedColumnWithBlob                      = "ddl_check_index_column_with_blob"
	DDLCheckAlterTableNeedMerge                        = "ddl_check_alter_table_need_merge"
	DDLDisableDropStatement                            = "ddl_disable_drop_statement"
	DDLCheckTableWithoutComment                        = "ddl_check_table_without_comment"
	DDLCheckColumnWithoutComment                       = "ddl_check_column_without_comment"
	DDLCheckIndexPrefix                                = "ddl_check_index_prefix"
	DDLCheckUniqueIndexPrefix                          = "ddl_check_unique_index_prefix"
	DDLCheckUniqueIndex                                = "ddl_check_unique_index"
	DDLCheckColumnWithoutDefault                       = "ddl_check_column_without_default"
	DDLCheckColumnTimestampWithoutDefault              = "ddl_check_column_timestamp_without_default"
	DDLCheckColumnBlobWithNotNull                      = "ddl_check_column_blob_with_not_null"
	DDLCheckColumnBlobDefaultIsNotNull                 = "ddl_check_column_blob_default_is_not_null"
	DDLCheckColumnEnumNotice                           = "ddl_check_column_enum_notice"
	DDLCheckColumnSetNotice                            = "ddl_check_column_set_notice"
	DDLCheckColumnBlobNotice                           = "ddl_check_column_blob_notice"
	DDLCheckIndexesExistBeforeCreateConstraints        = "ddl_check_indexes_exist_before_creat_constraints"
	DDLCheckDatabaseCollation                          = "ddl_check_collation_database"
	DDLCheckDecimalTypeColumn                          = "ddl_check_decimal_type_column"
	DDLCheckBigintInsteadOfDecimal                     = "ddl_check_bigint_instead_of_decimal"
	DDLCheckDatabaseSuffix                             = "ddl_check_database_suffix"
	DDLCheckPKName                                     = "ddl_check_pk_name"
	DDLCheckTransactionIsolationLevel                  = "ddl_check_transaction_isolation_level"
	DDLCheckTablePartition                             = "ddl_check_table_partition"
	DDLCheckIsExistLimitOffset                         = "ddl_check_is_exist_limit_offset"
	DDLCheckIndexOption                                = "ddl_check_index_option"
	DDLCheckObjectNameUseCN                            = "ddl_check_object_name_using_cn"
	DDLCheckCreateView                                 = "ddl_check_create_view"
	DDLCheckCreateTrigger                              = "ddl_check_create_trigger"
	DDLCheckCreateFunction                             = "ddl_check_create_function"
	DDLCheckCreateProcedure                            = "ddl_check_create_procedure"
	DDLCheckTableSize                                  = "ddl_check_table_size"
	DDLCheckIndexTooMany                               = "ddl_check_index_too_many"
	DDLCheckRedundantIndex                             = "ddl_check_redundant_index"
	DDLDisableTypeTimestamp                            = "ddl_disable_type_timestamp"
	DDLDisableAlterFieldUseFirstAndAfter               = "ddl_disable_alter_field_use_first_and_after"
	DDLCheckCreateTimeColumn                           = "ddl_check_create_time_column"
	DDLCheckUpdateTimeColumn                           = "ddl_check_update_time_column"
	DDLHintUpdateTableCharsetWillNotUpdateFieldCharset = "ddl_hint_update_table_charset_will_not_update_field_charset"
	DDLHintDropColumn                                  = "ddl_hint_drop_column"
	DDLHintDropPrimaryKey                              = "ddl_hint_drop_primary_key"
	DDLHintDropForeignKey                              = "ddl_hint_drop_foreign_key"
	DDLCheckFullWidthQuotationMarks                    = "ddl_check_full_width_quotation_marks"
	DDLCheckColumnQuantity                             = "ddl_check_column_quantity"
	DDLRecommendTableColumnCharsetSame                 = "ddl_table_column_charset_same"
	DDLCheckColumnTypeInteger                          = "ddl_check_column_type_integer"
	DDLCheckVarcharSize                                = "ddl_check_varchar_size"
	DDLCheckColumnQuantityInPK                         = "ddl_check_column_quantity_in_pk"
	DDLCheckAutoIncrement                              = "ddl_check_auto_increment"
	DDLNotAllowRenaming                                = "ddl_not_allow_renaming"
)

inspector DDL rules

View Source
const (
	DMLCheckWithLimit                     = "dml_check_with_limit"
	DMLCheckSelectLimit                   = "dml_check_select_limit"
	DMLCheckWithOrderBy                   = "dml_check_with_order_by"
	DMLCheckSelectWithOrderBy             = "dml_check_select_with_order_by"
	DMLCheckWhereIsInvalid                = "all_check_where_is_invalid"
	DMLDisableSelectAllColumn             = "dml_disable_select_all_column"
	DMLCheckInsertColumnsExist            = "dml_check_insert_columns_exist"
	DMLCheckBatchInsertListsMax           = "dml_check_batch_insert_lists_max"
	DMLCheckInQueryNumber                 = "dml_check_in_query_limit"
	DMLCheckWhereExistFunc                = "dml_check_where_exist_func"
	DMLCheckWhereExistNot                 = "dml_check_where_exist_not"
	DMLCheckWhereExistImplicitConversion  = "dml_check_where_exist_implicit_conversion"
	DMLCheckLimitMustExist                = "dml_check_limit_must_exist"
	DMLCheckWhereExistScalarSubquery      = "dml_check_where_exist_scalar_sub_queries"
	DMLWhereExistNull                     = "dml_check_where_exist_null"
	DMLCheckSelectForUpdate               = "dml_check_select_for_update"
	DMLCheckNeedlessFunc                  = "dml_check_needless_func"
	DMLCheckFuzzySearch                   = "dml_check_fuzzy_search"
	DMLCheckNumberOfJoinTables            = "dml_check_number_of_join_tables"
	DMLCheckIfAfterUnionDistinct          = "dml_check_is_after_union_distinct"
	DMLCheckExplainAccessTypeAll          = "dml_check_explain_access_type_all"
	DMLCheckExplainExtraUsingFilesort     = "dml_check_explain_extra_using_filesort"
	DMLCheckExplainExtraUsingTemporary    = "dml_check_explain_extra_using_temporary"
	DMLCheckTableSize                     = "dml_check_table_size"
	DMLCheckJoinFieldType                 = "dml_check_join_field_type"
	DMLCheckAlias                         = "dml_check_alias"
	DMLNotRecommendNotWildcardLike        = "dml_not_recommend_not_wildcard_like"
	DMLHintInNullOnlyFalse                = "dml_hint_in_null_only_false"
	DMLNotRecommendIn                     = "dml_not_recommend_in"
	DMLCheckSpacesAroundTheString         = "dml_check_spaces_around_the_string"
	DMLNotRecommendOrderByRand            = "dml_not_recommend_order_by_rand"
	DMLNotRecommendGroupByConstant        = "dml_not_recommend_group_by_constant"
	DMLCheckSortDirection                 = "dml_check_sort_direction"
	DMLHintGroupByRequiresConditions      = "dml_hint_group_by_requires_conditions"
	DMLNotRecommendGroupByExpression      = "dml_not_recommend_group_by_expression"
	DMLCheckSQLLength                     = "dml_check_sql_length"
	DMLNotRecommendHaving                 = "dml_not_recommend_having"
	DMLHintUseTruncateInsteadOfDelete     = "dml_hint_use_truncate_instead_of_delete"
	DMLNotRecommendUpdatePK               = "dml_not_recommend_update_pk"
	DMLNotRecommendFuncInWhere            = "dml_not_recommend_func_in_where"
	DMLNotRecommendSysdate                = "dml_not_recommend_sysdate"
	DMLHintSumFuncTips                    = "dml_hint_sum_func_tips"
	DMLHintLimitMustBeCombinedWithOrderBy = "dml_hint_limit_must_be_combined_with_order_by"
	DMLHintTruncateTips                   = "dml_hint_truncate_tips"
	DMLHintDeleteTips                     = "dml_hint_delete_tips"
	DMLCheckSQLInjectionFunc              = "dml_check_sql_injection_func"
	DMLCheckNotEqualSymbol                = "dml_check_not_equal_symbol"
	DMLNotRecommendSubquery               = "dml_not_recommend_subquery"
	DMLCheckSubqueryLimit                 = "dml_check_subquery_limit"
	DDLCheckSubQueryNestNum               = "ddl_check_sub_query_depth"
)

inspector DML rules

View Source
const (
	ConfigDMLRollbackMaxRows       = "dml_rollback_max_rows"
	ConfigDDLOSCMinSize            = "ddl_osc_min_size"
	ConfigDDLGhostMinSize          = "ddl_ghost_min_size"
	ConfigOptimizeIndexEnabled     = "optimize_index_enabled"
	ConfigDMLExplainPreCheckEnable = "dml_enable_explain_pre_check"
	ConfigSQLIsExecuted            = "sql_is_executed"
)

inspector config code

View Source
const (
	DefaultMultiParamsFirstKeyName  = "multi_params_first_key"
	DefaultMultiParamsSecondKeyName = "multi_params_second_key"
)
View Source
const DefaultSingleParamKeyName = "first_key" // For most of the rules, it is just has one param, this is first params.

Variables

View Source
var (
	RuleHandlerMap = map[string]RuleHandler{}
)
View Source
var RuleHandlers = []RuleHandler{}/* 118 elements not displayed */

Functions

This section is empty.

Types

type RuleHandler

type RuleHandler struct {
	Rule                 driver.Rule
	Message              string
	Func                 RuleHandlerFunc
	AllowOffline         bool
	NotAllowOfflineStmts []ast.Node
	// 开始事后审核时将会跳过这个值为ture的规则
	OnlyAuditNotExecutedSQL bool
	// 事后审核时将会跳过下方列表中的类型
	NotSupportExecutedSQLAuditStmts []ast.Node
}

func (*RuleHandler) IsAllowOfflineRule

func (rh *RuleHandler) IsAllowOfflineRule(node ast.Node) bool

func (*RuleHandler) IsDisableExecutedSQLRule added in v1.2208.0

func (rh *RuleHandler) IsDisableExecutedSQLRule(node ast.Node) bool

type RuleHandlerFunc added in v1.2208.0

type RuleHandlerFunc func(input *RuleHandlerInput) error

type RuleHandlerInput added in v1.2208.0

type RuleHandlerInput struct {
	Ctx  *session.Context
	Rule driver.Rule
	Res  *driver.AuditResult
	Node ast.Node
}

Jump to

Keyboard shortcuts

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