Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-DIAG-084

The JAR pipeline runs java or plantuml once per diagram on stdin, at most 2 at once

When useJar is true in a trusted workspace, the extension SHALL render each PlantUML diagram by starting its own process in the workspace folder, at most 2 at once, and return the pictures in document order, running java with the arguments -jar, the resolved JAR path, -pipe and -tsvg when jarPath is not empty and the plantuml command with -pipe and -tsvg otherwise, each process under the PlantUML security profile ALLOWLIST with the workspace folder as its allowlist path and an image size limit of 4096, writing the diagram text to its standard input and taking as the picture the output from the first svg start tag to the last svg end tag. Before any process starts, the extension SHALL refuse a diagram with an include directive whose file (or whose nested include) leaves the workspace folder, by parent segments, an absolute path, a sibling folder sharing the folder-name prefix or a symbolic link, or is computed by a function or variable, and show a message instead of the picture.

Step 2 of path 1 in StRS-MDOKFSTUDIO-DIAG-007: from “The JAR pipeline is selected” to “The JAR has drawn the diagrams of the render”.

Scenarios 8

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

nominalJAR configured
GivenuseJar true, a trusted workspace and an existing JAR path
Whena preview with a PlantUML diagram is rendered
Thenthe process started is java, taken from JAVA_HOME/bin when JAVA_HOME is an absolute path and holds a java binary and from the PATH otherwise, with the arguments -jar, the JAR path, -pipe, -tsvg preceded by the size-limit and allowlist-path properties
its environment sets PLANTUML_SECURITY_PROFILE to ALLOWLIST, PLANTUML_LIMIT_SIZE to 4096 and PLANTUML_ALLOWLIST_PATH to the workspace folder
nominalPATH command
GivenuseJar true, a trusted workspace and an empty jarPath
Whena preview with a PlantUML diagram is rendered
Thenthe process started is plantuml with the arguments -pipe and -tsvg
its environment carries the same three PlantUML variables
boundaryReading and resolving jarPath
InputOutcome
jarPath of two spaces, a path and a tabthe result is the path without the padding
jarPath holding only spacesthe setting reads as empty and the plantuml command is used instead
jarPath holding a number (not a string)the result is the empty string
Relative jarPath tools/plantuml.jar with a workspace folderjava is given the JAR path inside the workspace folder
Absolute jarPathjava is given that path unchanged
refusalCommand missing
Givenno plantuml command on the PATH
Whena preview is rendered
Thenthe diagram shows the executable-not-found message
nominalText on standard input, workspace folder as working directory
Givena diagram with some text, the JAR pipeline and a workspace folder open in the editor
Whenthe process is started
Thenthe process standard input receives exactly the diagram text and its working directory is the workspace root
nominalThe picture is the SVG span of the output
Givena process that prints log lines before and after the SVG, or a multibyte character split across two output chunks
Whenthe output is read
Thenthe picture is the SVG only, the log lines are ignored and the character is decoded correctly
refusalInclude leaves the workspace folder
Givena diagram with an include directive naming ../outside.puml, an absolute path into a sibling folder whose name starts with the workspace folder name, a symbolic link that points out of the folder, a file that itself includes such a path, or a path computed by a function or variable
Whenthe preview is rendered
Thenno process is started for that diagram, which shows a message that the include is outside the workspace folder (or is computed and cannot be checked), and a warning is reported
includes inside the folder, URLs and standard-library names are passed to the process unchanged
boundaryOne process per diagram, at most 2 at once
InputOutcome
three PlantUML diagrams in one pagethree processes in all, never more than 2 at once; the third starts when one of the first two finishes
five diagrams in one pagenever more than 2 processes run together and all 5 are rendered
diagrams that finish in another order than the page orderthe pictures come back in document order
a document without PlantUML diagramsno process starts and the result is empty

Implemented in 3

Tested by 5

Known limits (2)

Replaces

SwRS-MDOKFSTUDIO-DIAG-085Without a JAR the plantuml command is run superseded superseded by SwRS-MDOKFSTUDIO-DIAG-084 Markdown file
SwRS-MDOKFSTUDIO-DIAG-086The JAR pipeline takes the SVG from the process output superseded superseded by SwRS-MDOKFSTUDIO-DIAG-084 Markdown file
SwRS-MDOKFSTUDIO-DIAG-087jarPath is read as a trimmed string superseded superseded by SwRS-MDOKFSTUDIO-DIAG-084 Markdown file
SwRS-MDOKFSTUDIO-DIAG-088A relative jarPath is resolved from the workspace folder superseded superseded by SwRS-MDOKFSTUDIO-DIAG-084 Markdown file
SwRS-MDOKFSTUDIO-DIAG-104The JAR pipeline starts one process per diagram superseded superseded by SwRS-MDOKFSTUDIO-DIAG-084 Markdown file
SwRS-MDOKFSTUDIO-DIAG-120The JAR pipeline feeds the text on stdin in the workspace folder superseded superseded by SwRS-MDOKFSTUDIO-DIAG-084 Markdown file