Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
puml-for-markdown
Advanced tools
An application to add interactive PUML diagrams to your github markdown files. If running with default arguments, run in project root directory.
The goal is to make PlantUML diagrams easily accessible from markdown, specifically GitHub flavored.
!include
The following examples are of a project I worked on, yellow components will link you to another diagram. Obviously the diagram content has been obfuscated.
PlantUML allows you to create diagrams that are defined using a simple and intuitive language. PlantUML diagrams are great for designing new projects but they don't work very well in Github markdown preview. There are some workarounds, but I found these to be unstable and they have a lot of caveats.
npm i -g puml-for-markdown
Whenever you run the CLI it will add a tinyurl link to the rendered SVG next to the markdown comments referencing a
puml diagram. E.g. <!--[Example With Only Link](./puml/level_1_system_view.puml)-->
will be replaced with
[Example With Only Link](https://tinyurl.com/yfpclfpp)<!--[Example With Only Link](./puml/level_1_system_view.puml)-->
When !
is included in front of the markdown link, it will render the diagram image in the markdown. If the image is
clicked it will open up the diagram. E.g. <!--![Example With Graph Image](./puml/level_1_system_view.puml)-->
will be
replaced with
[![Example With Graph Image](https://tinyurl.com/yfpclfpp)](https://tinyurl.com/yfpclfpp)<!--![Example With Graph Image](./puml/level_1_system_view.puml)-->
If you want to update the link text or switch it between image and link, just update the comment and rerun the CLI. You don't need to delete the rendered image or link.
Optionally you can specify the CLI to output the diagram images as png and/or svg.
Usage: puml-for-markdown [options]
An application to add interactive PUML diagrams to your github markdown files. If running with default arguments, run in project root directory.
Options:
-x, --root-directory <path> The path to your project (default: CWD)
-r, --hot-reload Rerun markdown generator every `interval` seconds, determined by interval option
-v, --interval-seconds <number> If --hot-reload is set, how often should it reload (default: 2)
-p, --puml-directory <path> Path to directory containing puml files which are referenced in markdown files (default: rootDirectory)
-m, --markdown-directory <path> Path to directory containing markdown files referencing puml files (default: rootDirectory)
-g, --respect-gitignore Automatically ignore MD files in .gitignore paths (default: true)
-i, --gitignore-path <path> If --respect-gitignore is set, use set this as path to .gitignore file. (default: rootDirectory/.gitignore)
-d, --output-images If set, will output images of diagrams to the dist directory
-b, --dist-directory <path> If --output-images is set, path to output diagram images (default: rootDirectory/dist_puml)
-f, --image-formats <format> If --output-images is set, sets the output image format (choices: "png", "svg", "both", default: "png")
-t, --turn-off-link-shortening Use the full puml server link instead of the tiny url, if your diagrams are too big this won't work
-h, --help display help for command
You can use PlantUML using the online web service to generate images on-the-fly. A online demonstration is available at http://www.plantuml.com/plantuml. You can pass the encoded text of your diagrams to the web service in the url path and it will generate an SVG or PNG for you. Here's a simple HelloWorld example http://www.plantuml.com/plantuml/uml/Aov9B2hXil98pSd9LoZFByf9iUOgBial0000. Large diagrams will have very long encoding strings, they can exceed maximum url length. They also don't look very good in markdown files. By default the CLI will use the tinyurl.com service to shorten the link to the diagram.
The CLI will use the plantuml-encoder
package to encode puml files. To support hyperlinking diagrams we need to parse
all hyperlinks in the puml files. A dependency graph is created for the files and a DFS is performed where we create
links for the leaf nodes first, then replace the links in the parent nodes with the links to the leaf nodes. The puml
files are not actually modified, only the puml files content in memory is modified. By default the tinyurl free service
is used to shorten the links.
In order to support !include
we parse puml files and replace any !include
with the contents of the file referenced.
The markdown files are then parsed for markdown comments. If the comments reference a PlantUML file, a link to the web service url will be added next to the comment. Because these links contain the full PlantUML diagram encoding in it, there are no issues using them in private repositories.
Currently there is no TDD, for now I've just been using the example diagrams to test. The examples are pretty extensive though.
FAQs
An application to add interactive PUML diagrams to your github markdown files. If running with default arguments, run in project root directory.
The npm package puml-for-markdown receives a total of 1,405 weekly downloads. As such, puml-for-markdown popularity was classified as popular.
We found that puml-for-markdown demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.