Trusting project code¶
Audience: anyone opening projects or languages from others · ~5 min read · Prerequisites: Projects and models
What it is¶
A language contains code: checks, evaluation rules, generators. It is stored as a *.lang.js file, which is
JavaScript. A project can carry such files in its folder. When the file is loaded, that JavaScript runs with
the full privileges of the IDE page (and the IDE backend is reachable from the page). So opening a project,
importing a language or loading a plugin is like running a program someone sent you.
When you'd use it¶
- Before you open a project or
.lang.jsfrom someone you do not know. - When a CLI run says a language is untrusted.
What the IDE does today¶
The IDE does not ask. The default policy is "allow all": a project's *.lang.js, an imported language and
a loaded folder plugin are executed without any dialog. The "Trust this language?" dialog and a per-content
hash list exist in the code (code-trust.ts) but nothing in the IDE switches them on, and there is no
preference for it. So the protection is you: open only content you trust.
Content that ships with the app is always trusted. Languages you save or export yourself are recorded as trusted so they would not be questioned if prompting were on.
Project scripts¶
A project can carry scripts (*.script.js, or entries in project.json; see Scripting the workbench).
They are JavaScript with the same privileges as a language file, plus access to the project's files and, if the host allows it, to
programs. A host runs a script it found in a project only when it has a trust policy that says yes; with none, it runs nothing.
strukts script needs --trust-project-code, and that flag is the whole boundary: a trusted script runs inside the CLI's own process with your privileges and can import Node's modules, write any file and start any program. The flags --write and --shell only gate what the workbench API itself will do on a script's behalf (workbench.fs, workbench.project.save(), workbench.shell); they are not a sandbox.
What the command-line tool does¶
The headless strukts tool has nobody to ask, so it is strict by default:
- A project that contains its own
*.lang.jsis refused. The JSON result haserror.codeSTRUKT-LANG-UNTRUSTEDand the exit code is 1. - Add
--trust-project-codeto load it:
npm run strukts -- check --project-dir path/to/project --trust-project-code
Use the flag only for projects you have read or built yourself. In CI, review the .lang.js files in the pull
request before enabling it. See Command line and Exit codes and JSON.
How to stay safe¶
- Open projects from people you trust, or read the
*.lang.jsfirst (it is plain text). - Prefer bundled languages for models you receive.
- Run unfamiliar projects in a throwaway user account or container.
- In shared setups limit folders with
STRUKTJS_ALLOWED_ROOTS(Security and privacy).
Every control¶
| # | Button/Option | What it does | Shortcut | Gotcha |
|---|---|---|---|---|
| 1 | --trust-project-code (CLI) |
Lets the CLI load a project's own *.lang.js. |
Without it: exit code 1, STRUKT-LANG-UNTRUSTED. |
|
| 2 | Trust / Don't trust dialog | Would ask before loading code. | Not shown by the IDE by default. |