Skip to content

WKS-3612 - Escape server-supplied action metadata in jf worker init templates - #73

Merged
ehl-jf merged 1 commit into
mainfrom
bugfix/WKS-3612
Nov 4, 2026
Merged

ehl-jf merged 1 commit into
mainfrom
bugfix/WKS-3612

Conversation

@ehl-jf

@ehl-jf ehl-jf commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

What

jf worker init now JSON-encodes every value it writes into manifest.json, and rejects an executionRequestType from the actions metadata that is not a valid TypeScript identifier.

Why

The scaffold templates were rendered with text/template, which does no escaping. A value containing a quote could change the structure of the generated manifest.json (for example, add or override keys). Generating a normal manifest gives exactly the same output as before.

Changes

  • commands/common/cmd_io.go: a shared TemplateFuncs with a json function (json.Marshal).
  • commands/templates/manifest.json_template: the worker name, action, project key and application values go through {{json ...}}.
  • commands/init_cmd.go: the templates are parsed with TemplateFuncs. A non-identifier executionRequestType is rejected before any file is written.
  • commands/common/test_commons.go: the expected-output helper uses the same funcs.
  • commands/init_cmd_test.go: three new cases:
    • an escaped application gives valid JSON with sourceCodePath unchanged;
    • an invalid request type is rejected and no files are written;
    • a worker name containing quotes round-trips.

Testing

  • make test passes. The existing golden-output tests are unchanged.
  • Manual QA with a plugin built from this branch:
    • init against a local stub actions server with crafted metadata: the manifest stays valid, and the values are kept literally.
    • Regression on a JPD: init for every listed action, then test-run, deploy, list and rm. The scaffold output is identical to main.

@ehl-jf
ehl-jf merged commit 2093167 into main Nov 4, 2026
5 of 6 checks passed

This branch is waiting to be deployed

1 waiting deployment
frogbot — d58328aa Waiting Nov 4, 2026 by ehl-jf via scan-pull-request #117
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants