-
Notifications
You must be signed in to change notification settings - Fork 150
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
While Fuzzing parseDocument threw uncaught exception at
Line 146 in e8576e8
| const [, handle, suffix] = source.match(/^(.*!)([^!]*)$/) as string[] |
To Reproduce
> const yaml = await import("yaml")
undefined
> const data = '!!�������p: >�: >\n|\x18\x00\x00pro��)�������������������: !!\r: !!: >\n\x07\x04\x00ke'
undefined
> const docs = yaml.parseDocument(data)
Uncaught:
TypeError: object null is not iterable (cannot read property Symbol(Symbol.iterator))
at Directives.tagName (/home/maxx/dev/security/oss-fuzz-projects/yaml/dist/doc/directives.js:121:36)
at Object.composeScalar (/home/maxx/dev/security/oss-fuzz-projects/yaml/dist/compose/compose-scalar.js:13:26)
at composeNode (/home/maxx/dev/security/oss-fuzz-projects/yaml/dist/compose/compose-node.js:24:34)
at Object.resolveBlockMap (/home/maxx/dev/security/oss-fuzz-projects/yaml/dist/compose/resolve-block-map.js:56:15)
at resolveCollection (/home/maxx/dev/security/oss-fuzz-projects/yaml/dist/compose/compose-collection.js:13:27)
at Object.composeCollection (/home/maxx/dev/security/oss-fuzz-projects/yaml/dist/compose/compose-collection.js:47:16)
at Object.composeNode (/home/maxx/dev/security/oss-fuzz-projects/yaml/dist/compose/compose-node.js:31:38)
at Object.composeDoc (/home/maxx/dev/security/oss-fuzz-projects/yaml/dist/compose/compose-doc.js:33:23)
at Composer.next (/home/maxx/dev/security/oss-fuzz-projects/yaml/dist/compose/composer.js:149:40)
at next (<anonymous>)Expected behaviour
parseDocument to not throw exception.
Versions (please complete the following information):
- Environment: Node.js v18.18.2
yaml: v2.3.3
Additional context
Possible fix for this will be a check against null
diff --git a/src/doc/directives.ts b/src/doc/directives.ts
index add18fc..896c584 100644
--- a/src/doc/directives.ts
+++ b/src/doc/directives.ts
@@ -143,7 +143,12 @@ export class Directives {
return verbatim
}
- const [, handle, suffix] = source.match(/^(.*!)([^!]*)$/) as string[]
+ const matched = source.match(/^(.*!)([^!]*)$/) as string[]
+ if (!matched) {
+ onError(`The ${source} tag is invalid`)
+ return null
+ }
+ const [, handle, suffix] = matched
if (!suffix) onError(`The ${source} tag has no suffix`)
const prefix = this.tags[handle]
if (prefix) {but i was not able to reproduce this with single error message in doc.errors,
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working