Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-TRUST-007

A page loads local files only from its resource roots

When the extension shows a document, it SHALL allow the webview to load local files only from the resource root of the preview (the folder of the document for a preview with restricted reads, which also loads the images of the workspace folder that holds it, unless that folder is broad; the workspace folder for a preview with full reads) and from the bundle folder of the extension, and no local file for the pending page that clears the content and for the missing-source page.

Step 2 of path 1 in StRS-MDOKFSTUDIO-TRUST-004: from “The page holds the address of a file inside the allowed roots” to “The image is shown from an allowed folder”.

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

Part of StRS-MDOKFSTUDIO-TOOLBAR-011, outside the paths drawn on its map.

Scenarios 7

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

nominalPreview with restricted reads of a file outside the workspace
Givena Markdown file outside every workspace folder, with an image beside it
Whenthe reader previews it
Thenthe resource root is the folder of the file and the image beside it loads
nominalPreview with restricted reads in an untrusted workspace
Givena document in a subfolder of an untrusted workspace folder
Whenthe reader previews it
Thenthe resource root is that subfolder; the workspace folder serves images only (SwRS-MDOKFSTUDIO-TRUST-002)
nominalWritable preview
InputOutcome
A trusted workspace and a document in a subfolder of its folderThe resource root is the workspace folder
A trusted window with two workspace folders and a document in the secondThe resource root is the second folder
nominalRoots the webview may load from
Givena preview with full reads of a workspace document, or a preview with restricted reads of a file outside the workspace
Whenthe page is shown
Thenthe webview may load from the workspace folder (full reads) or the folder of the file (restricted reads), and from the bundle folder, and from nowhere else; a preview with restricted reads of a workspace document may also load from the workspace folder (its images, SwRS-MDOKFSTUDIO-TRUST-002) but not from the rest of the disk
nominalRuntime and stylesheet as bundle files
InputOutcome
A rendered page, its HTML readIt holds a script element with the bundle URL of preview.js and the attribute data-sphinx-preview-scroll-sync, and the page's style imports preview.css
Two renders of one document type, their pages builtOnly the JSON element of the context differs, so the shell keys are equal
refusalNew panel and status pages allow no local file
InputOutcome
A panel just created for a preview, no document rendered yetIts webview has no local resource root
A preview whose source file was deleted, the page replaced by the missing-source pageThe webview has no local resource root until a document is rendered again
The page replaced by the pending page that clears the contentThe webview has no local resource root
boundaryLinks and includes of a preview with restricted reads stay in the folder of the document
InputOutcome
A standalone preview and a link to a file below the document's folderIt opens
The same preview and a link to ../other.mdIt is blocked with outside the standalone document directory
A preview with restricted reads and an include of sub/part.md next to the documentThe file is included
The same preview and an include of ../other.mdThe file is refused as outside the roots

Implemented in 8

Tested by 7

Known limits (1)