fix(export): require HTTPS Google endpoint

This commit is contained in:
nyan404 committed 2026-08-25 04:11:52 +03:00
1 parent 1979583550
commit af5c047e27
5 files changed
+15 -2

No files matched your search

+1
View File
@@ -23,6 +23,7 @@
- GitLab CI/CD now builds SHA/latest tags and deploys `deploy/k8s/production.yaml` from `main`. The ignored `.gitlab.variables.env` is a local handoff for GitLab Variables; CI uses namespace-scoped ServiceAccount `belki/gitlab-deploy`, not cluster-admin credentials. - GitLab CI/CD now builds SHA/latest tags and deploys `deploy/k8s/production.yaml` from `main`. The ignored `.gitlab.variables.env` is a local handoff for GitLab Variables; CI uses namespace-scoped ServiceAccount `belki/gitlab-deploy`, not cluster-admin credentials.
- 2026-08-21: applications use a separate store/table from calculator history. `/applications` and VK `/заявка` collect typed data; `/admin` accepts it. The bot can automatically notify only VK submissions, because a web form has no known reply peer. - 2026-08-21: applications use a separate store/table from calculator history. `/applications` and VK `/заявка` collect typed data; `/admin` accepts it. The bot can automatically notify only VK submissions, because a web form has no known reply peer.
- 2026-08-21: Google Sheets export is intentionally disabled by default. Application create/accept events go to a durable outbox and will be delivered through an explicitly configured Apps Script Web App endpoint once the feature flag is enabled. - 2026-08-21: Google Sheets export is intentionally disabled by default. Application create/accept events go to a durable outbox and will be delivered through an explicitly configured Apps Script Web App endpoint once the feature flag is enabled.
- 2026-08-25: Google Sheets export will activate only for a valid HTTPS endpoint; an HTTP/malformed environment URL leaves the outbox untouched and avoids sending its bearer token.
- 2026-08-21: CI final images use immutable registry base images. Any runtime dependency change requires rebuilding/pushing the matching base (`Dockerfile.base` for `requirements.txt`, `Dockerfile.gateway-base` for `nginx.conf`) and changing the tag used by the final Dockerfile. - 2026-08-21: CI final images use immutable registry base images. Any runtime dependency change requires rebuilding/pushing the matching base (`Dockerfile.base` for `requirements.txt`, `Dockerfile.gateway-base` for `nginx.conf`) and changing the tag used by the final Dockerfile.
- 2026-08-21: use Context7 for fresh official integration documentation and `prevent-eol` before dependency changes; lifecycle status is not a vulnerability verdict. - 2026-08-21: use Context7 for fresh official integration documentation and `prevent-eol` before dependency changes; lifecycle status is not a vulnerability verdict.
- 2026-08-21: project-local frontend instructions include `frontend-craft`, `frontend-design`, and `ui-ux-pro-max`; use them together for UI work. - 2026-08-21: project-local frontend instructions include `frontend-craft`, `frontend-design`, and `ui-ux-pro-max`; use them together for UI work.
+3 -1
View File
@@ -6,6 +6,7 @@ import json
import os import os
from dataclasses import dataclass from dataclasses import dataclass
from urllib.error import URLError from urllib.error import URLError
from urllib.parse import urlparse
from urllib.request import Request, urlopen from urllib.request import Request, urlopen
from .applications import ApplicationStore from .applications import ApplicationStore
@@ -29,7 +30,8 @@ class GoogleSheetsExportConfig:
@property @property
def ready(self) -> bool: def ready(self) -> bool:
return self.enabled and bool(self.url) parsed = urlparse(self.url)
return self.enabled and parsed.scheme == "https" and bool(parsed.hostname)
class GoogleSheetsExportService: class GoogleSheetsExportService:
+1 -1
View File
@@ -65,7 +65,7 @@ mindmap
Viewer img.nyan404.ru Viewer img.nyan404.ru
Integrations Integrations
VK API VK API
Optional Google Sheets export Optional Google Sheets export (HTTPS only)
Deployment Deployment
Docker Docker
Immutable Belki base image Immutable Belki base image
+1
View File
@@ -58,6 +58,7 @@
- 2026-08-17: web-selected screenshots are sent through `/api/web/upload` to `BELKI_IMAGE_HOST_API_URL` (production API `https://nyan.nyan404.ru`, viewer `https://img.nyan404.ru`) and persisted as report attachments. The image-host API requires an explicit Belki `User-Agent`; the default Python `urllib` header is rejected with HTTP 403. - 2026-08-17: web-selected screenshots are sent through `/api/web/upload` to `BELKI_IMAGE_HOST_API_URL` (production API `https://nyan.nyan404.ru`, viewer `https://img.nyan404.ru`) and persisted as report attachments. The image-host API requires an explicit Belki `User-Agent`; the default Python `urllib` header is rejected with HTTP 403.
- 2026-08-21: added structured community applications for feathers, kitten, flying-squirrel, and curator roles across VK, `/applications`, and the top-level `/admin` "Заявки" tab; acceptance is a status transition, not a generated forum post. - 2026-08-21: added structured community applications for feathers, kitten, flying-squirrel, and curator roles across VK, `/applications`, and the top-level `/admin` "Заявки" tab; acceptance is a status transition, not a generated forum post.
- 2026-08-21: added a disabled durable Google Sheets export outbox for application-created and application-accepted events; no external request is attempted until an approved Apps Script URL and `BELKI_GOOGLE_EXPORT_ENABLED=1` are configured. - 2026-08-21: added a disabled durable Google Sheets export outbox for application-created and application-accepted events; no external request is attempted until an approved Apps Script URL and `BELKI_GOOGLE_EXPORT_ENABLED=1` are configured.
- 2026-08-25: the optional Google Sheets export considers a configured endpoint ready only when it is a valid HTTPS URL, preventing its optional bearer token from crossing plaintext HTTP.
- 2026-08-25: fixed separator-free bulk parsing around time ranges, scoped web quick input to coaching, changed web inspection resources to `+N name`, corrected Russian inspection-count grammar, enabled VK image mirroring fallback, and added the standalone goal calculator mode/API. - 2026-08-25: fixed separator-free bulk parsing around time ranges, scoped web quick input to coaching, changed web inspection resources to `+N name`, corrected Russian inspection-count grammar, enabled VK image mirroring fallback, and added the standalone goal calculator mode/API.
- 2026-08-25: added the goal calculator to the VK menu as `/цель` and `/калькулятор`; the bot now runs the same goal calculation interactively with step prompts, choice buttons, and confirmation without report attachments. - 2026-08-25: added the goal calculator to the VK menu as `/цель` and `/калькулятор`; the bot now runs the same goal calculation interactively with step prompts, choice buttons, and confirmation without report attachments.
- 2026-08-25: hardened the public goal calculator: point values must be finite, one session is limited to 1–1440 minutes, and one calculation to 1–50 kittens. The same validation is applied by the domain, JSON API, and VK dialogue, with regression tests for `NaN`, infinity, and excessive values. - 2026-08-25: hardened the public goal calculator: point values must be finite, one session is limited to 1–1440 minutes, and one calculation to 1–50 kittens. The same validation is applied by the domain, JSON API, and VK dialogue, with regression tests for `NaN`, infinity, and excessive values.
+9
View File
@@ -93,6 +93,15 @@ class ApplicationTests(unittest.TestCase):
self.assertEqual(exporter.sync_pending(), 0) self.assertEqual(exporter.sync_pending(), 0)
self.assertEqual(len(store.pending_exports()), 2) self.assertEqual(len(store.pending_exports()), 2)
def test_google_export_refuses_an_insecure_endpoint_even_when_enabled(self) -> None:
with tempfile.TemporaryDirectory() as directory:
store = ApplicationStore(sqlite_path=Path(directory) / "applications.sqlite3")
exporter = GoogleSheetsExportService(
store, GoogleSheetsExportConfig(enabled=True, url="http://example.test/export", token="secret"),
)
self.assertFalse(exporter.config.ready)
self.assertEqual(exporter.sync_pending(), 0)
def test_vk_kitten_application_uses_profile_and_saves(self) -> None: def test_vk_kitten_application_uses_profile_and_saves(self) -> None:
with tempfile.TemporaryDirectory() as directory: with tempfile.TemporaryDirectory() as directory:
store = ApplicationStore(sqlite_path=Path(directory) / "applications.sqlite3") store = ApplicationStore(sqlite_path=Path(directory) / "applications.sqlite3")