Permission allow-fs-* to resolve env variables
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- javascript
Research direction
Start by tracing how Node.js parses --allow-fs-read and --allow-fs-write from direct arguments, NODE_OPTIONS, and configuration files. Check the existing permission-option tests and add coverage for exact environment-variable values in string and array forms. Done means supported permission inputs resolve environment variables consistently, including behavior when a variable is unset.
Written by the indexing model from the issue text.
Description
What is the problem this feature will solve?
While it is possible to pass values of env variables when calling node directly
node --permission --allow-fs-read=$HOME
there are other ways to set permissions (in config file or via NODE_OPTIONS) that don't go through the shell first.
I'd like to make it possible for all methods of passing in permissions to support using environment variables.
{
"nodeOptions": {
"--permission": true,
"--allow-fs-read": [
"$HOME"
]
}
}
What is the feature you are proposing to solve the problem?
Pseudocode:
const replaceEnvVar = (value) => {
const envVarMatch = value.match(/^\$([A-Z_][A-Z0-9_]*)$/i)
if (envVarMatch) {
const envVarName = envVarMatch[1]
if (process.env[envVarName] !== undefined) {
return process.env[envVarName]
} else {
console.error(
`[LavaMoat] Environment variable "${envVarName}" referenced in config but not found in environment`
)
}
}
return value
}
for (const key of ['--allow-fs-read', '--allow-fs-write']) {
if (Array.isArray(configOptions[key])) {
configOptions[key] = configOptions[key].map(replaceEnvVar)
} else if (typeof configOptions[key] === 'string') {
configOptions[key] = replaceEnvVar(configOptions[key])
}
}
What alternatives have you considered?
I've considered more advanced support where this would also work:
{
"nodeOptions": {
"--permission": true,
"--allow-fs-read": [
"/home/${MY_USER}/some/place/else"
]
}
}
but it seems unnecessarily complex and error prone to be worth it IMHO.
- Dominant language
- JavaScript
- Stars
- 122k
- Forks
- 37.4k
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 279
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.
More from nodejs/node
-
doc
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
build
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
feature request
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Similar issues
-
bug customer-eng Durable Agents Inngest status: needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
optimization optimization:agents-md-curator
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
githubnext/gh-aw-cao#13475 ·
-
[BUG]: "Clear All" in Settings doesn't clear the saved analysis, old data comes back after reload Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
AOSSIE-Org/OrgExplorer#253 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
oxc-project/oxc#26944 ·
-
ai-observability bug team/ai-observability
Difficulty 2/5 1-3 hours Newbie friendliness 78/100