Skip to content

[IMP] compiler: force validated strings#8694

Closed
LucasLefevre wants to merge 1 commit into
masterfrom
master-compiler-lul
Closed

[IMP] compiler: force validated strings#8694
LucasLefevre wants to merge 1 commit into
masterfrom
master-compiler-lul

Conversation

@LucasLefevre
Copy link
Copy Markdown
Collaborator

The formula compiler builds JS source by string concatenation and feeds it to new Function(...). Several of those strings came from user input (function names, operator symbols), so any value that slipped past the parser's validation could end up executed as code.

This commit introduces a JsString branded type plus a jsStr tagged-template helper:
generated code can only be assembled from values explicitly marked trusted, and untrusted strings must go through dangerouslyCreateJsStr, which makes the trust decision auditable.

Task: 6185314

Description:

description of this task, what is implemented and why it is implemented that way.

Task: TASK_ID

review checklist

  • feature is organized in plugin, or UI components
  • support of duplicate sheet (deep copy)
  • in model/core: ranges are Range object, and can be adapted (adaptRanges)
  • in model/UI: ranges are strings (to show the user)
  • undo-able commands (uses this.history.update)
  • multiuser-able commands (has inverse commands and transformations where needed)
  • new/updated/removed commands are documented
  • exportable in excel
  • translations (_t("qmsdf %s", abc))
  • unit tested
  • clean commented code
  • track breaking changes
  • doc is rebuild (npm run doc)
  • status is correct in Odoo

@robodoo
Copy link
Copy Markdown
Collaborator

robodoo commented May 13, 2026

Pull request status dashboard

The formula compiler builds JS source by string concatenation and feeds it
to `new Function(...)`. Several of those strings came from user input
(function names, operator symbols), so any value that slipped past the
parser's validation could end up executed as code.

This commit introduces a `JsString` branded type plus a `jsStr`
tagged-template helper:
generated code can only be assembled from values explicitly marked
trusted, and untrusted strings must go through `dangerouslyCreateJsStr`,
which makes the trust decision auditable.

Task: 6185314
@LucasLefevre LucasLefevre force-pushed the master-compiler-lul branch from efca639 to 50160c6 Compare May 13, 2026 14:47
@rrahir
Copy link
Copy Markdown
Collaborator

rrahir commented May 18, 2026

robodoo r+

robodoo pushed a commit that referenced this pull request May 18, 2026
The formula compiler builds JS source by string concatenation and feeds it
to `new Function(...)`. Several of those strings came from user input
(function names, operator symbols), so any value that slipped past the
parser's validation could end up executed as code.

This commit introduces a `JsString` branded type plus a `jsStr`
tagged-template helper:
generated code can only be assembled from values explicitly marked
trusted, and untrusted strings must go through `dangerouslyCreateJsStr`,
which makes the trust decision auditable.

closes #8694

Task: 6185314
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
@robodoo robodoo added the 19.4 label May 18, 2026
@robodoo robodoo closed this May 18, 2026
VincentSchippefilt pushed a commit that referenced this pull request May 18, 2026
The formula compiler builds JS source by string concatenation and feeds it
to `new Function(...)`. Several of those strings came from user input
(function names, operator symbols), so any value that slipped past the
parser's validation could end up executed as code.

This commit introduces a `JsString` branded type plus a `jsStr`
tagged-template helper:
generated code can only be assembled from values explicitly marked
trusted, and untrusted strings must go through `dangerouslyCreateJsStr`,
which makes the trust decision auditable.

closes #8694

Task: 6185314
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants