center-for-threat-informed-defense / attack-flow

Attack Flow helps executives, SOC managers, and defenders easily understand how attackers compose ATT&CK techniques into attacks by developing a representation of attack flows, modeling attack flows for a small corpus of incidents, and creating visualization tools to display attack flows.
https://ctid.io/attack-flow
Apache License 2.0
522 stars 83 forks source link

AF-26 Autosave #90

Closed mikecarenzo closed 11 months ago

mikecarenzo commented 11 months ago

Overview

Implements basic autosave functionality.

image

The builder now logs all document edits to localStorage. If the builder closes with unsaved changes, the unsaved changes can be recovered via the Open Recovered Files submenu. This menu is only visible when there exist documents with unsaved changes.

Simply click on a recovered file to begin editing it. Once saved, the recovered file will disappear from the Open Recovered Files submenu.

You can also clear the recovered files list at any time by clicking Delete Recovered Files under the Open Recovered Files submenu.

Implementation Notes

The original plan involved leveraging the File System Access API. Unfortunately, the FileSystemWritableFileStream construct, required to write changes back to the file system, is still not fully supported by all 5 of the major internet browsers. In order to achieve the greatest level of compatibility, localStorage was chosen instead.

IMPORTANT:

Accessing the application from a webserver will not present issues for autosave. The same cannot be said when opening the application locally via the compiled index.html file. In this case, the behavior of localStorage varies from browser to browser.

Per Mozilla:

For documents loaded from file: URLs (that is, files opened in the browser directly from the user's local filesystem, rather than being served from a web server) the requirements for localStorage behavior are undefined and may vary among different browsers.

In all current browsers, localStorage seems to return a different object for each file: URL. In other words, each file: URL seems to have its own unique local-storage area. But there are no guarantees about that behavior, so you shouldn't rely on it because, as mentioned above, the requirements for file: URLs remain undefined. So it's possible that browsers may change their file: URL handling for localStorage at any time. In fact some browsers have changed their handling for it over time.

sonarcloud[bot] commented 11 months ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 6 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication