Commit Graph

5751 Commits

Author SHA1 Message Date
Mahima Shanware 9ff03ddd20 fix(core): remove redundant plansDirCache to avoid stale configs and satisfy bot 2026-04-07 16:53:10 +00:00
Mahima Shanware 50d8880e9c fix(core): remove lint disablers in plan directory validation
Replaced eslint-disable-next-line comments with explicit type guarding (checking instanceof Error and 'code') and used process.stderr.write instead of console.warn to comply with project linting rules natively.
2026-04-07 16:40:32 +00:00
Mahima Shanware 495931be79 fix(core): remove duplicate isSubpath import
Moved the isSubpath and resolveToRealPath imports to the top of the file to satisfy the static analysis bot, which failed to detect the existing import statement further down in the file.
2026-04-07 16:40:31 +00:00
Mahima Shanware df8f1a8f03 fix: address review bot feedback on concurrency and error handling
- Reverted the 'isIdle' guard in AppContainer.tsx to ensure slash commands entered while the agent is busy are correctly processed or queued, preventing them from falling through as regular chat text.
- Enhanced the physical path validation in config.ts to gracefully handle 'mkdirSync' failures (e.g. EACCES). The CLI will now log a warning and return the lexically-validated path instead of throwing a misleading 'Security violation' via 'resolveToRealPath'.
2026-04-07 16:40:31 +00:00
Mahima Shanware 7c0cfd53df fix(core): gracefully degrade global config dir path validation on EACCES
If the user's home directory or global `.gemini` config directory has
restrictive permissions that prevent `realpathSync` from succeeding, the
CLI should not crash. Instead, it now gracefully degrades by omitting
the global config directory from the valid security boundaries for plan
directories, allowing the CLI to continue operating securely within the
project root.
2026-04-07 16:40:31 +00:00
Mahima Shanware 432df7982c fix: address final review feedback on context resets and pre-creation path validation 2026-04-07 16:40:31 +00:00
Mahima Shanware 35fd166bce fix(core): ensure global gemini dir resolution is crash-safe during plan validation 2026-04-07 16:40:31 +00:00
Mahima Shanware e42b762553 fix(core): ensure path validation always executes even if mkdirSync fails 2026-04-07 16:40:31 +00:00
Mahima Shanware 76c28142eb fix(cli): remove /plan extension context hacks and fix dropped queue messages 2026-04-07 16:40:31 +00:00
Mahima Shanware 7ab4c3d61f fix(core,cli): resolve TOCTOU, concurrency, and performance regressions in plan resolution 2026-04-07 16:40:31 +00:00
Mahima Shanware ded474c2d0 fix(core): fail-closed security for plan directory TOCTOU
Resolves security review findings:
- Reordered resolveToRealPath before mkdirSync to fully eliminate TOCTOU risks with symlink injection.
- Fail closed by re-throwing 'Security violation' errors instead of swallowing them.
- Replaced lint-disabler with process.stderr.write for legitimate fallback warnings.
- Used direct context string as LRUCache key to avoid collision with an extension potentially named 'default'.
2026-04-07 16:35:24 +00:00
Mahima Shanware 3256b16039 fix(core): mitigate TOCTOU vulnerability in plan directory creation
This change addresses a critical security review finding regarding a Time-of-Check to Time-of-Use (TOCTOU) vulnerability.

Previously, plan directory paths were validated using `isSubpath` before creation. However, an attacker could potentially replace a path component with a symlink pointing outside the project root exactly between validation and creation.

By resolving the physical path *after* `fs.mkdirSync` using `resolveToRealPath` and then verifying it with `isSubpath`, we ensure that the actual directory created on disk resides safely within the workspace. Any violation results in a warning, and the malicious path is prevented from being added to the agent's `workspaceContext`.
2026-04-07 16:35:24 +00:00
Mahima Shanware 5e89760856 perf(core): optimize plan directory resolution with LRUCache and cached project root
This commit addresses the final performance and usability review comments:

- **Performance:** Introduced `LRUCache` for `plansDirCache` and `initializedPlanDirs` to prevent redundant, synchronous filesystem calls to `Storage.getPlansDir` on every turn.
- **Performance:** Cached the resolved `realProjectRoot` in the `Storage` constructor, eliminating expensive synchronous symlink resolution calls during active command routing.
- **Usability:** Replaced hard `throw` with `console.warn` when `fs.mkdirSync` fails (e.g., `EACCES`, `EEXIST`), allowing the CLI to gracefully degrade and continue functioning rather than crashing the entire process.
- **Validation:** Updated `config.test.ts` to verify the exact warning messages emitted during filesystem failures.
2026-04-07 16:35:24 +00:00
Mahima Shanware 6559fdbc31 fix(core,cli): address review findings for plan dir resolution and security
This commit addresses several critical findings from the review bot:

- **Security:** Implemented defense-in-depth symlink resolution. Removed insecure string-based fallbacks in `Storage.getPlansDir` and added a mandatory `isSubpath` validation AFTER directory creation in `Config.getPlansDir` to prevent TOCTOU traversal attacks.
- **Architecture:** Fixed a race condition where active extension context was mutated synchronously in `AppContainer`, potentially corrupting concurrent background tasks. Mutation now occurs within the command execution pipeline.
- **Robustness:** Switched to canonical path checking for `plan` command detection to support aliases and subcommands.
- **Regressions:** Added a `planEnabled` guard to prevent unwanted directory creation when the planning feature is disabled.
- **Validation:** Added exhaustive unit tests covering sequential context switching, shared directory deduplication, and symlink security edge cases.
2026-04-07 16:35:24 +00:00
Mahima Shanware a5c2bf81f4 fix(core): remove redundant ENOENT fallback in getPlansDir to fix traversal vulnerability
This removes the insecure ENOENT fallback in `Storage.getPlansDir` that could be exploited to bypass the `isSubpath` check via symlinks. The fallback was unnecessary because the underlying `resolveToRealPath` function (via `robustRealpath`) was recently updated to gracefully handle and resolve symlinks for non-existent target paths.
2026-04-07 16:35:24 +00:00
Mahima Shanware b5d92caf89 fix(core): handle plan dir EEXIST safely and rely on mkdir idempotency
This addresses a potential TOCTOU vulnerability and edge case identified during review. The redundant `fs.existsSync` check in `getPlansDir` has been removed, allowing `fs.mkdirSync(..., { recursive: true })` to safely handle directory idempotency.

By relying directly on `mkdirSync`, we ensure that if a non-directory file already exists at the target path, the system will correctly throw an `EEXIST` error rather than silently treating the file as a directory and crashing later during workspace registration.
2026-04-07 16:35:23 +00:00
Mahima Shanware 81c74e1483 perf(core): cache initialized plan directories
Adds caching to getPlansDir to avoid redundant synchronous disk I/O and repeated workspace context registrations.
2026-04-07 16:35:23 +00:00
Mahima Shanware b2f7c157ce fix(cli): consistently clear sticky extension context
This fixes a bug where the active extension context would remain sticky when a user switched from an extension command to a standard non-plan command, or to an extension without a plan directory.

The context is now correctly reset to undefined when an extension command without a plan directory is executed, preventing subsequent plan mode invocations from incorrectly targeting the previous extension's folder.
2026-04-07 16:35:23 +00:00
Mahima Shanware 0a8195fb3a fix(core): address extension context stickiness and symlink path resolution
This commit addresses two bugs identified during review:

1. Cleared the sticky `activeExtensionContext` when the standard `/plan` command is executed, ensuring subsequent prompts correctly target the default global plan directory.
2. Fixed a path resolution regression in `Storage.getPlansDir()` by constructing the fallback ENOENT path directly against the real project root. This prevents `isSubpath` validation failures and potential traversal vulnerabilities when the project root is a symlink.
2026-04-07 16:35:23 +00:00
Mahima Shanware 058b5e31b4 feat(cli): wire active extension context into slash command routing
Extracts the extension context from slash commands based on their registered metadata and sets it as the active context in the Config before execution. This enables the backend to dynamically route plan directories based on the extension that owns the invoked command.
2026-04-07 16:35:23 +00:00
Mahima Shanware 402a96a519 fix(core): migrate consumers to lazily-evaluated getPlansDir
Updates prompts and tool implementations (edit, write-file, enter/exit plan mode) to route through Config.getPlansDir() instead of Storage.getPlansDir(). This ensures the plan directory is lazily created exactly when these features attempt to use it, preventing ENOENT failures.
2026-04-07 16:35:23 +00:00
Mahima Shanware bdf90e9985 feat(core): dynamic MRU plan directory resolution and lazy initialization
Introduces active extension context tracking in config to support dynamic switching of plan directories. Resolves circular dependency in storage by deferring plan directory creation until on-demand use, preventing ENOENT errors on non-existent paths.
2026-04-07 16:34:08 +00:00
Emily Hedlund 1762c9c509 temporarily disable sandbox integration test on windows (#24786) 2026-04-07 15:33:40 +00:00
Abhijit Balaji 0025978d76 feat(cli): support selective topic expansion and click-to-expand (#24793) 2026-04-07 15:00:40 +00:00
Gaurav 4c5e887732 feat(telemetry): add browser agent clearcut metrics (#24688) 2026-04-07 07:48:38 +00:00
Abhi 83096c68b0 fix(policy): allow complete_task in plan mode (#24771) 2026-04-07 03:43:42 +00:00
Christian Gunderman d2b775f9a7 Add an eval for and fix unsafe cloning behavior. (#24457) 2026-04-07 03:17:44 +00:00
Spencer 0a8da988ed fix(cli): ensure skills list outputs to stdout in non-interactive environments (#24566) 2026-04-07 02:40:23 +00:00
David Pierce 984f02c180 relax tool sandboxing overrides for plan mode to match defaults. (#24762) 2026-04-06 22:18:10 +00:00
Tommaso Sciortino df67f973ed fix(cli): respect global environment variable allowlist (#24767) 2026-04-06 22:17:55 +00:00
Christian Gunderman 7872d6d7fe fix(ui): improve narration suppression and reduce flicker (#24635) 2026-04-06 21:18:59 +00:00
Gaurav e116aa34f4 fix(browser): remove premature browser cleanup after subagent invocation (#24753) 2026-04-06 21:17:31 +00:00
Abhijit Balaji ad98294352 Revert "feat(core,cli): prioritize summary for topics (#24608)" (#24777) 2026-04-06 20:33:18 +00:00
Dev Randalpura 2353a6d253 fix(ui): fixed auth race condition causing logo to flicker (#24652) 2026-04-06 20:17:05 +00:00
krishdef7 8ac560d2c9 fix(core): handle partial llm_request in BeforeModel hook override (#22326) 2026-04-06 20:11:38 +00:00
Tommaso Sciortino c6a9d3de13 fix(cli): remove -S from shebang to fix Windows and BSD execution (#24756) 2026-04-06 19:06:56 +00:00
Christian Gunderman 8f131ffef7 Fix issue where topic headers can be posted back to back (#24759) 2026-04-06 18:36:22 +00:00
Jacob Richman 70f6d6a992 split context (#24623) 2026-04-06 17:20:38 +00:00
cynthialong0-0 c96cb09e09 feat(cli): add role specific metrics to /stats (#24659) 2026-04-06 16:20:48 +00:00
Sri Pasumarthi 15298b28c2 feat(acp): add support for /about command (#24649) 2026-04-04 07:42:27 +00:00
Gal Zahavi 7311e242ec feat(cli): enhance tool confirmation UI and selection layout (#24376) 2026-04-04 01:32:35 +00:00
Gal Zahavi 21a3925f99 docs: update sandboxing documentation and toolSandboxing settings (#24655) 2026-04-04 01:26:41 +00:00
Jacob Richman ec35ebbe57 fix(core): detect uninitialized lines (#24646) 2026-04-04 00:51:29 +00:00
Gal Zahavi 65024d4538 fix(core): ensure global temp directory is always in sandbox allowed paths (#24638)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2026-04-04 00:23:27 +00:00
Samee Zahid 4fb3790051 feat(core): discourage update topic tool for simple tasks (#24640)
Co-authored-by: Samee Zahid <sameez@google.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2026-04-03 23:52:24 +00:00
Christian Gunderman 4a040931ef Fix restoration of topic headers. (#24650) 2026-04-03 23:50:38 +00:00
Alisa e74efc5c0b Do not run pr-eval workflow when no steering changes detected (#24621) 2026-04-03 22:54:05 +00:00
Jacob Richman d5a5995281 feat(cli) Scrollbar for input prompt (#21992) 2026-04-03 22:10:04 +00:00
Gal Zahavi 893ae4d29a fix(core): ensure sandbox approvals are correctly persisted and matched for proactive expansions (#24577) 2026-04-03 21:48:18 +00:00
Emily Hedlund 370c45de67 fix(core): improve windows sandbox reliability and fix integration tests (#24480) 2026-04-03 20:54:48 +00:00