--disallow-code-generation-from-strings does not work as documented
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 122k
- Forks
- 37.3k
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 283
Description
Doc: https://nodejs.org/docs/latest/api/cli.html#--disallow-code-generation-from-strings
It is advertised to cover built-in language features, but it doesn't cover data imports
No Node.js modules are directly imported here
// run with node and node --disallow-code-generation-from-strings
const payload = 'console.log("evaluated code from string")'
try { eval(payload) } catch (e) { console.log(e.message) }
try { new Function(payload)() } catch (e) { console.log(e.message) }
try { await import('data:text/javascript,' + payload) } catch (e) { console.log(e.message) }
Output:
% node --disallow-code-generation-from-strings 1.js
Code generation from strings disallowed for this context
Code generation from strings disallowed for this context
evaluated code from string
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the issue's 1.js reproduction with Node.js and with --disallow-code-generation-from-strings, then compare the eval, new Function, and data import results with the CLI documentation linked in the issue. Trace the handling of this option for data imports; done means the observed behavior matches the documented coverage, with regression coverage for all three cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100