-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathplugin.go
More file actions
25 lines (22 loc) · 870 Bytes
/
plugin.go
File metadata and controls
25 lines (22 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright 2026 The go-yaml Project Contributors
// SPDX-License-Identifier: Apache-2.0
package yaml
// LimitPlugin configures safety limits for YAML parsing.
//
// When registered, CheckDepth is called on each nesting depth increase,
// and CheckAlias is called on each alias expansion to detect excessive
// aliasing.
//
// Example usage:
//
// import "go.yaml.in/yaml/v4/plugin/limit"
// loader := yaml.NewLoader(data, yaml.WithPlugin(limit.New(limit.AliasNone())))
type LimitPlugin interface {
// CheckDepth is called when the parser increases nesting depth.
// depth is the current nesting level; ctx.Kind is "flow" or "block".
// Return an error to abort parsing.
CheckDepth(depth int, ctx *DepthContext) error
// CheckAlias is called during alias expansion.
// Return an error to abort construction.
CheckAlias(aliasCount, constructCount int) error
}