Skip to content

ci(lint): guard direct HOME reads - #1604

Merged
jeff-r2026 merged 2 commits into
Tencent:mainfrom
huong8373tt-beep:teamai-cli-1590-home-guard
Oct 31, 2026
Merged

jeff-r2026 merged 2 commits into
Tencent:mainfrom
huong8373tt-beep:teamai-cli-1590-home-guard

Conversation

@huong8373tt-beep

Copy link
Copy Markdown
Contributor

Summary

Adds teamai/home-env, an enabled oxlint rule that keeps raw process.env.HOME reads in src/utils/home.ts.

getUserHome() already handles the Windows USERPROFILE fallback and os.homedir() fallback. The new rule prevents a later production call site from bypassing that behavior.

The rule deliberately excludes src/__tests__/, because the existing source guard fixture contains the literal it scans for.

Validation

  • npx vitest run oxlint-plugin-teamai/rules/home-env.test.ts src/__tests__/home.test.ts --maxWorkers=2 (17 passed)
  • npm run typecheck
  • npm run lint (0 warnings, 0 errors)
  • npm run build
  • git diff --check
  • Built CLI smoke check:
    • node dist/index.js --version → 0.22.0
    • node dist/index.js list --help exited 0

Authorization

Slai Agent Runtime performed the investigation, implementation, and test execution. The account owner authorized this contribution and is responsible for its content.

@huong8373tt-beep
huong8373tt-beep marked this pull request as ready for review October 30, 2026 22:30
@github-actions

Copy link
Copy Markdown
  • [P2 non-blocking] Handle computed properties correctly (oxlint-plugin-teamai/rules/home-env.js:32). The rule treats any property identifier named HOME as the literal environment key, so const HOME = 'XDG_CONFIG_HOME'; process.env[HOME] is incorrectly rejected. Conversely, process.env['HOME'] bypasses the guard. Distinguish computed string literals from noncomputed identifiers.

The PR description provides sufficient testing, including built real-CLI smoke checks. No testing-record finding.

@SaulMoro SaulMoro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This was generated by AI during triage.

No blocking findings. teamai/home-env is on in .oxlintrc.json, main has no direct process.env.HOME read outside src/utils/home.ts, so turning it on breaks nothing, and CI is green.

[P2 non-blocking] The rule checks node.property without looking at node.computed (oxlint-plugin-teamai/rules/home-env.js:32). So process.env[HOME], where HOME is a variable holding another key, is reported, and process.env['HOME'] is not. Report a non-computed HOME identifier or a computed 'HOME' string literal, and add a rule.invalid case for process.env['HOME']. (The CI review found the same.)

[P3 nit] const { HOME } = process.env also gets past the rule; main has none today. The description doesn't link an issue; if this is part of #1590, say so.

@jeff-r2026 Your call: this turns on a new lint rule.

@huong8373tt-beep

Copy link
Copy Markdown
Contributor Author

Thanks for the follow-up. Fixed in 8bfad1db: the rule now reports non-computed process.env.HOME and computed string-literal process.env['HOME'], while leaving computed identifiers such as const HOME = 'XDG_CONFIG_HOME'; process.env[HOME] alone. Added both regression cases to the real-oxlint harness; focused tests (7 passed), typecheck, lint (0 warnings/errors), and git diff --check pass. The branch is updated and the existing #1590 linkage remains the scope of this PR.

Slai Agent Runtime performed the investigation, implementation, and test execution. The account owner authorized this contribution and is responsible for its content.

@github-actions

Copy link
Copy Markdown

No new findings in the scoped PR diff.

  • Resolved: The earlier [P2 non-blocking] computed-property finding is fixed. The rule distinguishes process.env[HOME] from process.env['HOME'], with regression tests for both.
  • Testing: The PR description includes sufficient validation and built real-CLI smoke checks. No testing-record finding.

Review was read-only; I did not run, build, or install anything from the PR.

@SaulMoro SaulMoro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This was generated by AI during triage.

Re-review at 8bfad1d. The computed-property finding is fixed: process.env['HOME'] is reported, process.env[HOME] with a variable is not, and both have a case. The destructuring and issue-link nits stand, and neither blocks. CI is green at this head.

@jeff-r2026 Your call: ready from my side.

@jeff-r2026 jeff-r2026 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Verified on main 8567110 (with #1601 landed): merges cleanly, tsc and lint (0 warnings/errors, so the enabled rule flags nothing on main) pass, oxlint-plugin-teamai rule tests + home.test.ts 34/34. Also verified earlier on 313341f with build.

@jeff-r2026
jeff-r2026 merged commit 42eade5 into Tencent:main Oct 31, 2026
18 checks passed
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
* ci(lint): guard direct HOME reads

* fix(lint): distinguish computed HOME reads
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.

3 participants