Debian Codegraph @

testdata/limit.yaml

raw symbols SCIP
1 # Copyright 2025 The go-yaml Project Contributors
2 # SPDX-License-Identifier: Apache-2.0
3
4 # Limit test cases for go-yaml
5 #
6 # Purpose: Tests YAML parser limits for deeply nested structures, excessive aliasing,
7 # and large documents. Validates that the parser properly enforces depth limits,
8 # handles large documents efficiently, and detects excessive resource usage.
9 #
10 # Format: Test cases use type-as-key format:
11 # - test-type:
12 # name: Test case name
13 # ...
14 #
15 # Test Types:
16 # limit-error - Tests that should fail with an error at resource limits
17 # limit-pass - Tests that should successfully parse at resource limits
18 #
19 # Common Keys:
20 # name - Test case name (string)
21 # data - YAML input specification (either direct string or generator spec)
22 # want - Expected value:
23 # - For limit-error: error message string
24 # - For limit-pass: {type: sequence|mapping} to validate top-level structure
25 #
26 # Data Specification:
27 # Direct YAML string (rare for limit tests):
28 # data: "yaml content"
29 #
30 # Generated data using 'join' (concatenate parts):
31 # data:
32 # join:
33 # - text: "string" # Literal string to include
34 # - loop: ["string", N] # Repeat string N times
35 # loop: M # Optional: repeat entire join M times
36 #
37 # Generated data using 'loop' (simple repeat):
38 # data:
39 # loop: ["string", N] # Repeat string N times
40 #
41 # Limits Tested:
42 # - Max depth: 10000 levels (flow, indent)
43 # - Aliasing: Excessive alias expansion detection
44 # - Document size: Various sizes (1kb, 10kb, 100kb, 1000kb)
45
46 - limit-error:
47 name: 1000kb of maps with 100 aliases
48 data:
49 join:
50 - text: '{a: &a [{a}'
51 - loop: [',{a}', 262044] # 1000*1024/4-100
52 - text: '], b: &b [*a'
53 - loop: [',*a', 99]
54 - text: ']}'
55 want: 'go-yaml load error in constructor at L[0-9]+.C[0-9]+: document contains excessive aliasing'
56
57 - limit-error:
58 name: 1000kb of deeply nested slices
59 data:
60 loop: ['[', 1024000] # 1000*1024
61 want: 'go-yaml load error in scanner \(while increasing flow level\) at L1.C10001: exceeded max depth of 10000'
62
63 - limit-error:
64 name: 1000kb of deeply nested maps
65 data:
66 join:
67 - text: 'x: '
68 - loop: ['{', 1024000] # 1000*1024
69 want: 'go-yaml load error in scanner \(while increasing flow level\) at L1.C10004: exceeded max depth of 10000'
70
71 - limit-error:
72 name: 1000kb of deeply nested indents
73 data:
74 loop: ['- ', 1024000] # 1000*1024
75 want: 'go-yaml load error in scanner \(while increasing indent level\) at <unknown position>-L1.C20001: exceeded max depth of 10000'
76
77 - limit-pass:
78 name: 1000kb of 1000-indent lines
79 data:
80 join:
81 - loop: ['- ', 1000]
82 - text: "\n"
83 loop: 512 # 1024/2
84 want: {type: sequence}
85
86 - limit-pass:
87 name: 1kb of maps
88 data:
89 join:
90 - text: 'a: &a [{a}'
91 - loop: [',{a}', 255] # 1*1024/4-1
92 - text: ']'
93 want: {type: mapping}
94
95 - limit-pass:
96 name: 10kb of maps
97 data:
98 join:
99 - text: 'a: &a [{a}'
100 - loop: [',{a}', 2559] # 10*1024/4-1
101 - text: ']'
102 want: {type: mapping}
103
104 - limit-pass:
105 name: 100kb of maps
106 data:
107 join:
108 - text: 'a: &a [{a}'
109 - loop: [',{a}', 25599] # 100*1024/4-1
110 - text: ']'
111 want: {type: mapping}
112
113 - limit-pass:
114 name: 1000kb of maps
115 data:
116 join:
117 - text: 'a: &a [{a}'
118 - loop: [',{a}', 255999] # 1000*1024/4-1
119 - text: ']'
120 want: {type: mapping}
121
122 - limit-pass:
123 name: 1000kb slice nested at max-depth
124 data:
125 join:
126 - loop: ['[', 10000]
127 - text: '1'
128 - loop: [',1', 491999] # 1000*1024/2-20000-1
129 - loop: [']', 10000]
130 want: {type: sequence}
131
132 - limit-pass:
133 name: 1000kb slice nested in maps at max-depth
134 data:
135 join:
136 - text: "{a,b:\n"
137 - loop: [' {a,b:', 9998] # 10000-2
138 - text: ' [1'
139 - loop: [',1', 451999] # 1000*1024/2-6*10000-1
140 - text: ']'
141 - loop: ['}', 9999] # 10000-1
142 want: {type: mapping}
143
144 - limit-pass:
145 name: 1000kb of 10000-nested lines
146 data:
147 join:
148 - text: '- '
149 - loop: ['[', 10000]
150 - loop: [']', 10000]
151 - text: "\n"
152 loop: 51 # 1000*1024/20000
153 want: {type: sequence}