Commit Graph
583 Commits
Author SHA1 Message Date
Xavier VelloandCatherine d833deabf3 Support notifying an audit-server over unix socket (#266)
The audit-server is able to listen on a unix socket, but the client does not support http on unix socket. It's pretty simple to implement in golang, by overriding the socket dialer in a http client.

We could also depend on https://github.com/peterbourgon/unixtransport for a better-tested implementation, but I don't think it's worth the maintenance cost.

Reviewed-on: https://codeberg.org/git-pages/git-pages/pulls/266
Reviewed-by: Catherine <whitequark@whitequark.org>
2026-10-07 22:42:15 +02:00
Catherine 762ff0ae65 FS: Skip temporary files in Enumerate{Blobs,Manifests}. 2026-10-07 20:10:24 +00:00
Catherine 01904858a1 Use less confusing temporary file names.
While dealing with an unrelated incident I got extremely confused by
what appeared to be sha256 names with 74 characters in them. This was
never intentional, a refactoring of how temporary files are created has
created a call site with this format.
2026-10-07 20:04:38 +00:00
Catherine a8c7bbb316 Add -repair-storage command.
This command replaces corrupted manifests and audit records with
placeholders indicating the corrupt status of the object in question.
As a result, other operations (many of which require that all objects
can be parsed) continue to work as expected.

The contents of a corrupted site manifest is replaced with a human
readable index page explaining the situation, and every URL is
rewritten to point to that index page.
2026-10-05 00:27:29 +00:00
Catherine e52dc6ed86 Include manifest name in protobuf decode errors. 2026-10-04 22:27:27 +00:00
miyuko 6c2f34c54d Allow specifying a reason for a mutation done via the CLI.
The reason is appended to the audit record and is surfaced in the log.
2026-09-20 10:12:15 +01:00
miyuko 6743cd73e9 Add protocol buffer development tools to the Nix devshell.
To lock the generated output.
2026-09-20 09:51:27 +01:00
phanirithvij 507e57edbc feat: use os.MkdirAll for creating root directory
Signed-off-by: phanirithvij <phanirithvij2000@gmail.com>
2026-09-04 02:16:16 +05:30
miyuko 0176494816 Treat wildcard domains and preview domains as public suffixes. 2026-08-27 02:11:48 +01:00
Catherine cb72f200c2 Revert "CI: pin Go toolchain version to 1.25.x."
This reverts commit 55d7851285.
2026-08-26 16:58:23 +00:00
Catherine d525cb61fc Add -purge-domain command (like wildcard -delete-site). 2026-08-26 16:56:27 +00:00
Catherine 255f91dd32 Harmonize log messages for admin commands. 2026-08-26 16:56:07 +00:00
8463eed5ba Retain query params for automatic redirects to .../.
Co-authored-by: phanirithvij <phanirithvij2000@gmail.com>
Reviewed-on: https://codeberg.org/git-pages/git-pages/pulls/253
Reviewed-by: Catherine <whitequark@whitequark.org>
2026-08-20 14:20:21 +02:00
whitequark 55d7851285 CI: pin Go toolchain version to 1.25.x.
Newer Go toolchain is incompatible with `staticcheck`.
2026-08-20 14:16:14 +02:00
woodpecker-bot 6b3706ff17 [Renovate] Update module github.com/go-git/go-git/v6 to v6.0.0-alpha.5 [SECURITY] 2026-08-09 00:07:11 +00:00
Psy-QandCatherine 472ae7ecaf README: accommodate installation from Docker/binary/etc
Reviewed-on: https://codeberg.org/git-pages/git-pages/pulls/250
Reviewed-by: Catherine <whitequark@whitequark.org>
2026-07-30 17:46:53 +02:00
miyukoandCatherine e02c8dd138 Group domains belonging to the same owner when analyzing storage.
Resolves: https://codeberg.org/git-pages/git-pages/issues/239
2026-07-28 01:53:12 +02:00
miyukoandCatherine 3332df668b Improve command-line help for -analyze-storage. 2026-07-28 01:53:12 +02:00
miyukoandCatherine 899e62a75d Add repository as a principal when updating via webhook.
Resolves: https://codeberg.org/git-pages/git-pages/issues/234
2026-07-28 01:47:08 +02:00
miyukoandCatherine f31d55c9ef Fold case of pull request author's username for preview uploads.
Hostnames are lowercase ASCII, so preview upload authorization would
always fail for repositories whose owners have uppercase letters in
their usernames.

Resolves: https://codeberg.org/git-pages/git-pages/issues/228
2026-07-28 01:44:20 +02:00
miyuko 2f810ec65b Fix type of [[wildcard]].max-preview-lifetime in the example config. 2026-07-27 17:24:48 +01:00
miyuko 6c1882911a Expose X-Server when responding to mutating requests.
Resolves: https://codeberg.org/git-pages/git-pages/issues/209
2026-07-20 15:23:46 +01:00
Catherine 5c1c8299a5 Color expiring manifests in -list-manifest output.
The color scheme is the same as in `-audit-log`.
2026-07-16 12:43:30 +00:00
Catherine 25462fbd42 Rename -site-expire to -expire-sites for consistency.
The flag is feature-gated.
2026-07-16 12:39:01 +00:00
woodpecker-bot 3de40a6b49 [Renovate] Update all dependencies 2026-07-16 00:06:51 +00:00
miyuko b02271cc27 Update go-slog-syslog. 2026-07-14 08:42:42 +01:00
miyuko 578e3b55d7 Update gomod2nix.toml. 2026-07-14 08:42:22 +01:00
whitequark 3d2488e051 Include source archive among release assets.
Forgejo does not guarantee that release archive checksums don't change.
2026-07-12 14:52:09 +02:00
woodpecker-bot fa8fbcd892 [Renovate] Update module golang.org/x/net to v0.55.0 [SECURITY] 2026-07-08 15:11:58 +00:00
imi415 03999af740 backend: s3: add option to choose bucket lookup type.
Certain S3 compatible storage providers does not support path style
bucket lookup anymore, add config option to manually specify DNS style
for minio.

Signed-off-by: imi415 <imi415@imi.moe>
2026-07-08 16:46:19 +08:00
woodpecker-bot f492dc707d [Renovate] Update module github.com/go-git/go-git/v6 to v6.0.0-alpha.4 [SECURITY] 2026-07-07 15:52:55 +00:00
Catherine 7d3368e196 Display audit records for expiring sites in a different color. 2026-07-01 01:03:47 +02:00
miyuko d870d0f9c5 Add an administrative CLI command to delete a site. 2026-06-28 21:27:59 +01:00
Catherine 4ce40fe560 Clarify docs on forge authorization for previews. 2026-06-23 10:32:47 +00:00
miyukoandCatherine 43dec6032a Match on the full request URL when applying headers.
Fixes: https://codeberg.org/git-pages/git-pages/issues/206
2026-06-19 09:20:07 +02:00
miyukoandCatherine 4cc8d58548 Don't serve files for URLs with trailing slashes.
Fixes: https://codeberg.org/git-pages/git-pages/issues/205
2026-06-19 09:15:14 +02:00
miyuko f620381551 Return 422 Unprocessable Entity on invalid archive uploads.
Fixes: https://codeberg.org/git-pages/git-pages/issues/216
2026-06-19 03:10:32 +01:00
miyuko 2737f275cf Add tests for HTTP content encoding negotiation. 2026-06-19 02:08:16 +01:00
miyuko 223512cd7a Fix implicit identity Accept-Encoding handling. 2026-06-19 02:04:56 +01:00
miyuko c2928f483f Fix 406 Not Acceptable when Accept-Encoding ends with *;q=0.
Fixes: https://codeberg.org/git-pages/git-pages/issues/203
2026-06-18 20:46:18 +01:00
Koen Oostveen 28012ffa5a Fix _redirects not using the fragment of the redirect URL
Closes #208
2026-06-08 16:36:59 +02:00
Andrew Cassidy 8be2ad0da1 [breaking-change] Clear redirects and headers when PATCHing manifest
Without this, whenever _redirects or _headers gets PATCHed, any new values are appended to the old instead of overriding it.
2026-06-07 21:21:59 -07:00
Catherine a5f3f2898b [breaking-change] Remove SIGHUP handler entirely.
The implementation contains both data races on single-word memory
accesses as well as multiple-word memory accesses which can result
in observing torn writes. It is unsafe and unsalvageable without
wrapping every access to global state into a mutex, or else stopping
request processing during a reload. Both are invasive options.

Since the server restarts very quickly, remove the handler to fix this.
2026-06-01 13:52:40 +00:00
Catherine 8fa88e0444 Fix regression in commit 0cd96a2b0b.
V12-Ref: F-77365
2026-06-01 10:33:09 +02:00
Catherine d1b652b895 Complete the fix in commit c591959fa9.
Staticcheck should have a lint for using `defer` in a loop, but it
does not.

V12-Ref: F-77363
2026-06-01 10:33:09 +02:00
Catherine 3d52632648 Fix regression in commit 0849735f9e.
The check would always fail.

V12-Ref: F-77362
2026-06-01 10:33:09 +02:00
miyukoandCatherine b78ac59758 Make existence cache refresh checks more robust.
For If-Modified-Since checks on the last change marker, only ever send
timestamps that we previously received from the server. This sidesteps
issues like races and anything dealing with clock precision.

Also make the code simpler to follow: handleFilterUpdates() now owns
lastRefresh, and refresh() now owns lastChanged.

Also retry with an exponential backoff if we fail to refresh the cache.
All sends to accessCh are non-blocking and are not affected.

V12-Ref: F-77198
2026-05-31 19:05:53 +02:00
Catherine bdc27c56f6 Improve installation section in README. 2026-05-31 15:59:23 +00:00
Catherine 434bc884c5 [security] Forbid backslashes from occurring in project names.
This addresses an authorization bypass (which could occur only on
Windows).

A more principled way to do this would be to use `os.Root.OpenRoot`
and scope the actual filesystem operations per-domain. However, I
prototyped this and it was complicated enough that it wasn't clear
whether this would not introduce new issues.

V12-Ref: F-77209
2026-05-30 19:10:41 +00:00
Catherine c591959fa9 Address minor file descriptor leak in CollectTar.
Before this commit, the reader opened by `GetBlob` was not closed.
This does not matter for the current implementation of the S3 backend,
but for the FS backend the file descriptor was only closed by
the `os.file` finalizer.

V12-Ref: F-77205
2026-05-30 18:13:49 +00:00