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
nominalPreview with restricted reads in an untrusted workspace
nominalWritable preview
| Input | Outcome |
|---|---|
| A trusted workspace and a document in a subfolder of its folder | The resource root is the workspace folder |
| A trusted window with two workspace folders and a document in the second | The resource root is the second folder |
nominalRoots the webview may load from
nominalRuntime and stylesheet as bundle files
| Input | Outcome |
|---|---|
| A rendered page, its HTML read | It 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 built | Only the JSON element of the context differs, so the shell keys are equal |
refusalNew panel and status pages allow no local file
| Input | Outcome |
|---|---|
| A panel just created for a preview, no document rendered yet | Its webview has no local resource root |
| A preview whose source file was deleted, the page replaced by the missing-source page | The webview has no local resource root until a document is rendered again |
| The page replaced by the pending page that clears the content | The webview has no local resource root |
boundaryLinks and includes of a preview with restricted reads stay in the folder of the document
| Input | Outcome |
|---|---|
| A standalone preview and a link to a file below the document's folder | It opens |
| The same preview and a link to ../other.md | It is blocked with outside the standalone document directory |
| A preview with restricted reads and an include of sub/part.md next to the document | The file is included |
| The same preview and an include of ../other.md | The file is refused as outside the roots |
Implemented in 8
Tested by 7
- test/integration/standalone-suite.tsintegration
- test/security/trustReq.requirements.test.tsunit
- test/session/previewRuntimeFile.test.tsunit
- test/session/readOnlyLocalRoots.test.tsunit
- test/session/toolbarReq.requirements.test.tsunit
- test/session/trustReq.requirements.test.tsunit
- test/session/trustReq.roots.requirements.test.tsunit
Known limits (1)
- the text of SwRS-MDOKFSTUDIO-CORE-012 says an include is expanded for a trusted document, and docs/known-limitations.md says that file includes are supported only when the workspace is trusted; the code reads includes in Restricted Mode and for a file outside the workspace too, from the folder of the document.