Commit Graph

341 Commits

Author SHA1 Message Date
Catherine
f59830ae20 Rename PATCH Race-Free: header to Atomic:.
Neither of these names is self-explanatory, and it is better to have
fewer distinct identifiers for the same concept.
2025-12-04 16:51:32 +00:00
Catherine
1c017020c1 Update -audit-log to fetch records in parallel.
This makes it *much* faster.
2025-12-04 16:45:29 +00:00
Catherine
e730b2bcd2 Fix phrasing in README. 2025-12-04 16:18:31 +00:00
Catherine
886635ce5e Implement -audit-log option.
Also, record the principal of `git-pages -{freeze,unfreeze}-domain`
and `git-pages -update-site` as the CLI administrator.
2025-12-04 15:58:14 +00:00
Catherine
4161013fc0 Implement -audit-read option. 2025-12-04 15:25:28 +00:00
Catherine
8f0712b3ad Improve error handling in CollectTar. 2025-12-04 15:23:15 +00:00
Catherine
2ebf4400bf Update introduction in README. 2025-12-04 13:52:37 +00:00
Catherine
1ad5d5590c Optionally include principal's IP address in audit record metadata.
Currently this doesn't handle `X-Forwarded-For` and as such isn't very
useful. It is surprisingly difficult to find a high-quality library for
parsing `X-Forwarded-For` and a solution will have to be found.
2025-12-04 06:17:11 +00:00
Catherine
75489f563e Fix issues with locking on Windows. 2025-12-04 05:09:28 +00:00
Catherine
d5360817f3 Simplify fetch logging. NFC 2025-12-04 03:52:03 +00:00
Catherine
e8c9cf588c Drop the shared manifest lock in the FS backend.
On Linux and macOS, two file descriptors opened by the same process are
treated as if they were different processes for the purpose of locking.
2025-12-04 03:00:47 +00:00
Catherine
f5c48d0759 Use ETag as precondition for partial updates.
Last-Modified does not have enough resolution to be fully reliable;
ETag does. This test now passes on both filesystem and MinIO:

    $ go run ./test/stresspatch -count 100
    ...
    written: 100 of 100

Other S3 implementations haven't been tested.
2025-12-04 03:00:47 +00:00
Catherine
92d6796ad9 Return both LastModified and ETag in manifest metadata. NFCI 2025-12-04 03:00:47 +00:00
Catherine
460ff41cc9 Allow PATCH method to apply partial updates.
Gated behind the `patch` feature.
2025-12-04 03:00:47 +00:00
Catherine
be75cc82a4 Factor out functions to create and fill a manifest. NFCI 2025-12-03 19:36:15 +00:00
Catherine
e99fade242 Make .gz/.zst extraction composable. NFCI 2025-12-03 17:30:55 +00:00
Catherine
21b82f8e2c [breaking-change] Implement audit record retrieval.
This is only a breaking change if you've enabled the `audit` feature.
All past audit reports should be removed once this commit is deployed,
as both the Protobuf schema and the Snowflake epoch have changed.
2025-12-03 16:43:33 +00:00
Catherine
6e7b42b942 Implement audit notifications. 2025-12-03 06:32:07 +00:00
Catherine
5b8267ace5 Parse URLs while loading configuration. NFCI
This avoids spreading URL parse error handling code all over
the codebase. It's not even easy to trigger that error!
2025-12-03 06:10:51 +00:00
Catherine
955af0d589 Add missing setConfigValue() branch.
This caused a crash when setting `PAGES_AUDIT_NODE_ID` or using
`-print-config-env-vars`.
2025-12-03 06:03:53 +00:00
Catherine
95c4f1041d Fix S3 implementation of frozen domain check. 2025-12-03 04:52:41 +00:00
Catherine
e226f51dd4 Implement auditing of important site lifecycle actions.
The list of audit events is:
  - `CommitManifest`
  - `DeleteManifest`
  - `FreezeDomain`
  - `UnfreezeDomain`

Currently these are the main abuse/moderation-relevant actions.
If collection is enabled, these events will be logged to `audit/...`
storage hierarchy; a way to examine audit logs will be added in
the future.

The auditing interposer backend is enabled with feature `audit`.
2025-12-03 04:19:41 +00:00
Catherine
dcf70dfdda Trim trailing \n from log messages. 2025-12-03 01:33:08 +00:00
Catherine
cc5f8f608e Consistently use context in Main().
Without this, some of the slog lines end in `\n` and some do not, which
I find deeply irritating.
2025-12-03 01:32:54 +00:00
Catherine
baae1e6560 Simplify. NFCI
Co-authored-by: David Leadbeater <dgl@dgl.cx>
2025-12-03 01:08:49 +00:00
Catherine
6faf3b1ee3 Reformat. NFC 2025-12-03 01:07:26 +00:00
Catherine
f089208ca7 [breaking-change] Make fallback handler per-instance, not per-wildcard.
There was never a particularly good reason to tie the fallback handler
to a wildcard domain; most importantly, this prevented it from being
used for custom domains, which is required for migrating custom domains
from Codeberg Pages v2 server.
2025-12-03 00:39:07 +00:00
Catherine
c250922f8d Allow domains to be administratively frozen.
The following script may be used to handle abusive sites:

    cd $(mktemp -d)
    echo "<h1>Gone</h1>" >index.html
    echo "/* /index.html 410" >_redirects
    tar cf site.tar index.html _redirects
    git-pages -update-site $1 site.tar
    git-pages -freeze-domain $1
2025-12-02 23:56:01 +00:00
Catherine
32111307eb Add "dry run" capability for all destructive endpoints. 2025-12-02 22:32:17 +00:00
Catherine
89c57cfadb Use git filters for incremental updates from a git repository.
This commit changes the git fetch algorithm to only retrieve blobs
that aren't included in the previously deployed site manifest, if
git filters are supported by the remote.

It also changes how manifest entry sizes are represented, such that
both decompressed and compressed sizes are stored. This enables
computing accurate (and repeatable) sizes even after incremental
updates.

Co-authored-by: David Leadbeater <dgl@dgl.cx>
2025-12-02 22:23:43 +00:00
Catherine
af40848d9f Explicitly mention SHA-256 transition status. 2025-12-02 22:23:43 +00:00
Catherine
689030c28a Add a Prometheus metric for blob/request encoding pairs.
Forcing the server to repeatedly decompress a large blob is a potential
DoS vector, so having a metric for this is essential.
2025-12-01 11:04:50 +00:00
Catherine
30bde8c1c4 Rename blob transforms to match HTTP encoding names. 2025-12-01 11:04:50 +00:00
woodpecker-bot
e1a2143d22 fix(deps): update all dependencies 2025-11-29 00:39:09 +00:00
Catherine
0b82dcbc25 Replace s3GetObjectErrorsCount metric with *ResponseCount.
The former metric was misnamed: it only counted NoSuchKey errors.
Also, it was applied *after* the cache, meaning it was just a count
of every request that got a successful 404 from the S3 backend.
Also, it pooled blob and manifest requests together.

The new metric is 1-to-1 correspondent to S3 requests and distinguishes
between different kinds of errors. Also, it distinguishes kinds of
requests. Example output:

    git_pages_s3_get_object_responses_count{code="NoSuchKey",kind="manifest"} 1
    git_pages_s3_get_object_responses_count{code="OK",kind="blob"} 1
    git_pages_s3_get_object_responses_count{code="OK",kind="manifest"} 1
2025-11-29 00:04:50 +00:00
Catherine
f9669e1c69 Update sentry-go.
Related to 4cca8abaf0.

They've fixed it in https://github.com/getsentry/sentry-go/issues/1142
2025-11-26 03:18:47 +00:00
Catherine
4cca8abaf0 Make Sentry telemetry buffer configurable.
Via `sentry-telemetry-buffer` feature.

I think this causes high CPU use on Grebedoc.
2025-11-23 03:04:25 +00:00
Catherine
d82ae69625 Simplify SIGINT handling code. NFC 2025-11-23 03:03:33 +00:00
Catherine
fa02595f8b Handle OPTIONS method. 2025-11-23 00:14:39 +00:00
Catherine
80d2a7a792 Rename license to satisfy https://pkg.go.dev 2025-11-22 23:32:18 +00:00
Catherine
988da5243e Fix nix flake. 2025-11-22 23:21:00 +00:00
miyuko
eda6d8b6f6 Update the go-slog-syslog dependency. 2025-11-22 14:43:38 +00:00
miyuko
fcc109c315 Add the ability to send logs to a syslog daemon. 2025-11-22 14:10:26 +00:00
woodpecker-bot
4d8f6d5e9d fix(deps): update module github.com/go-git/go-git/v6 to v6.0.0-20251121083746-39fcec474970 2025-11-22 09:35:57 +00:00
miyuko
cb7802df10 Pass the context to logging functions. 2025-11-22 07:05:07 +00:00
miyuko
b01e67f993 Exit gracefully (run deferred statements in main()) on SIGINT. 2025-11-21 23:34:33 +00:00
David Leadbeater
b5a1626a10 Fix content-type detection for small files
Previously a <512 byte file without an extension resulted in:

internal server error: runtime error: slice bounds out of range [:512] with capacity 8
2025-11-21 05:55:50 +01:00
Catherine
b1b8ae26e8 Restrict DNS Allowlist authorization to index site only.
Otherwise, an undesired degree of freedom permits a third party to
deny access to index site URLs by publishing projects with the same
name.

In the future, the _git-pages-repository TXT record format may be
extended to allow non-index sites to be specified without introducing
undesired degrees of freedom.
2025-11-21 03:49:38 +00:00
woodpecker-bot
eac02e5758 fix(deps): update all dependencies 2025-11-21 00:31:03 +00:00
Catherine
7e1185309b Fix a regression causing non-observance of ≠200 S3 manifest responses.
Introduced in commit dd168186.
2025-11-20 07:06:14 +00:00