Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-CORE-013

Includes are bounded by depth, budget, size and allowed roots

When a chain of includes reaches the 8th level, an include repeats a file already being included, a render has expanded 2000 includes or 10 Mi characters of included text, an included file is larger than 5 MiB or cannot be read, or an include points outside the allowed roots, uses an absolute path or a URL scheme, has an undecodable path, has a symlink that escapes its root or names a missing file, the extension SHALL leave that directive as an unresolved placeholder and, for a refused or missing file or an exhausted budget, list a warning naming the request without reading a refused file.

Another outcome at step 1 of path 1 in StRS-MDOKFSTUDIO-CORE-002, in the state “A trusted document holds an include directive”.

Part of StRS-MDOKFSTUDIO-CORE-003, outside the paths drawn on its map.

Part of StRS-MDOKFSTUDIO-TRUST-006, outside the paths drawn on its map.

Scenarios 8

The situations the tests check; open one to read it.

nominalStop include depth
Givena chain of eight nested includes
Whenit is rendered
Thenthe first seven expand and the eighth stays a placeholder
refusalStop include cycles
Givena file that includes itself
Whenit is rendered
Thenthe cyclic include stays a placeholder and the render ends
boundaryLimit the include budget per render
InputOutcome
a document with 2001 include directives2000 are expanded, the rest are placeholders and one budget warning ("Include budget exhausted") is listed
10 Mi characters of included text expandedthe remaining includes are placeholders and one budget warning is listed
a document within both limitsno budget warning is listed
boundaryRefuse oversize and unreadable included files
InputOutcome
an included file of 5 MiB plus one bytethe directive stays a placeholder and the file is not expanded
an included file of exactly 5 MiBthe file is expanded
a file inside the roots that the process cannot readthe directive stays a placeholder and nothing of the file is shown
refusalRefuse includes outside the allowed roots
InputOutcome
an include that the allowed-roots rule (SwRS-MDOKFSTUDIO-TRUST-025) refuses: `../../secret.md` outside the roots, an absolute path, an undecodable path, a symlink that escapes its rootthe file is not read and a warning naming the request is listed
an include with an `https:` URLthe URL is not fetched and a warning is listed
refusalWarn about a missing included file
Givenan include of `missing.md`
Whenit is rendered
Thena warning for `missing.md` is listed in the status region
boundaryThe warning ends when the file exists
Giventhe file `missing.md` is created and the document re-rendered
Whenit is rendered
Thenthe warning disappears and the content is expanded
boundaryA file is checked once per render
Givena document that references the same image or include several times, existing or missing
Whenthe preview renders it
Thenthe policy asks the file system once per distinct path (one stat, one real-path lookup) and still reports every refusal; the next render asks again, so a file that appears or changes is seen

Implemented in 3

Tested by 9

Replaces

SwRS-MDOKFSTUDIO-CORE-016Limit the include budget per render superseded superseded by SwRS-MDOKFSTUDIO-CORE-013 Markdown file
SwRS-MDOKFSTUDIO-CORE-018Refuse includes outside the allowed roots superseded superseded by SwRS-MDOKFSTUDIO-CORE-013 Markdown file
SwRS-MDOKFSTUDIO-CORE-019Warn about a missing included file superseded superseded by SwRS-MDOKFSTUDIO-CORE-013 Markdown file
SwRS-MDOKFSTUDIO-CORE-067Refuse oversize included files superseded superseded by SwRS-MDOKFSTUDIO-CORE-013 Markdown file