GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||
GeezerVison is showing github.com — fix: SharedServer feature parity columns and write guards by asheshv · Pull Request #9835 · pgadmin-org/pgadmin4 Conversation
|
WalkthroughExtends the Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@web/migrations/versions/add_user_id_to_debugger_func_args_.py`:
- Around line 161-164: The migration defines the 'kerberos_conn' column with
server_default='false'; change this to use SQLAlchemy's portable boolean literal
by setting server_default=sa.false() on the sa.Column(...) for 'kerberos_conn'
(and ensure sa.false is available from the imported sa namespace if not
already). This ensures the default renders as a proper SQL boolean literal
across DB backends.
In `@web/pgadmin/browser/server_groups/servers/__init__.py`:
- Around line 1182-1184: The current truthiness check for passexec_expiration
collapses an explicit 0 to None; change the conditional to test explicitly for
None (e.g. use "if server.passexec_expiration is not None else None") so that a
value of 0 is preserved when building the properties dict for
passexec_expiration and will round-trip correctly through the properties API.
- Around line 230-231: The update path currently computes tag deltas using
server.tags (the owner's tags) which causes non-owner SharedServer.tags to be
rebuilt from the owner; change the merge base so that when handling a non-owner
update (where SharedServer exists and you assign server.kerberos_conn =
sharedserver.kerberos_conn and server.tags = sharedserver.tags) you compute tag
diffs against sharedserver.tags (i.e. use SharedServer.tags as the base) instead
of server.tags inside update(), and apply only the delta to the non-owner
SharedServer record to avoid overwriting its existing tags.
In `@web/pgadmin/model/__init__.py`:
- Around line 563-569: The SCHEMA_VERSION constant was not incremented after
adding new SharedServer columns (passexec_cmd, passexec_expiration,
kerberos_conn, tags, post_connection_sql), so update the module's SCHEMA_VERSION
(e.g., from 50 to 51) where it is defined so upgrades detect and run the
migration for the SharedServer changes; ensure the new version is used by
migration/upgrade logic and any tests referencing SCHEMA_VERSION are updated
accordingly.
Fix all unresolved CodeRabbit comments on this PR:
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 49a1e807-6d76-4299-b568-5be7ba3c9c6e
web/migrations/versions/add_user_id_to_debugger_func_args_.pyweb/pgadmin/browser/server_groups/servers/__init__.pyweb/pgadmin/browser/server_groups/servers/tests/test_shared_server_unit.pyweb/pgadmin/model/__init__.pyweb/pgadmin/utils/driver/psycopg3/__init__.py
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Add passexec_cmd, passexec_expiration, kerberos_conn, tags, and post_connection_sql to SharedServer so non-owners get their own per-user values instead of inheriting the owner's. Drop the unused db_res column which was never overlaid or writable by non-owners. Key changes: - New Alembic migration (sharedserver_feature_parity) adds 5 columns, drops db_res, cleans up orphaned records. All operations idempotent. - Overlay copies new fields from SharedServer instead of suppressing - _owner_only_fields guard blocks non-owners from setting passexec_cmd, passexec_expiration, db_res, db_res_type via API - Non-owners can set post_connection_sql (runs under their own creds) - update_tags and flag_modified use sharedserver for non-owners - update() response returns sharedserver tags for non-owners - ServerManager passexec suppression with config.SERVER_MODE guard - UI: post_connection_sql editable for non-owners (readonly only when connected, not when shared) - SCHEMA_VERSION bumped to 51 - Comprehensive unit tests for overlay, write guards, and tag deltas
0fd0ac3 to
4c1705e
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
web/pgadmin/browser/server_groups/servers/__init__.py (1)
965-985:⚠️ Potential issue | 🟡 MinorReturn the overlaid record in the update response.
For non-owner edits, this block still serializes most node fields from the owner
serverrow. Onlytagswas switched tosharedserver or server, so updates to fields likeusername,role, orsave_passwordcome back stale until the next fetch.🔧 Suggested fix
+ node_server = server + if sharedserver is not None: + node_server = ServerModule.get_shared_server_properties( + server, sharedserver) + return jsonify( node=self.blueprint.generate_browser_node( - "%d" % (server.id), server.servergroup_id, - server.name, + "%d" % (node_server.id), node_server.servergroup_id, + node_server.name, server_icon_and_background( - connected, manager, sharedserver) - if _is_non_owner(server) - else server_icon_and_background( - connected, manager, server), + connected, manager, node_server), True, self.node_type, connected=connected, - shared=server.shared, - user_id=server.user_id, + shared=node_server.shared, + user_id=node_server.user_id, user=manager.user_info if connected else None, server_type='pg', # default server type - username=server.username, - role=server.role, - is_password_saved=bool(server.save_password), - description=server.comment, - tags=(sharedserver or server).tags + username=node_server.username, + role=node_server.role, + is_password_saved=bool(node_server.save_password), + description=node_server.comment, + tags=node_server.tags ) )🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@web/pgadmin/browser/server_groups/servers/__init__.py` around lines 965 - 985, The response uses owner `server` fields even for non-owner edits so returned values (username, role, is_password_saved, description, tags, etc.) can be stale; when _is_non_owner(server) is true, pick the overlaid record (sharedserver or server) as the source and pass its attributes to self.blueprint.generate_browser_node and related calls (e.g., username, role, save_password -> is_password_saved, comment -> description, tags) and use that same source for server_icon_and_background instead of mixing owner and overlay; update the code around generate_browser_node to compute something like source = (sharedserver or server) when _is_non_owner(server) and read source.username, source.role, bool(source.save_password), source.comment, source.tags, and pass source into server_icon_and_background.
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@web/pgadmin/browser/server_groups/servers/__init__.py`:
- Around line 965-985: The response uses owner `server` fields even for
non-owner edits so returned values (username, role, is_password_saved,
description, tags, etc.) can be stale; when _is_non_owner(server) is true, pick
the overlaid record (sharedserver or server) as the source and pass its
attributes to self.blueprint.generate_browser_node and related calls (e.g.,
username, role, save_password -> is_password_saved, comment -> description,
tags) and use that same source for server_icon_and_background instead of mixing
owner and overlay; update the code around generate_browser_node to compute
something like source = (sharedserver or server) when _is_non_owner(server) and
read source.username, source.role, bool(source.save_password), source.comment,
source.tags, and pass source into server_icon_and_background.
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 0efc8367-6e92-495f-bcb0-eaee6d213a28
web/migrations/versions/sharedserver_feature_parity_.pyweb/pgadmin/browser/server_groups/servers/__init__.pyweb/pgadmin/browser/server_groups/servers/static/js/server.ui.jsweb/pgadmin/browser/server_groups/servers/tests/test_shared_server_unit.pyweb/pgadmin/model/__init__.pyweb/pgadmin/utils/driver/psycopg3/__init__.py
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Replaces the "(CVE pending)" markers on the seven placeholder issues with their assigned identifiers: #9830 -> CVE-2026-7813 (cross-user data access / shared-server escalation) #9865 -> CVE-2026-7814 (stored XSS via crafted PostgreSQL object names) #9898 -> CVE-2026-7815 (SQL injection in Maintenance tool option values) #9899 -> CVE-2026-7816 (OS command injection in Import/Export query export) #9900 -> CVE-2026-7817 (LFI/SSRF in LLM API configuration endpoints) #9901 -> CVE-2026-7818 (unsafe deserialization in session manager) #9902 -> CVE-2026-7819 (symlink path traversal in file manager) #9904 -> CVE-2026-7820 (account-lockout bypass via Flask-Security /login) #9835 is a follow-up to #9830 and shares CVE-2026-7813, so its parenthetical is dropped rather than replaced with a separate ID. To be revealed publicly when this branch is pushed for the 9.15 release.
…umes Refs pgadmin-org#9940. Issue pgadmin-org#9940 reported a SQLite "no such column: sharedserver.db_res" error on a Kubernetes deployment where the main pgAdmin container was pinned to 9.13 but an init container (running `setup.py load-servers` to import a servers.json) used the `pgadmin4:latest` image. The init container's migrations advanced the schema past 9.13's ORM expectations — specifically the `sharedserver_feature_parity_` migration (introduced in 9.15 via PR pgadmin-org#9835) drops the `db_res` column from `sharedserver`. This is a real hazard of pgAdmin's forward-only-with-destructive- operations migration model when combined with the K8s init-container pattern, but it wasn't documented anywhere. Operators hitting this have no guidance on how to avoid it. Add a short section to docs/en_US/container_deployment.rst: - The single rule: init container's image tag must NOT be newer than the main container's, when they share a data volume. - A concrete Helm-values example showing the pinned tags side by side, with an explicit "Do NOT use :latest" note. - A reminder that during upgrades, every reference to the image tag must move together. Pure docs-only change — no code touched. Reviewable on its own.
PR pgadmin-org#9830 (CVE-2026-7813) unconditionally nulled manager.passexec for non-owners of a shared server, which also made ENABLE_SERVER_PASS_EXEC_CMD meaningless for them even though the SharedServer.passexec_cmd column (added in pgadmin-org#9835) already gave each non-owner a place to store their own command. _owner_only_fields additionally blocked the update API from ever writing to it, and the front-end field was already live and unguarded by isShared, so the value was unreachable. Continue to never honour the *owner's* passexec_cmd for a non-owner -- that's the actual privilege-escalation vector the CVE fix closed, since any authenticated user can own a shared server. But a non-owner's own SharedServer.passexec_cmd only ever runs in their own request context, exactly like an owned server's would, so there's no reason to block it. Closes pgadmin-org#10249
PR pgadmin-org#9830 (CVE-2026-7813) unconditionally nulled manager.passexec for non-owners of a shared server, which also made ENABLE_SERVER_PASS_EXEC_CMD meaningless for them even though the SharedServer.passexec_cmd column (added in pgadmin-org#9835) already gave each non-owner a place to store their own command. _owner_only_fields additionally blocked the update API from ever writing to it, and the front-end field was already live and unguarded by isShared, so the value was unreachable. Continue to never honour the *owner's* passexec_cmd for a non-owner -- that's the actual privilege-escalation vector the CVE fix closed, since any authenticated user can own a shared server. But a non-owner's own SharedServer.passexec_cmd only ever runs in their own request context, exactly like an owned server's would, so there's no reason to block it. Closes pgadmin-org#10249
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.