Commit Graph

39 Commits

Author SHA1 Message Date
Catherine
43b6d92492 Split UnfreezeDomain off FreezeDomain. NFC
The code would branch on the value of `freeze` in basically all
implementations and call sites.
2025-12-06 01:40:19 +00:00
Catherine
ed2d853cbe Add EnumerateManifests API and -list-manifests option.
The new API replaces the `ListManifests` API.

This also adds `Name` and `Size` to manifest metadata.
2025-12-06 00:10:04 +00:00
Catherine
1e3c39b7f6 Add EnumerateBlobs API and -list-blobs option.
This also adds `Name` to blob metadata.
2025-12-06 00:10:04 +00:00
Catherine
92dc8f7231 Consolidate return values into BlobMetadata. NFC 2025-12-06 00:10:04 +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
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
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
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
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
eaf77565bc Improve configuration reload and clarify scope.
This commit also moves all of the globals into `main.go`.
2025-11-20 04:06:09 +00:00
Catherine
0e342b11f6 Add Last-Modified: header to /.git-pages/ metadata responses. 2025-11-19 22:37:06 +00:00
Catherine
26b29ec4be Add Netlify _headers support. 2025-11-11 15:36:14 +00:00
Catherine
f9e142dd51 Observe all storage errors reported by GetManifest.
Otherwise users may get jumpscares of "site not found" due to temporary
conditions (network errors to S3 backend included).
2025-11-11 06:10:01 +00:00
miyuko
aa965c5a08 Use s3:GetObject instead of s3:ListObjects for CheckDomain. 2025-10-22 13:45:15 +01:00
Catherine
d1be93919f Make installable with go install. 2025-10-22 05:24:55 +00:00
miyuko
3863f0f134 Revert "Add a GetManifests function."
This reverts commit 0a111234f2.
2025-10-22 00:25:21 +01:00
Catherine
0a111234f2 Add a GetManifests function.
Intended as an implementation detail of parallel `getPages`.
2025-10-21 01:40:22 +00:00
miyuko
eda3e8a791 Add stale-while-revalidate support to the cache. 2025-10-15 23:53:12 +01:00
Catherine
b1c50c10de Thread context argument through the backend interface. NFC 2025-09-29 23:10:33 +00:00
miyuko
1c7ef99359 Add manifest and blob metrics. 2025-09-27 18:36:17 +01:00
Catherine
a159dba0b8 [breaking-change] Redesign environment var configuration overrides.
This is done using reflection to avoid boilerplate and potential desync
of the two configuration interfaces. The `[[wildcards]]` section did
not fit well into the "splat every config key" paradigm, so it is
unmarshalled as a whole from a JSON payload in an environment variable.

This commit also splits up the `Config` type into small per-section
struct types and removes most references to the global `config` in
favor of passing pointers to sections around.

A new option, `-print-config-env-vars`, shows the names and types of
all of the available configuration knobs.
2025-09-22 07:02:42 +00:00
Catherine
5765fa7ffa Proxy requests for unknown sites via wildcard fallback URL (if any). 2025-09-21 02:39:44 +00:00
Catherine
e5f1bac0ed Remove outdated comment. NFC 2025-09-20 08:38:55 +00:00
Catherine
3acab677e0 Split up backend.go. NFC 2025-09-20 04:39:13 +00:00
Catherine
7178885bfb Add a dedicated error type to report missing blob or manifest. 2025-09-20 04:24:36 +00:00
Catherine
5f3edfedf9 Add DELETE method support. 2025-09-19 04:08:22 +00:00
Catherine
c9b2cbb52e Work around a TOCTTOU race in os.Root.MkdirAll().
This race was reliably triggered by an initial push into an empty blob
store, causing it to fail.
2025-09-17 23:14:52 +00:00
Catherine
f482be4c05 Invalidate S3 backend cache after committing or deleting a manifest. 2025-09-17 17:01:50 +00:00
Catherine
13c72015a7 Raise default S3 backend max-age for manifests to 60s.
The default of 5s is way too aggressive and results in poor experience.
2025-09-17 15:16:02 +00:00
Catherine
ef7aea6a38 Fix S3 backend cache expiry calculation. 2025-09-17 14:19:10 +00:00
Catherine
48cc4cbcbb Cache misses as well as hits in S3 GetManifest.
Otherwise URLs with a subdirectory end up hammering the backend server.
2025-09-17 14:18:08 +00:00
miyuko
cf8abbca28 Wrap errors when calling fmt.Errorf. 2025-09-17 13:14:42 +01:00
Catherine
3b80cb4144 Fix domain presence check.
Before this commit, domains which had a project deployed but not
an index would be incorrectly considered nonexistent when queried
via the Caddy endpoint.
2025-09-17 12:11:25 +00:00
Catherine
b3f8b941d8 [breaking-change] Split blob paths for S3 backend as well. 2025-09-17 10:03:39 +00:00
Catherine
373d48ed22 Cache blobs in memory when using the S3 backend. 2025-09-17 07:42:33 +00:00
Catherine
1faf0a4431 Cache manifests in memory when using the S3 backend. 2025-09-17 06:54:20 +00:00
Catherine
6254176a17 Add logging to S3 backend. 2025-09-17 06:20:22 +00:00
Catherine
7fc81d3d97 [breaking-change] Rearchitect for better object store compatibility.
Co-authored-by: bin <flumf@users.noreply.github.com>
2025-09-17 05:59:50 +00:00