Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

Marketplace trust: split 409 reasons, hide unreviewed outside dev mode

Juan Denise8d84297f2c6
diff --git a/backend/app/api/marketplace.py b/backend/app/api/marketplace.py
index d17a7946..bbc6e525 100644
--- a/backend/app/api/marketplace.py
+++ b/backend/app/api/marketplace.py
@@ -46,23 +46,41 @@ def install_registry(slug):
if not user or not user.is_admin:
return jsonify({'error': 'Admin access required'}), 403
- # Trust gate: an unreviewed community extension (or one with no pinned
- # checksum) installs only after an explicit risk acknowledgment — the
- # Marketplace shows a confirmation dialog and resends with
- # acknowledge_risk: true. first_party / reviewed entries install as-is.
+ # Trust gate: an unreviewed community extension, or any entry with no
+ # pinned checksum (possible even for first_party), installs only after an
+ # explicit risk acknowledgment — the Marketplace shows a confirmation
+ # dialog and resends with acknowledge_risk: true. first_party / reviewed
+ # entries install as-is. `reason` tells the UI which case it is so the
+ # dialog copy stays accurate.
from app.services import registry_service
entry = registry_service.get_entry(slug)
+ # Hidden means not installable: unreviewed entries only exist in
+ # development contexts (see registry_service._show_unreviewed).
+ if entry is not None and entry.get('trust') == 'unreviewed' \
+ and not registry_service._show_unreviewed():
+ return jsonify({'error': 'Extension not found in the registry'}), 404
body = request.get_json(silent=True) or {}
trust = (entry or {}).get('trust', 'unreviewed')
acknowledged = body.get('acknowledge_risk') is True
- if entry is not None and not acknowledged and (
- trust == 'unreviewed' or not entry.get('sha256')):
+ reason = None
+ if entry is not None and not acknowledged:
+ if trust == 'unreviewed':
+ reason = 'unreviewed'
+ elif not entry.get('sha256'):
+ reason = 'unverified'
+ if reason:
+ message = (
+ 'This community extension has not been reviewed by the ServerKit '
+ 'maintainers; installing it runs unreviewed code with full panel '
+ 'privileges.'
+ if reason == 'unreviewed' else
+ 'This extension has no pinned checksum, so the panel cannot '
+ 'verify the artifact it would install.'
+ )
return jsonify({
- 'error': 'This community extension has not been reviewed by the '
- 'ServerKit maintainers; installing it runs unreviewed code '
- 'with full panel privileges. Resend with '
- 'acknowledge_risk: true to proceed.',
+ 'error': f'{message} Resend with acknowledge_risk: true to proceed.',
'trust': trust,
+ 'reason': reason,
'requires_acknowledgment': True,
}), 409
diff --git a/backend/app/services/registry_service.py b/backend/app/services/registry_service.py
index ea52d788..a1a5d607 100644
--- a/backend/app/services/registry_service.py
+++ b/backend/app/services/registry_service.py
@@ -204,6 +204,28 @@ def refresh(force=False):
return entries
+def _show_unreviewed():
+ """Unreviewed community entries are developer-stage content.
+
+ They list in the Marketplace (and install, behind the 409 risk
+ acknowledgment) only when the panel runs in a development context:
+ Flask debug mode (development/testing config) or the ``dev_mode``
+ setting toggled on in Settings. Production panels with dev_mode off
+ never see them — a hidden extension is not installable either.
+ """
+ try:
+ from flask import current_app
+ if current_app.debug or current_app.config.get('TESTING'):
+ return True
+ except RuntimeError:
+ return False # no app context (CLI/scripts): hide by default
+ try:
+ from app.services.settings_service import SettingsService
+ return bool(SettingsService.get('dev_mode'))
+ except Exception:
+ return False
+
+
def list_extensions():
return refresh()
@@ -245,6 +267,8 @@ def list_catalog(include_bundled=False):
entries = refresh()
if not include_bundled:
entries = [e for e in entries if not e.get('bundled')]
+ if not _show_unreviewed():
+ entries = [e for e in entries if e.get('trust') != 'unreviewed']
return [to_catalog_dict(e) for e in entries]
diff --git a/backend/app/services/settings_service.py b/backend/app/services/settings_service.py
index 38e6665d..8422f396 100644
--- a/backend/app/services/settings_service.py
+++ b/backend/app/services/settings_service.py
@@ -62,7 +62,7 @@ class SettingsService:
'dev_mode': {
'value': False,
'type': 'boolean',
- 'description': 'Enable developer mode for debugging tools and icon reference'
+ 'description': 'Enable developer mode: debugging tools, icon reference, and unreviewed community extensions in the Marketplace'
},
'managed_app_base_port': {
'value': 0,
diff --git a/backend/tests/test_registry.py b/backend/tests/test_registry.py
index c2326f0b..e1badd16 100644
--- a/backend/tests/test_registry.py
+++ b/backend/tests/test_registry.py
@@ -434,6 +434,7 @@ def test_install_gate_blocks_unreviewed_without_ack(app, client, auth_headers, f
data = resp.get_json()
assert data['requires_acknowledgment'] is True
assert data['trust'] == 'unreviewed'
+ assert data['reason'] == 'unreviewed'
assert 'unreviewed' in data['error']
@@ -445,7 +446,10 @@ def test_install_gate_blocks_first_party_without_sha256(app, client, auth_header
resp = client.post('/api/v1/marketplace/registry/community-ext/install',
headers=auth_headers)
assert resp.status_code == 409
- assert resp.get_json()['requires_acknowledgment'] is True
+ data = resp.get_json()
+ assert data['requires_acknowledgment'] is True
+ assert data['reason'] == 'unverified'
+ assert 'checksum' in data['error']
def test_install_gate_passes_with_acknowledge_risk(app, client, auth_headers, fake_install, monkeypatch):
@@ -467,3 +471,45 @@ def test_install_gate_unaffected_for_reviewed(app, client, auth_headers, fake_in
resp = client.post('/api/v1/marketplace/registry/community-ext/install',
headers=auth_headers)
assert resp.status_code == 201
+
+
+def test_catalog_hides_unreviewed_outside_dev_mode(app, client, auth_headers, monkeypatch):
+ # Production panel with dev_mode off: unreviewed entries never list.
+ monkeypatch.setattr(registry_service, '_show_unreviewed', lambda: False)
+ _seed_cache(monkeypatch, _entry())
+ resp = client.get('/api/v1/marketplace/registry', headers=auth_headers)
+ assert resp.status_code == 200
+ assert resp.get_json()['extensions'] == []
+
+
+def test_catalog_lists_unreviewed_in_dev_mode(app, client, auth_headers, monkeypatch):
+ monkeypatch.setattr(registry_service, '_show_unreviewed', lambda: True)
+ _seed_cache(monkeypatch, _entry())
+ resp = client.get('/api/v1/marketplace/registry', headers=auth_headers)
+ assert resp.status_code == 200
+ slugs = [e['slug'] for e in resp.get_json()['extensions']]
+ assert 'community-ext' in slugs
+
+
+def test_catalog_keeps_reviewed_visible_outside_dev_mode(app, client, auth_headers, monkeypatch):
+ monkeypatch.setattr(registry_service, '_show_unreviewed', lambda: False)
+ _seed_cache(monkeypatch, _entry(review={'reviewer': 'jhd3197', 'sha256': _SHA_A}))
+ resp = client.get('/api/v1/marketplace/registry', headers=auth_headers)
+ assert resp.status_code == 200
+ slugs = [e['slug'] for e in resp.get_json()['extensions']]
+ assert 'community-ext' in slugs
+
+
+def test_install_hidden_unreviewed_returns_404(app, client, auth_headers, fake_install, monkeypatch):
+ # Hidden means not installable, even with acknowledge_risk.
+ monkeypatch.setattr(registry_service, '_show_unreviewed', lambda: False)
+ _seed_cache(monkeypatch, _entry())
+ resp = client.post('/api/v1/marketplace/registry/community-ext/install',
+ headers=auth_headers, json={'acknowledge_risk': True})
+ assert resp.status_code == 404
+
+
+def test_show_unreviewed_defaults_on_under_testing_config(app):
+ # The test suite runs with DEBUG/TESTING on, i.e. a development context.
+ with app.test_request_context():
+ assert registry_service._show_unreviewed() is True
diff --git a/docs/EXTENSIONS_REGISTRY.md b/docs/EXTENSIONS_REGISTRY.md
index 1f481877..cfe8a4fe 100644
--- a/docs/EXTENSIONS_REGISTRY.md
+++ b/docs/EXTENSIONS_REGISTRY.md
@@ -162,12 +162,21 @@ The Marketplace renders **Reviewed** (with a *Reviewed by \<reviewer\> on
entry with no `sha256` to verify against — requires explicit consent:
`POST /api/v1/marketplace/registry/<slug>/install` without
`{"acknowledge_risk": true}` in the JSON body returns **409** with
-`{"error": …, "trust": …, "requires_acknowledgment": true}`. The Marketplace
-catches this, shows a confirmation dialog explaining that the extension is
-unreviewed community code running with full panel privileges, and resends with
-`acknowledge_risk: true` only if the operator confirms (the acknowledgment is
-recorded in the audit log). `first_party` and `reviewed` entries install
-unchanged, with no extra prompt.
+`{"error": …, "trust": …, "reason": …, "requires_acknowledgment": true}`,
+where `reason` is `unreviewed` (community code not vetted) or `unverified`
+(no pinned checksum, possible even for `first_party`). The Marketplace catches
+this, shows a confirmation dialog whose copy matches the reason, and resends
+with `acknowledge_risk: true` only if the operator confirms (the
+acknowledgment is recorded in the audit log). `first_party` and `reviewed`
+entries install unchanged, with no extra prompt.
+
+**Unreviewed entries are developer-stage content.** On a production panel
+(Flask debug off, `dev_mode` setting off) `unreviewed` entries do not appear
+in the Marketplace at all, and the install endpoint answers **404** for them —
+hiding is the default, the 409 acknowledgment flow only exists where they are
+visible. They list and install only in development contexts: Flask debug mode
+(development/testing config) or the `dev_mode` setting toggled on under
+Settings → Site. `first_party` and `reviewed` entries are unaffected.
---
diff --git a/frontend/src/pages/Marketplace.jsx b/frontend/src/pages/Marketplace.jsx
index a34fbc45..37eee3b2 100644
--- a/frontend/src/pages/Marketplace.jsx
+++ b/frontend/src/pages/Marketplace.jsx
@@ -108,7 +108,7 @@ const sourceBadgeVariant = (source) => {
};
// Trust badge derived from the registry's hash-bound review stamp. 'reviewed'
-// shows who/when in the tooltip; 'unreviewed' warns on registry cards only
+// shows who/when in the tooltip; 'unreviewed' warns on registry entries
// (built-in entries never carry a trust field).
const TrustBadge = ({ entry }) => {
if (entry.trust === 'reviewed') {
@@ -196,8 +196,10 @@ const Marketplace = () => {
const [manualInstallSource, setManualInstallSource] = useState(null);
const [installing, setInstalling] = useState(false);
const [detailEntry, setDetailEntry] = useState(null);
- // Registry slug awaiting unreviewed-risk confirmation — drives the
- // acknowledge-risk dialog (confirm retries with acknowledge_risk: true).
+ // Registry entry awaiting risk confirmation — drives the acknowledge-risk
+ // dialog (confirm retries with acknowledge_risk: true). Shape:
+ // { slug, reason } where reason is 'unreviewed' (proactive gate or 409)
+ // or 'unverified' (409: entry has no pinned checksum).
const [riskTarget, setRiskTarget] = useState(null);
// Plugin pending uninstall — drives the keep-vs-purge data-policy dialog.
const [uninstallTarget, setUninstallTarget] = useState(null);
@@ -252,7 +254,7 @@ const Marketplace = () => {
} catch (err) {
// 409 trust gate — ask for explicit confirmation, then retry.
if (err.status === 409 && err.data?.requires_acknowledgment) {
- setRiskTarget(slug);
+ setRiskTarget({ slug, reason: err.data?.reason || 'unreviewed' });
} else {
toast.error(err.message || 'Registry install failed');
}
@@ -267,14 +269,14 @@ const Marketplace = () => {
} else if (entry.trust === 'unreviewed') {
// Proactive gate: unreviewed registry entries confirm first
// (the backend 409 path above covers the race/stale cases).
- setRiskTarget(entry.installKey);
+ setRiskTarget({ slug: entry.installKey, reason: 'unreviewed' });
} else {
handleRegistryInstall(entry.installKey);
}
};
const confirmRiskyInstall = () => {
- const slug = riskTarget;
+ const slug = riskTarget?.slug;
setRiskTarget(null);
if (slug) handleRegistryInstall(slug, true);
};
@@ -546,7 +548,9 @@ const Marketplace = () => {
<Modal
open
onClose={() => setRiskTarget(null)}
- title="Install unreviewed extension?"
+ title={riskTarget.reason === 'unverified'
+ ? 'Install without checksum verification?'
+ : 'Install unreviewed extension?'}
size="sm"
footer={
<>
@@ -559,8 +563,11 @@ const Marketplace = () => {
>
<div className="extension-risk-dialog">
<p>
- This is a community extension whose exact code has not been
- reviewed by the ServerKit maintainers.
+ {riskTarget.reason === 'unverified'
+ ? 'This extension has no pinned checksum, so the panel '
+ + 'cannot verify the artifact it would download.'
+ : 'This is a community extension whose exact code has not '
+ + 'been reviewed by the ServerKit maintainers.'}
</p>
<p className="text-muted">
It runs with full panel privileges. Only install it if you trust