Templates feature for desktop application
Currently, the templates feature is only available for web-deployed instances, and the current implementation uses a GitHub repository as the backing storage. This is somewhat limiting for users who configure their web deployments with other services such as GitLab, Bitbucket, or Google Drive. Because of this, I thought it would be valuable to make the feature available in the desktop version as well, backed by the local file system, so that anyone can experiment with and use the feature regardless of their storage provider.
Implementation
The approach I took was to use a file storage schema similar to the GitHub-backed templates used in the web version.
templates/
├── template_info.json # Index file containing all template metadata
├── a1b2c3d4-e5f6-7890-abcd-ef1234567890.json # Template content file
├── b2c3d4e5-f6a7-8901-bcde-f12345678901.json # Another template content
└── ...
However, instead of configuring the template storage through GitHub configuration variables as in the web version:
| GITHUB_CONTENT_REPO | Optional GitHub repository for organization-wide templates (e.g., org/templates-repo) | |
For the desktop application, I implemented the ability to configure template storage within a folder on the local file system. Instead of using configuration variables, the storage path can be set directly through the UI, as shown below.
The logic behind this is that once a templates folder is configured, the path is stored in AppData/Roaming/Threat Dragon/templates-path.txt on Windows. In the menu above, there are a few options: you can either select an existing folder that already contains templates (following the structure shown earlier), or choose the default path, in which case the application will create an empty folder for you.
All other operations work the same way as in the web version. I’ll be opening a PR as a draft for this very soon, but it will likely require a fair amount of manual testing, because there’s a good chance I may have missed something along the way. :))
Declaration:
By submitting this issue you have:
<Used Ai to refine the grammar, but the content was written by me :))>
Templates feature for desktop application
Currently, the templates feature is only available for web-deployed instances, and the current implementation uses a GitHub repository as the backing storage. This is somewhat limiting for users who configure their web deployments with other services such as GitLab, Bitbucket, or Google Drive. Because of this, I thought it would be valuable to make the feature available in the desktop version as well, backed by the local file system, so that anyone can experiment with and use the feature regardless of their storage provider.
Implementation
The approach I took was to use a file storage schema similar to the GitHub-backed templates used in the web version.
However, instead of configuring the template storage through GitHub configuration variables as in the web version:
|
GITHUB_CONTENT_REPO| Optional GitHub repository for organization-wide templates (e.g.,org/templates-repo) | |For the desktop application, I implemented the ability to configure template storage within a folder on the local file system. Instead of using configuration variables, the storage path can be set directly through the UI, as shown below.
The logic behind this is that once a templates folder is configured, the path is stored in AppData/Roaming/Threat Dragon/templates-path.txt on Windows. In the menu above, there are a few options: you can either select an existing folder that already contains templates (following the structure shown earlier), or choose the default path, in which case the application will create an empty folder for you.
All other operations work the same way as in the web version. I’ll be opening a PR as a draft for this very soon, but it will likely require a fair amount of manual testing, because there’s a good chance I may have missed something along the way. :))
Declaration:
By submitting this issue you have:
<Used Ai to refine the grammar, but the content was written by me :))>