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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ version may change things that need attention when updating, and these notes say
itself is never shown. A PDF in the bin is not searched until it is restored. PDFs added before this version have no
text; upload them again to make them searchable.
- The item page shows a PDF as its pages, one under the other, each with "Page 3 of 20".
- Recordings can be uploaded by curators (not through contribution links): MP3, M4A (the voice recorders of phones), WAV and
FLAC. Visitors hear a copy in the item page's own player, which can jump about. Names, places, dates, cover pictures
and everything else the file carries in tags are cut out of that copy; the sound itself is not re-encoded. The original
stays with curators. A file whose structure the archive cannot follow is refused rather than served. OGG/Opus is not
accepted yet. Recordings are not yet searched or transcribed.

### For people running an archive

Expand Down
12 changes: 12 additions & 0 deletions docs/curator-handbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ needs to be entered for that.

Visitors can open a photo at about 3000 pixels. Whether they can is a setting for the whole archive, under "Settings".

## Recordings

A recording (MP3, M4A from a phone's voice recorder, WAV or FLAC) is added like a photo, on the item's page, by a curator or helper;
not through a contribution link. Visitors hear it with the player on the item page once the item is published. They get a copy
that has everything cut out that the file carries besides the sound: names, places, dates, the device and cover pictures. The
sound itself is exactly the original's. The original stays with curators ("Original" on the card). If the archive cannot make
sense of a file, it says "No preview could be created" and offers nothing to visitors: try saving it again from the recorder
or converting it to MP3 or WAV. OGG and Opus are not accepted yet.

A recording cannot be searched. Write down in the description what is said, or at least who and where, and tick "Still needs a
transcription" until there is a transcript.

## Rights, credit and what only you see

Open **Rights and credit** on an item:
Expand Down
5 changes: 5 additions & 0 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ Originals and their previews are stored under `Storage:RootPath`. It defaults to
`Media/MediaEndpoints.cs`, which checks permissions. The per-file limit is
`Uploads:MaxFileSizeMegabytes` (default 200).

Recordings (`Media/AudioTools.cs`) have no pictures: `MediaProcessor` writes a copy without tags under `audio/{StorageId}` by
cutting tags out of the file's structure and copying the sound unchanged (no ffmpeg, which would add about 400 MB to the image).
Only that copy is served to visitors, from `/media/{id}/audio` with range requests. Every query that picks a cover skips
`audio/*` files.

Previews are generated in the background with [NetVips](https://github.com/kleisauke/net-vips)
(libvips). They are rotated upright and contain no EXIF, so GPS coordinates stay in the private
original. `MediaProcessor` works through them one at a time. Nothing a single file does may leave its loop, because an
Expand Down
12 changes: 12 additions & 0 deletions docs/handbuch-kuratoren.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ Besucher sehen auf der Seite und der Karte einer Sammlung, aus welchen Jahren ih

Besucher können ein Foto mit etwa 3000 Pixeln öffnen. Ob das möglich ist, gilt für das ganze Archiv und steht unter „Einstellungen“.

## Aufnahmen

Eine Aufnahme (MP3, M4A vom Diktiergerät des Telefons, WAV oder FLAC) fügen Kuratoren und Helfer auf der Seite des Eintrags hinzu wie ein
Foto, nicht über einen Einsendelink. Besucher hören sie im Player auf der Seite des Eintrags, sobald er veröffentlicht ist. Sie bekommen
eine Kopie, aus der alles entfernt ist, was die Datei außer dem Ton enthält: Namen, Orte, Daten, das Gerät und Titelbilder. Der Ton selbst
ist genau der des Originals. Das Original bleibt bei den Kuratoren („Original“ auf der Karte). Kann das Archiv mit einer Datei nichts
anfangen, steht dort „Es konnte keine Vorschau erstellt werden“, und Besucher bekommen nichts: speichern Sie sie noch einmal aus dem
Aufnahmegerät oder wandeln Sie sie in MP3 oder WAV um. OGG und Opus werden noch nicht angenommen.

Eine Aufnahme lässt sich nicht durchsuchen. Schreiben Sie in die Beschreibung, was gesagt wird, oder wenigstens wer und wo, und setzen Sie
den Haken bei „Muss noch abgeschrieben werden“, bis es eine Abschrift gibt.

## Rechte, Nennung und was nur Sie sehen

Öffnen Sie bei einem Eintrag **Rechte und Nennung**:
Expand Down
364 changes: 363 additions & 1 deletion docs/roadmap.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ vulnerability, see [SECURITY.md](../SECURITY.md).
| Staff names and last login | `StaffProfiles` holds an optional display name and the time of the last login per account, written after a successful login (password, authenticator code or recovery code). Read only on the admin-only Accounts pages, never on a public page, feed or link preview, and not in the export or the activity log (which keeps the email address). Changing a name is logged. The row goes with the account (cascade). `AccountTests`. |
| Helpers | The `Helper` role (policy `Describe`) reaches only the item list, the item form, "Add many photos", the preview and the generated pictures under `/admin/media` (not the original). Everything else under `/Admin` needs `ManageArchive` (curator or admin) or `Administer`. A helper only gets draft items, in the list, the form, the preview and the pictures, never published, submitted, rejected or withdrawn ones: what visitors see changes only through a curator, and no contribution or contributor name or email reaches a helper (the contribution is not even loaded). The start page counts, the "already in the archive" file check and the reference-number check show a helper drafts only. Publishing, unpublishing, accepting, rejecting, deleting, withdrawing and removing a photo are refused with 403 on the server, not only hidden. Accepted: a helper can read "received from" and the internal notes of the items they open; the handbook says so. `HelperTests` (including a test that lists every `/Admin` address a helper can reach), `AccountTests`. |
| Import | Only curators (the `/Admin` policy). The sheet and ZIP are kept in `import-staging` on the media volume, which is never served by path, for a day at most. A sheet is read as strict UTF-8, at most 20 MB and 100,000 rows; a ZIP at most 4 GB and 200,000 entries; every entry is counted as it is unpacked into a temporary file, and a name inside it is never used in a path. A folder to import from is chosen from a listing of `import/`, links and hidden files are skipped. Files go through the same checks as an upload. One import at a time. Everything imported is a draft; the activity log records each item and the import, never the spreadsheet or the contributors' details. `ImportTests`. |
| Recordings | Only curators can add a recording (MP3, M4A, WAV, FLAC, recognised by their first bytes); contribution links refuse them. Visitors hear only a copy made by the app itself (`AudioTools`, no outside program): the sound is copied byte for byte, and ID3v2/ID3v1/APE tags (MP3), `udta`, `meta`, `uuid` and padding boxes and the dates in the headers (M4A), every chunk except `fmt `, `fact` and `data` (WAV), and every block except stream info and the seek table (FLAC) are left out. A file that is not built as its type says (impossible sizes, missing parts, fragmented M4A) fails and has no copy, so nothing is ever served untouched. The parser is managed code reading sizes against the file's length, with the header of an M4A limited to 64 MB; it runs on the single preview queue and a failure marks only that file. Served for published items only, from `/media/{id}/audio` with range requests, with its own copy (`audio/…` key); the original is only at `/admin/media/{id}/original` for curators. Accepted: the sound itself may contain a voice that identifies someone, which is what an oral history is; curators decide what to publish. `AudioTests`. |
| PDF files | Only curators can add a PDF; contribution links refuse it. A PDF is recognised by `%PDF-` and read by poppler (`pdfinfo`, `pdftoppm`), a large C++ parser, so it runs as separate processes, never inside the app: each call has a time limit (`Uploads:PdfTimeoutSeconds`, 60) and is killed with its children when it takes longer, the size of the drawn picture is set by us with `-scale-to` whatever size the page claims, at most 300 pages are drawn, and no part of the file or its name reaches a command line (arguments are passed as a list, the file is copied to a random name in an owner-only temporary folder that is removed afterwards). Pages are served only for published items; the PDF stays private. Accepted: a hostile PDF made by a curator could still exploit poppler, which runs with the app's rights in the container; build with `WITH_PDF=false` to remove it. `poppler-utils` comes from the distribution at build time and is not pinned to a version, so a rebuild of the same commit can ship another poppler (accepted; the base image digest is pinned). The text of a PDF (`pdftotext`, same limits, control characters removed, at most 200,000 characters) is only matched by search, never shown, and it is in the index only while the item is not in the bin and the PDF is not in the bin; a draft is found only by curators, as before. The preview queue is single, so a very long PDF delays other previews (at most 60 s per page); copies of a PDF left by a stopped app are removed at the next start. |
| Uploads | Files are recognised by their content (magic bytes), never by name or browser type, and stored under random names outside the web root. Originals are never changed or served to visitors. Previews are made by libvips, rotated upright and stripped of all metadata. Images over 250 megapixels get no preview (decompression bombs), also for GIF and AVIF (`Images_with_more_pixels_than_the_limit_get_no_preview`). GIF and AVIF (libheif with an AV1 decoder, from M23) are further decoders reachable from a contribution link; a GIF is read as its first frame only. There is no time limit on a decode, so a very large AVIF costs memory and time on a small server; the pixel limit and the three-attempt guard are the protection. Size limits per file and per request. A file that the preview maker fails on, in whatever way, costs only its own preview, and one that takes the app down is given up after three attempts instead of at every start (`PreviewFailureTests`). |
| Browser | Strict Content Security Policy (no inline script or style, no framing, no plugins; only the contribution form may show `blob:` images, for the photos someone has chosen on their own device, and a picture opened on its own has no scripts at all but lets the browser's picture view style itself), `nosniff`, `Referrer-Policy: same-origin` (setup links never leak to other sites), `X-Frame-Options`, `Permissions-Policy`, `Cross-Origin-Opener-Policy`. No `Server` header. `SecurityHeaderTests` checks the headers and that no page contains inline script or style, so the policy can stay strict. |
Expand Down
7 changes: 6 additions & 1 deletion src/Commonage.Web/Domain/MediaFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public class MediaFile

public bool IsPdf => ContentType == PdfContentType;

/// <summary>A recording. It has no pictures; visitors hear a copy without tags, and the original stays with curators.</summary>
public bool IsAudio => ContentType.StartsWith("audio/", StringComparison.Ordinal);

/// <summary>The text read from a PDF, for search only. Never shown. Null for pictures and for PDFs without text.</summary>
public string? ExtractedText { get; set; }

Expand Down Expand Up @@ -87,6 +90,8 @@ public class MediaFile
public DateTime? DeletedAt { get; set; }

public string OriginalKey => $"originals/{StorageId:N}";
/// <summary>The copy of a recording without its tags, the only one visitors can reach.</summary>
public string AudioKey => $"audio/{StorageId:N}";
public string PreviewKey => $"previews/{StorageId:N}.jpg";
public string ThumbnailKey => $"thumbnails/{StorageId:N}.jpg";
public string CardKey => $"cards/{StorageId:N}.jpg";
Expand All @@ -100,7 +105,7 @@ public class MediaFile

/// <summary>Everything made from the original: the sizes of the picture and the pages of a PDF.</summary>
public IEnumerable<string> DerivativeKeys() =>
new[] { PreviewKey, ThumbnailKey, CardKey, LargeKey }.Concat(Enumerable.Range(1, PageCount ?? 0).Select(PageKey));
IsAudio ? [AudioKey] : new[] { PreviewKey, ThumbnailKey, CardKey, LargeKey }.Concat(Enumerable.Range(1, PageCount ?? 0).Select(PageKey));

/// <summary>Which picture sizes exist. Raising it makes the archive add the new ones in the background.</summary>
public const int CurrentDerivativeVersion = 3;
Expand Down
Loading
Loading