Repository navigation
Install the workspace policy at ug configure - #1259
Conversation
|
/ug-review |
|
/ug-review |
Polly AI ReviewBlocking issues
Security vulnerabilitiesNo newly introduced security vulnerability was confirmed. The documented world-readable policy format is intentional; administrators must not place credentials in it. Non-blocking notes
ApproachThe existing managed writer and shell worker are appropriate boundaries. SummaryDiff size (computed): 19 files; +935 / -36 lines (971 changed text lines); 0 binary files.
Shares use additions + deletions, including generated text and lockfiles. Binary files have no line count. Tests include fixtures/helpers under test paths and colocated test/spec files; categories are path-based, not coverage measurements. ChangesThe PR installs a machine-wide workspace-policy envelope during configure, removes it when no policy is published, and adds revert handling. Launches continue using the per-user cache. Supporting changes cover privileged writes, platform and opt-out gates, test isolation, cleanup, and documentation. No dependency or generated-file changes contribute to the diff. Most of the breadth follows from introducing a privileged filesystem boundary. A concrete implementation reduction is sharing the temporary-source, sudo invocation, and error-normalization machinery between TestsTest-by-test assessmentThe frozen diff’s checksum and both trusted review policies were verified. Static parsing confirmed the import failure; the reconstructed file also matches the diff’s post-image blob hash. No tests, lint, or type checks were executed, so the description’s green-gate claims are not independently confirmed. Existing TTL, config-scope, and shell replacement/rollback tests provide relevant coverage. No existing test function was directly removed or weakened; fixture changes alter their execution. The supplied checkout has no
After fixing the import failure, run: uv run pytest tests/test_managed_config.py tests/test_managed_files.py tests/test_integration_runner.py
just lintOn a disposable POSIX host, verify configure creates the documented owner/modes, repeated configure leaves unchanged policy untouched, and denied sudo produces recovery guidance. Also verify installation-only checks preserve a policy that existed before the test run. ScopeNo clearly unrelated changes were found. The implementation, revert behavior, documentation, preflight checks, and cleanup all support the workspace-policy lifecycle. The installation-only teardown defect is an unsafe implementation of that supporting cleanup, not a separate requested outcome. Automated review by Polly · workflow run |
Explicit ug configure now installs the workspace policy at /etc/unitygateway/managed-settings.json on Linux and macOS, using a non-interactive-sudo-capable writer. Unchanged policy writes nothing, and no-config or feature-disabled removes the installed file. A failed install raises ManagedPolicyInstallDenied with an actionable message. Launches keep reading the per-user cache and never touch the machine file. Co-authored-by: Isaac <no-reply@databricks.com>
`ug revert` deletes /etc/unitygateway/managed-settings.json with sudo; nothing else writes that file. Without sudo it warns and keeps it, and Windows, UG_SKIP_OS_SETTINGS and `--user` leave it alone. Test cleanup keeps a backstop removal in its own finally, so a failed or skipped revert can no longer leave the policy behind for later cases. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Removal hands the replace script the exact bytes of the installed file, so a file with a BOM or CRLF endings still matches its byte-for-byte check. Add a regression test and a comment on why the copy is binary. Co-authored-by: Isaac <no-reply@databricks.com>
f8b2f1d to
146a07a
Compare
Removing /etc/unitygateway/managed-settings.json left an empty /etc/unitygateway/ behind. ug created that folder for the policy, so remove it too; rmdir leaves it in place if anything else is there. Co-authored-by: Isaac <no-reply@databricks.com>
## 🥞 Stacked PR Use this [link](https://github.com/databricks/unity-gateway/pull/1260/files/6ba7a3011ea0819265eedf572012cac0bbbb4192..99fe5a1a10574107c95c514d99fb5ac770d07dc0) to review incremental changes. - [mdm-policy-write](databricks#1259) [[Files changed](https://github.com/databricks/unity-gateway/pull/1259/files)] - [**mdm-policy-read**](databricks#1260) [[Files changed](https://github.com/databricks/unity-gateway/pull/1260/files/6ba7a3011ea0819265eedf572012cac0bbbb4192..99fe5a1a10574107c95c514d99fb5ac770d07dc0)] ← _this PR_ - [mdm-policy-windows](databricks#1262) [[Files changed](https://github.com/databricks/unity-gateway/pull/1262/files/054432159de3b7c08ada7587c110d35a4be1190e..653d83aa3ea952cc4c5d82e79ad00810d8c2a49c)] --------- **Worktree:** unity-gateway | **Branch:** mdm-policy-read ## What did you change, and why? Second of two stacked PRs replacing databricks#1228. It's based on databricks#1259, which installs the policy file. Launches now read the installed policy instead of the per-user cache on Linux and macOS: - `ug`, `ug claude` and `ug codex` refuse any other workspace. Only `ug configure` can switch it. - Refresh happens at most every 5 minutes, through `~/.ucode/refresh_ts.json`. - A first launch before any configure applies the fetched policy for that run. - If sudo is denied, the saved workspace stays on the installed one. Windows, `UG_SKIP_OS_SETTINGS` and `--user` keep the per-user cache unchanged. ## How do you know it works? Unit tests cover enforcement, refresh and fallback. The CUJ and integration harnesses read the installed policy. Lint and ty are clean. https://github.com/user-attachments/assets/83ff7f44-6189-47ab-bd73-937e22ccdeb5 --------- Co-authored-by: Isaac <no-reply@databricks.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
🥞 Stacked PR
Use this link to review incremental changes.
Worktree: unity-gateway | Branch: mdm-policy-write
What did you change, and why?
First of two stacked PRs that replace #1228, porting #1105's machine workspace policy. This one only writes it: on Linux and macOS,
ug configurefor Claude or Codex installs the workspace's managed config as root-owned/etc/unitygateway/managed-settings.json({workspace, config},0644in a root0755folder) using sudo. It rewrites the file only on change and removes it when the workspace publishes none. If sudo is denied, configure fails with steps to fix it.Launches don't change: they still read the per-user cache. Windows,
UG_SKIP_OS_SETTINGSand--userwrite nothing. #1260 makes launches read the file.How do you know it works?
New unit tests cover the writer and the install, replace and remove paths. One integration test checks that configure installs a root-owned file. Lint and ty are clean.
Screen.Recording.2026-10-23.at.7.13.59.AM.mov