safe-markdown

Since 0.0.1 · fixed by --fix · In the rulesets: Recommended at warning, Strict at error, All at error

This rule checks that no description contains a <script> tag or an eval() call.

Rule details

Descriptions are CommonMark, and CommonMark allows raw HTML, so a description is rendered as-is by every documentation page built from the document. A script in it runs in the browser of every reader of that page, with the page’s cookies and origin.

The rule reports Markdown contains <script> tag and Markdown contains eval() function on the object whose description has them.

Examples

Good. Prose.

components:
  schemas:
    User:
      type: object
      description: A user of the system.

Bad. A script in the description.

components:
  schemas:
    User:
      type: object
      description: "A user of the system. <script>alert('Unsafe')</script>"

Automatic fixes

--fix escapes the delimiters of the script elements and eval() calls it finds, so they render as text. Code spans and fenced code blocks are left as they are, and so is the rest of the Markdown.

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.rules has the details.

commands:
  lint:
    rules:
      safe-markdown: off
Was this helpful?