Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,18 @@ DASHBOARD_PUBLIC_PORTAL="false"
# Only meaningful with a loopback bind (DASHBOARD_HOST=127.0.0.1); the secret is
# the only thing standing between the port and full owner access.
# DASHBOARD_TRUST_PROXY_SECRET=""

# ── Panel image uploads (dashboard) ───────────────────────────────────────────
# Logo and banner can be uploaded in the dashboard (Configuration → Ticket Panel).
# Every image is re-encoded (metadata removed, SVG converted to PNG).
#
# Size limit per upload in MB. Default 5, allowed 1 to 10.
# ASSET_UPLOAD_MAX_MB="5"
#
# Optional virus scan with ClamAV (clamd). Set the local socket, OR host + port.
# When set, an upload is refused if clamd does not answer (fail closed). When
# neither is set, uploads are not virus scanned (logged once at start).
# Debian/Ubuntu: CLAMAV_SOCKET="/var/run/clamav/clamd.ctl"
# CLAMAV_SOCKET=""
# CLAMAV_HOST="127.0.0.1"
# CLAMAV_PORT="3310"
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Auto detect text files and perform LF normalization
* text=auto

# Shell scripts run inside Linux containers: always LF, also in a Windows checkout.
*.sh text eol=lf
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **`npm run update`** runs the same update routine as the dashboard's Update
button, without the dashboard, for self-hosters and for updating many
installations in a loop. It does not restart the bot.
- **Upload the panel logo and banner in the dashboard.** Configuration, section
*Ticket Panel*, has an upload, a preview and **Reset to default** for each
image, so a hosted bot can change them without access to the server's files
(`POST`/`DELETE /api/panel-assets/:slot`, permission `config.edit`, audited
as `panel.asset.upload` and `panel.asset.reset`). PNG, JPEG, GIF, WebP and
SVG are accepted, the type is read from the content. Every image is decoded
and encoded again with sharp, which removes metadata (EXIF, GPS, XMP, ICC)
and anything appended to the file, scales the logo to at most 1024 px and
the banner to at most 2048 px, and turns SVG into PNG. Images over 30
megapixels are refused before decoding. The file is stored in `assets/`
under a generated name and `panel.<slot>.file` in `config.jsonc` is set to
it, comments kept; it takes effect after a restart of the bot.
- **New `.env` keys for uploads.** `ASSET_UPLOAD_MAX_MB` (default 5, 1 to 10)
limits the upload size. `CLAMAV_SOCKET`, or `CLAMAV_HOST` and `CLAMAV_PORT`,
turn on a virus scan with clamd before an image is processed; a flagged file
is refused and audited as `panel.asset.infected`, and an unreachable scanner
refuses the upload. Without them uploads are not virus scanned, which the
dashboard logs once at start.
- New production dependency **sharp** for the image conversion. It installs
from prebuilt binaries on Linux, Windows and macOS, no build tools needed.

### Changed

Expand All @@ -48,6 +68,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- **Docker keeps uploaded images and changed texts.** `docker-compose.yml` mounts
`./assets` and `./locales-custom` (create both and `chown -R 1000:1000` them like
`config` and `data`). The image keeps a copy of the default images and the
entrypoint refreshes `assets/default/` on every start, so the mount does not hide
them; files of your own in `assets/` are never touched.
- Shell scripts are always checked out with LF (`.gitattributes`). On Windows
with `core.autocrlf` the entrypoint got CRLF and a locally built image failed
with `docker-entrypoint.sh: not found`.

- **Security: a panel image path can no longer leave `assets/`.** A value such
as `"../.env"` in `panel.logo.file` or `panel.banner.file` made the panel post
that file, the bot token included, to Discord as an attachment. Anyone with
Expand Down
9 changes: 8 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,15 @@ COPY . .
# and a checkout on Windows arrives as read-only directories (dr-xr-xr-x). The
# image would then run fine when built in CI on Linux and refuse to write its
# config when built on a developer machine.
RUN mkdir -p data config config-defaults \
#
# The same goes for assets/: uploaded panel images live in a mount over
# /app/assets, which hides the shipped default images. A copy of assets/default
# is kept in assets-defaults and refreshed into the mount by the entrypoint.
# locales/custom holds the locale texts changed in the dashboard and is mounted
# on its own, so the shipped locale files stay visible.
RUN mkdir -p data config config-defaults assets/default assets-defaults locales/custom \
&& cp config/*.example.jsonc config-defaults/ \
&& cp -r assets/default/. assets-defaults/ \
&& chmod +x docker-entrypoint.sh \
&& chown -R node:node /app \
&& chmod -R u+rwX /app
Expand Down
7 changes: 6 additions & 1 deletion assets/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Panel images

Put your own panel images here, for example `logo.png` or `banner.png`.
Supported formats: PNG, JPG, GIF, WEBP
Supported formats: PNG, JPG, GIF, WEBP (the dashboard upload also takes SVG and converts it to PNG)

The bot looks for the file named in the config in this folder first and then in
`default/`, which holds the MSK logo. So `"file": "logo.png"` shows the MSK logo
Expand All @@ -23,5 +23,10 @@ Configure them in `config/config.jsonc`:
},
```

Without access to this folder (a hosted bot), upload the images in the web
dashboard under Configuration, section "Ticket Panel". They are stored here as
`custom-logo-<hash>.<ext>` and `custom-banner-<hash>.<ext>`, and the config is
updated for you. Reset to default deletes them again.

The other images in this folder (`msk-ticket-bot-banner.png`, `bot-hosting-*.png`)
belong to the documentation.
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ services:
- ./data:/app/data
# config.jsonc and snippets.jsonc, so the config survives an image update.
- ./config:/app/config
# Panel images uploaded in the dashboard (logo, banner). The shipped
# defaults are copied into assets/default/ on every start.
- ./assets:/app/assets
# Locale texts changed in the dashboard (only the changed values).
- ./locales-custom:/app/locales/custom

# For the web dashboard: uncomment both lines and set DASHBOARD_ENABLED=true
# plus DASHBOARD_HOST=0.0.0.0 in .env. Without the host change the dashboard
Expand Down
16 changes: 16 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,20 @@ if [ ! -w /app/data ]; then
exit 1
fi

# Shipped default panel images. assets/ is usually a mount for uploaded images,
# which hides what the image shipped there. The defaults are copied in on every
# start, so an image update also updates them. Only assets/default/ is written;
# uploaded and customer images elsewhere in assets/ are never touched.
if ! { mkdir -p /app/assets/default && cp -r /app/assets-defaults/. /app/assets/default/; } 2>/dev/null; then
echo "[entrypoint] /app/assets is not writable by uid 1000. Uploaded panel images"
echo "[entrypoint] cannot be stored there. Try: chown -R 1000:1000 assets"
exit 1
fi

if [ ! -w /app/locales/custom ]; then
echo "[entrypoint] /app/locales/custom is not writable by uid 1000. Locale texts"
echo "[entrypoint] changed in the dashboard cannot be saved. Try: chown -R 1000:1000 locales-custom"
exit 1
fi

exec "$@"
4 changes: 4 additions & 0 deletions docs/configuration-de.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ Tokens, der MSK-API-Key, Datenbank-Zugangsdaten und Dashboard-Secrets gehören i

`panel.logo.file` und `panel.banner.file` nennen eine Datei in `assets/`. Dein eigenes Logo oder Banner legst du dort ab, etwa als `assets/logo.png` oder `assets/banner.png`. Liegt die Datei nicht in `assets/`, sucht der Bot in `assets/default/`. Dort liegt das MSK-Logo, `"file": "logo.png"` zeigt also das MSK-Logo, bis du ein eigenes ablegst. Bilder, die du in `assets/` ablegst, ignoriert git, und die Update-Routine legt ein ersetztes `assets/logo.png` beiseite und stellt es danach zurück. Deine Bilder blockieren also kein Update.

Ohne Zugriff auf die Dateien des Servers (ein gehosteter Bot) lädst du Logo oder Banner stattdessen im Dashboard hoch: **Konfiguration**, Abschnitt *Ticket Panel*. Das Dashboard prüft und wandelt das Bild um, legt es unter einem erzeugten Namen wie `custom-logo-3f2a9c1e5b7d4a60.png` in `assets/` ab und trägt diesen Namen in `panel.logo.file` beziehungsweise `panel.banner.file` ein. Aus SVG wird PNG. Das Größenlimit (`ASSET_UPLOAD_MAX_MB`, Vorgabe 5 MB) und der optionale Virenscan mit ClamAV (`CLAMAV_SOCKET` oder `CLAMAV_HOST`/`CLAMAV_PORT`) stehen in der `.env`, siehe [Panel-Bilder im Dashboard](dashboard-de.md#panel-bilder).

Ein Dateiname muss innerhalb von `assets/` bleiben: ein Name wie `../.env` wird ignoriert.

## Texte anpassen

Einen Text des Bots änderst du im Dashboard (Konfiguration, Reiter der Locale-Datei) oder trägst ihn selbst in `locales/custom/<lang>.json` ein. Diese Datei enthält nur die Texte, die du änderst, im selben Aufbau wie `locales/<lang>.json`:
Expand Down
4 changes: 4 additions & 0 deletions docs/configuration-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ Tokens, the MSK API key, database credentials and dashboard secrets go into `.en

`panel.logo.file` and `panel.banner.file` name a file in `assets/`. Put your own logo or banner there, for example `assets/logo.png` or `assets/banner.png`. When the file is not in `assets/`, the bot looks in `assets/default/`, which holds the MSK logo, so `"file": "logo.png"` shows the MSK logo until you add your own. Images you add to `assets/` are ignored by git, and the update routine sets a replaced `assets/logo.png` aside and puts it back, so your images never block an update.

Without access to the server's files (a hosted bot), upload the logo or banner in the dashboard instead: **Configuration**, section *Ticket Panel*. The dashboard checks and converts the image, stores it in `assets/` under a generated name like `custom-logo-3f2a9c1e5b7d4a60.png` and sets `panel.logo.file` or `panel.banner.file` to it. SVG is converted to PNG. The size limit (`ASSET_UPLOAD_MAX_MB`, default 5 MB) and the optional ClamAV virus scan (`CLAMAV_SOCKET` or `CLAMAV_HOST`/`CLAMAV_PORT`) are set in `.env`, see [Panel images in the dashboard](dashboard-en.md#panel-images).

A file name must stay inside `assets/`: a name like `../.env` is ignored.

## Changing texts

Change a bot text in the dashboard (Configuration, tab of the locale file) or write it into `locales/custom/<lang>.json` yourself. That file holds only the texts you change, in the same structure as `locales/<lang>.json`:
Expand Down
62 changes: 61 additions & 1 deletion docs/dashboard-de.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ aktivierst, ändert sich an deinem Bot nichts.
| **Meine Tickets** | Jedes Mitglied sieht die selbst geöffneten Tickets und kann in offenen antworten. Die Antwort erscheint im Discord-Kanal unter dem eigenen Namen. Geschlossene Tickets bieten einen Transcript-Download und, mit Premium, einen "Transcript öffnen"-Link. |
| **Tickets** | Vollständige Liste mit Filtern, Ticket-Detail mit dem Live-Verlauf, Claim / Schließen / Wieder öffnen / Verschieben / Sperren / Priorität. |
| **Statistiken** | Gesamtzahlen, Durchschnittsbewertung, durchschnittliche Bearbeitungszeit und ein Team-Ranking nach geschlossenen Tickets. |
| **Konfiguration** | Bearbeite `config.jsonc`, `snippets.jsonc`, `.env` und die Locale-Dateien wahlweise in einer strukturierten **Formular**-Ansicht oder einer rohen **Datei**-Ansicht (mit Zeilennummern und Syntax-Highlighting). Formular-Änderungen erhalten die `//`-Kommentare, und ein Seitenpanel löst Discord-Rollen-/Kanal-/Kategorie-**Namen** auf, sodass du nie nach rohen IDs suchen musst. Änderungen an einer Locale-Datei landen als Unterschied zu den mitgelieferten Texten in `locales/custom/`, Updates behalten sie also; **Auf Standard zurücksetzen** entfernt sie wieder (siehe [Texte anpassen](configuration-de.md#texte-anpassen)). |
| **Konfiguration** | Bearbeite `config.jsonc`, `snippets.jsonc`, `.env` und die Locale-Dateien wahlweise in einer strukturierten **Formular**-Ansicht oder einer rohen **Datei**-Ansicht (mit Zeilennummern und Syntax-Highlighting). Formular-Änderungen erhalten die `//`-Kommentare, und ein Seitenpanel löst Discord-Rollen-/Kanal-/Kategorie-**Namen** auf, sodass du nie nach rohen IDs suchen musst. Änderungen an einer Locale-Datei landen als Unterschied zu den mitgelieferten Texten in `locales/custom/`, Updates behalten sie also; **Auf Standard zurücksetzen** entfernt sie wieder (siehe [Texte anpassen](configuration-de.md#texte-anpassen)). Logo und Banner des Panels lädst du direkt dort hoch (siehe [Panel-Bilder](#panel-bilder)). |
| **Bot-Steuerung** | Starten, stoppen, neu starten und aktualisieren des Bots, plus eine Live-Konsole. **Update** führt dieselbe Routine aus wie `npm run update` (siehe [Aktualisieren](installation-de.md#aktualisieren)). |
| **Berechtigungen** | Lege fest, welche Rollen und Nutzer das Dashboard verwenden dürfen und was sie tun dürfen. |
| **Dashboard-Einstellungen** | Akzentfarbe und Favicon, abgesichert über eigene Ansehen-/Bearbeiten-Rechte. Die Akzentfarbe wird an die helle und die dunkle Darstellung angepasst. |
Expand Down Expand Up @@ -85,6 +85,63 @@ reduzierte Bewegung, mehr Kontrast und die Windows-Kontrastdesigns.

---

## Panel-Bilder

Unter **Konfiguration**, Abschnitt *Ticket Panel*, haben Logo und Banner je einen
Upload, eine Vorschau des aktuellen Bildes und **Auf Standard zurücksetzen**. So
änderst du sie bei einem gehosteten Bot, bei dem du keinen Zugriff auf die
Dateien des Servers hast. Dafür braucht es das Recht `config.edit`, und jeder
Upload und jedes Zurücksetzen steht im Audit-Log.

Angenommen werden **PNG, JPEG, GIF, WebP und SVG** bis **5 MB** je Datei (siehe
`ASSET_UPLOAD_MAX_MB` unten). Der Typ wird aus dem Inhalt der Datei gelesen,
nicht aus ihrem Namen. Danach wird jedes Bild umgewandelt:

* Es wird dekodiert und als neue Datei gespeichert. Metadaten wie Standort,
Kameradaten oder Kommentare überstehen das nicht, und auch nichts, was hinter
den Bilddaten versteckt ist.
* Das Logo wird auf höchstens 1024 px verkleinert, das Banner auf höchstens
2048 px. Kleinere Bilder behalten ihre Größe.
* PNG bleibt PNG, JPEG bleibt JPEG, WebP bleibt WebP, ein animiertes GIF bleibt
animiert. Ein unbewegtes GIF wird zu PNG.
* **SVG wird immer zu PNG.** Discord kann SVG im Panel nicht anzeigen, und eine
SVG-Datei kann Skripte enthalten. SVGs mit Skripten, Verweisen auf andere
Dateien oder Webadressen oder mit Entity-Deklarationen werden abgelehnt.
* Bilder mit sehr vielen Pixeln (mehr als 30 Megapixel, etwa eine
"Dekompressionsbombe", die als Datei winzig und im Speicher riesig ist) werden
abgelehnt, bevor sie dekodiert werden.

Gespeichert wird das Bild in `assets/` unter einem erzeugten Namen wie
`custom-logo-3f2a9c1e5b7d4a60.png`, und `panel.logo.file` beziehungsweise
`panel.banner.file` in `config.jsonc` wird auf diesen Namen gesetzt, alle
Kommentare bleiben erhalten. Das zuvor hochgeladene Bild desselben Platzes wird
gelöscht; Bilder, die du selbst in `assets/` gelegt hast, und das mitgelieferte
Standardbild bleiben unangetastet. **Auf Standard zurücksetzen** setzt den Namen
zurück auf `logo.png` beziehungsweise `banner.png` und löscht die hochgeladene
Datei. Wie jede andere Änderung an der Konfiguration verwendet das Panel das neue
Bild nach dem nächsten Neustart des Bots.

### Virenscan (optional)

Läuft [ClamAV](https://www.clamav.net/) auf dem Server, kann das Dashboard jeden
Upload von `clamd` prüfen lassen, bevor es ihn verarbeitet. Setze entweder
`CLAMAV_SOCKET` (den Pfad des lokalen Sockets von clamd, unter Debian meist
`/var/run/clamav/clamd.ctl`) oder `CLAMAV_HOST` und `CLAMAV_PORT`. Der Benutzer,
unter dem das Dashboard läuft, muss den Socket benutzen dürfen.

* Eine Datei, die clamd meldet, wird abgelehnt und mit dem Namen des Fundes ins
Audit-Log geschrieben.
* Ist ClamAV eingetragen, antwortet aber nicht (gestoppt, falscher Pfad,
Zeitüberschreitung), werden Uploads **abgelehnt**, bis es wieder antwortet. Ein
eingetragener Scanner lässt nie eine Datei ungeprüft durch.
* Ohne diese Variablen meldet das Dashboard beim Start einmal im Log, dass
Uploads nicht auf Viren geprüft werden. Umgewandelt werden die Bilder trotzdem
wie oben beschrieben.

`StreamMaxLength` von clamd (Vorgabe 25 MB) muss größer sein als das Upload-Limit.

---

## Schnellstart

```bash
Expand Down Expand Up @@ -242,6 +299,9 @@ Ticket ist, bevor irgendetwas Discord erreicht.
| `DASHBOARD_ALLOW_INSECURE` | `false` | Nur, wenn du TLS an einer Stelle terminierst, die der Bot nicht sieht |
| `SESSION_SECRET` | *erzeugt* | Schlüssel für die Cookie-Signatur. Niemals teilen oder wiederverwenden. |
| `CLIENT_SECRET` | (keins) | Discord-OAuth2-Client-Secret |
| `ASSET_UPLOAD_MAX_MB` | `5` | Größenlimit für den Upload eines Panel-Bildes in MB, zwischen 1 und 10 |
| `CLAMAV_SOCKET` | (keiner) | Socket von clamd für den Virenscan der Uploads, z. B. `/var/run/clamav/clamd.ctl` |
| `CLAMAV_HOST` / `CLAMAV_PORT` | (keiner) / `3310` | clamd über TCP statt über einen Socket. Sind beide gesetzt, gilt `CLAMAV_SOCKET`. |

---

Expand Down
Loading
Loading