Skip to content

Keep ENVIRON empty in sandbox mode - #676

Merged
bertysentry merged 3 commits into
mainfrom
feature/issue-675-sandbox-environ
Nov 28, 2026
Merged

bertysentry merged 3 commits into
mainfrom
feature/issue-675-sandbox-environ

Conversation

@bertysentry

@bertysentry bertysentry commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #675.

Change

In sandbox mode (SandboxedAwk and -S), ENVIRON is no longer populated with the environment of the process. SandboxedAVM overrides the new AVM.getEnvironment() hook to return an empty map, so ENVIRON stays a plain global: empty, or exactly the map the host passes with variable("ENVIRON", map) or AwkSettings.putVariable(). This is enforced at run time, so it also holds for programs and expressions compiled by a plain Awk and run in the sandbox, -S -L included. No new option. Without the sandbox, nothing changes.

strftime() and mktime() in the sandbox therefore use the default time zone unless ENVIRON["TZ"] is set.

The unused JRT.assignEnvironmentVariables() is removed.

Tests

AwkTest:

  • sandboxed script and eval(): ENVIRON is empty (length(ENVIRON) is 0, a real variable of the process reads as "")
  • sandboxed script with preassign("ENVIRON", {TZ=UTC}) and eval() with AwkSettings.putVariable(): only TZ is seen
  • program and expression compiled by a plain Awk, run by SandboxedAwk: ENVIRON is empty
  • plain Awk: ENVIRON still holds the value of the process

The tests pick an existing environment variable at runtime instead of PATH (named Path on Windows).

Docs

cli.md, java-advanced.md, index.md.vm, and behavior-changes.md (Unreleased).

🤖 Generated with Claude Code

In SandboxedAwk and with -S, ENVIRON is no longer populated with the
environment of the process: it stays a plain global, empty unless the
host passes its own map, which the script then sees unchanged.

Remove the unused JRT.assignEnvironmentVariables().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-28T09:27:02.659420Z 1888c2b Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8154536aec

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/main/java/io/jawk/SandboxedAwk.java Resolved
A program or an expression compiled by a plain Awk (or loaded with -S -L)
carries the ENVIRON_OFFSET tuple, which the sandboxed compile-time
overrides never see. SandboxedAVM now supplies an empty environment
through the new AVM.getEnvironment() hook, which covers every path, so
the environOffset() overrides are removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bertysentry

Copy link
Copy Markdown
Contributor Author

@codex please review again

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 593ea6ccec

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/test/java/io/jawk/AwkTest.java Resolved
Comment thread src/test/java/io/jawk/AwkTest.java Resolved
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bertysentry

Copy link
Copy Markdown
Contributor Author

@codex please review again

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 1888c2bab4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@bertysentry
bertysentry merged commit 037c312 into main Nov 28, 2026
5 checks passed
@bertysentry
bertysentry deleted the feature/issue-675-sandbox-environ branch November 28, 2026 12:58
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.

In sandbox mode, ENVIRON is empty unless the host passes one

1 participant