safe-markdown
Since 0.9.0 · fixed by --fix · In the rulesets: Recommended at warning, Strict at error, All at error
This rule ensures that Markdown strings (descriptions) do not contain unsafe
constructs like script tags or eval() calls.
Rule details
Unsafe constructs embedded in Markdown strings can pose security risks when the documentation is rendered, for example by a documentation portal.
The safe-markdown rule checks the description field of every object that
supports CommonMark descriptions: the info object, servers, server variables,
channels, parameters, operations, operation traits, operation reply addresses,
messages, message traits, correlation IDs, tags, external documentation,
schemas and security schemes. It reports:
Markdown contains <script> tagwhen a description contains ascriptelement,Markdown contains eval() functionwhen a description contains aneval()call.
Examples
Good.
asyncapi: 3.0.0
info:
title: Pet Events
version: 1.0.0
description: Events published when pets are adopted or returned.
Bad.
asyncapi: 3.0.0
info:
title: Pet Events
version: 1.0.0
description: "Events published when pets are adopted. <script>alert('Unsafe')</script>"
Automatic fixes
--fix escapes the delimiters of recognized
script elements and eval() calls. It preserves the surrounding Markdown and
does not alter code spans or fenced code blocks.
Turn it off or change its severity
In apigenie.yaml, off turns the rule off and warning or error sets its severity; a rule with options takes the severity and the options as a pair, [warning, options]. lint.asyncapi has the details.
commands:
lint:
asyncapi:
rules:
safe-markdown: off