Harden entry safety, unify runtime config, bound document unpacking
Shared-IP safety: entry autoban and entry notifications default off, and a shared IP is treated as review evidence only. ban_user/ban_cluster refuse reason=entry_ip_collision (also with the legacy flag set to 1), so token status and quota are never touched; explicit admin moderation still works. Reproducible startup: new bot/runtime_config.py and scripts/run.py load the repository .env (or --env-file) without shell interpolation, normalize config/DB/upstream aliases, and make the bot, Mini App, gateway, econ cap, account admin, mk_daemon, entry admin and key notifications resolve the same paths. "run.py <target> --check" is an offline preflight that starts nothing and reports placeholders, missing upstream DB and invalid data directories. Resource limits: aggregate Office decompression, a 400 read-entry cap and a per-row XLSX cell budget stop early; truncated or corrupt archives are reported instead of raising. Deploy and docs: only source-backed systemd units remain, and deploy/runtime.env.example documents the environment contract including the 0600 session-secret file rules. Removed the destructive "cp bot/iishko_bot.py bot/grok_bot.py" instruction, the unused generated site/ snapshot and the unsupported iishko-ts staging unit; corrected .env.example, README, ARCHITECTURE, SECURITY, docs/native-gateway.md and iishko-ts/README.md. Tests: entry safety, runtime bootstrap, economy paths, file intake, deploy contract, abilities_guard CLI, and a startup smoke that launches all three components through scripts/run.py with non-loopback network blocked. Every config reader, selfcheck included, accepts a UTF-8 BOM. Verified on this tree: pytest 716 passed + 322 subtests, node --test 73/73, go test and go vet clean, selfcheck --source-only ok, gitleaks worktree and history 0 findings. No production or live-split changes are included.
This commit is contained in:
@@ -1,14 +1,23 @@
|
||||
[Unit]
|
||||
Description=Grok Telegram Bot
|
||||
After=network-online.target new-api.service
|
||||
Description=IISHKO Telegram bot (long polling)
|
||||
Documentation=file:/opt/iishko/deploy/README.md
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
# The upstream gateway (New API / one-api) is an external service and has no unit
|
||||
# in this repo. If it runs on this host, add its unit name to After= below.
|
||||
|
||||
[Service]
|
||||
EnvironmentFile=/opt/grok-bot/.env
|
||||
WorkingDirectory=/opt/grok-bot
|
||||
ExecStart=/opt/venv/bin/python /opt/grok-bot/iishko_bot.py
|
||||
Type=simple
|
||||
User=root
|
||||
WorkingDirectory=/opt/iishko
|
||||
# scripts/run.py loads /etc/iishko/runtime.env (real environment wins), adds the
|
||||
# repo directories to sys.path and starts bot/grok_bot.py.
|
||||
# The file is required: without it the unit fails fast instead of starting half-configured.
|
||||
ExecStart=/opt/iishko/.venv/bin/python /opt/iishko/scripts/run.py bot --env-file /etc/iishko/runtime.env
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
NoNewPrivileges=true
|
||||
PrivateTmp=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,13 +1,22 @@
|
||||
[Unit]
|
||||
Description=IISHKO gateway web skin
|
||||
After=network-online.target new-api.service
|
||||
Description=IISHKO gateway skin (loopback 127.0.0.1:48001)
|
||||
Documentation=file:/opt/iishko/deploy/README.md
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
# Upstream gateway is external, see the note in grok-bot.service.
|
||||
|
||||
[Service]
|
||||
EnvironmentFile=/opt/grok-bot/.env
|
||||
Type=simple
|
||||
User=root
|
||||
WorkingDirectory=/opt/iishko
|
||||
# gateway target runs gateway/grok-web-skin.py; sys.path needs gateway/ and bot/
|
||||
# (the skin imports bot modules), which scripts/run.py sets up.
|
||||
ExecStart=/opt/iishko/.venv/bin/python /opt/iishko/scripts/run.py gateway --env-file /etc/iishko/runtime.env
|
||||
TimeoutStopSec=30
|
||||
ExecStart=/opt/venv/bin/python /opt/grok-web-skin.py
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
NoNewPrivileges=true
|
||||
PrivateTmp=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,13 +1,17 @@
|
||||
[Unit]
|
||||
Description=IISHKO moderation policy (loopback only, no Telegram poller)
|
||||
After=network.target
|
||||
Documentation=file:/opt/iishko/deploy/README.md
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=root
|
||||
WorkingDirectory=/opt/grok-bot
|
||||
EnvironmentFile=/etc/iishko/moderation.env
|
||||
ExecStart=/opt/grok-bot/bin/iishko-moderation -addr 127.0.0.1:48003
|
||||
WorkingDirectory=/opt/iishko
|
||||
# Native EnvironmentFile: the Go binary is not started through scripts/run.py.
|
||||
# IISHKO_MODERATION_TOKEN is required (see deploy/runtime.env.example).
|
||||
EnvironmentFile=/etc/iishko/runtime.env
|
||||
ExecStart=/opt/iishko/bin/iishko-moderation -addr 127.0.0.1:48003
|
||||
Restart=on-failure
|
||||
RestartSec=3
|
||||
TimeoutStopSec=15
|
||||
@@ -15,6 +19,8 @@ NoNewPrivileges=true
|
||||
PrivateTmp=true
|
||||
ProtectSystem=strict
|
||||
ProtectHome=true
|
||||
# Runtime state is written under /opt/iishko/var (DBs, logs).
|
||||
ReadWritePaths=/opt/iishko/var
|
||||
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
|
||||
CapabilityBoundingSet=
|
||||
MemoryMax=128M
|
||||
@@ -22,4 +28,4 @@ TasksMax=32
|
||||
UMask=0077
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,13 +1,20 @@
|
||||
[Unit]
|
||||
Description=iishko webapp (Mini App backend)
|
||||
After=network.target
|
||||
Description=IISHKO Mini App backend (loopback 127.0.0.1:8850)
|
||||
Documentation=file:/opt/iishko/deploy/README.md
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
EnvironmentFile=/opt/grok-bot/.env
|
||||
ExecStart=/opt/venv/bin/python /opt/grok-bot/webapp/server.py
|
||||
WorkingDirectory=/opt/grok-bot/webapp
|
||||
Type=simple
|
||||
User=root
|
||||
WorkingDirectory=/opt/iishko
|
||||
# miniapp target runs bot/webapp/server.py; listen address comes from runtime.env
|
||||
# (IISHKO_WEBAPP_HOST / IISHKO_WEBAPP_PORT).
|
||||
ExecStart=/opt/iishko/.venv/bin/python /opt/iishko/scripts/run.py miniapp --env-file /etc/iishko/runtime.env
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
NoNewPrivileges=true
|
||||
PrivateTmp=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
WantedBy=multi-user.target
|
||||
Reference in New Issue
Block a user