This commit is contained in:
Mateusz Gruszczyński committed 2026-11-19 23:17:19 +01:00
1 parent 45b1fc04c7
commit 8b7f5dbfb8
21 files changed
+765 -413

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
# RustProxy source and documentation maintenance # RustProxy source and documentation maintenance
Current source version: **0.38.10**. The Cargo package and binary are named `rust-proxy`. Current source version: **0.39.0**. The Cargo package and binary are named `rust-proxy`.
Before editing, read [README.md](README.md), the relevant [documentation guide](docs/README.md) and the actual code and tests. Historical release experiments are not current specifications. Use the bundled `src/admin/openapi.json` for API routes and payloads; the source implementation is authoritative for runtime behavior. Before editing, read [README.md](README.md), the relevant [documentation guide](docs/README.md) and the actual code and tests. Historical release experiments are not current specifications. Use the bundled `src/admin/openapi.json` for API routes and payloads; the source implementation is authoritative for runtime behavior.
+30 -1
View File
@@ -2,6 +2,35 @@
Release history focused on **features, settings, default behavior, compatibility and fixes**. Changes to internal code structure and preliminary performance experiments are intentionally omitted. Historical descriptions reflect their respective releases; consult the current documentation for the settings available in the latest release. Release history focused on **features, settings, default behavior, compatibility and fixes**. Changes to internal code structure and preliminary performance experiments are intentionally omitted. Historical descriptions reflect their respective releases; consult the current documentation for the settings available in the latest release.
## 0.39.0 — Dependency security refresh and compatibility fixes (source release)
### Changed
- **Dependency updates:** upgraded compatible Rust dependencies, including:
- **TLS and cryptography:** `rustls 0.23.46`, `rustls-webpki 0.103.17`, `tokio-rustls 0.26.6`, `sha2 0.11.1`.
- **Networking and HTTP/3:** `tokio 1.54.1`, `hpx-h3 2.6.1`, `quinn-proto 0.11.19`.
- **Database:** `sqlx 0.9.1`, `libsqlite3-sys 0.40.0`.
- **Compression and system:** `zstd 0.14.4`, `systemstat 0.2.8`.
- Updated additional networking, compression, cryptography, and utility dependencies.
- Regenerated `Cargo.lock` and synchronized the package version to `0.39.0`.
### Security
- Updated TLS certificate validation, QUIC, SQLite, and asynchronous I/O dependencies to versions containing published security fixes.
- Refreshed TLS and QUIC protocol components for security and stability.
- A complete vulnerability review with `cargo-audit` is still pending; successful tests do not replace a dependency audit.
### Fixed
- Adapted SHA-256 hexadecimal encoding to the `sha2 0.11` API while preserving existing checksum formats.
- Fixed VCL import diagnostics to report unsupported `client.ip` conditions alongside unsupported actions, without accepting unsupported rules.
- Added regression coverage for SHA-256 encoding and VCL import warnings.
### Verification
- On the source baseline prior to the version-only bump: **981 library tests and 7 CLI tests passed**, with **0 failures** and **2 ignored**.
- The Rust test suite has not been rerun after the release metadata change.
## 0.38.10 — Cache/VCL guide and targeted rule compatibility fixes (source release) ## 0.38.10 — Cache/VCL guide and targeted rule compatibility fixes (source release)
- **Cache settings help modal:** a single in-app guide opens from Settings → Cache (header and Rules subtab). It provides concrete `Cookie`, `return(hash)`, `Vary`, `beresp`/`resp` header and TTL examples, with buttons that paste safe starting points into the *unsaved* graphical VCL importer; stage order, global/per-vhost precedence, unsupported VCL features and diagnostics. Its status line reads the current form values (including unsaved changes) and warns when storage is off, the TTL is zero or RFC mode is selected. - **Cache settings help modal:** a single in-app guide opens from Settings → Cache (header and Rules subtab). It provides concrete `Cookie`, `return(hash)`, `Vary`, `beresp`/`resp` header and TTL examples, with buttons that paste safe starting points into the *unsaved* graphical VCL importer; stage order, global/per-vhost precedence, unsupported VCL features and diagnostics. Its status line reads the current form values (including unsaved changes) and warns when storage is off, the TTL is zero or RFC mode is selected.
@@ -92,7 +121,7 @@ Panel-only release: no configuration, API or proxy behavior changes. Measured on
## 0.38.1 — built-in dashboard presets and matching fixes ## 0.38.1 — built-in dashboard presets and matching fixes
- **Path prefixes with a trailing slash:** a cache bypass prefix or forced-cache target written as `/api/` now also matches the paths below it (`/api/health`); before, it matched only the exact path `/api/`, so such responses were cached when their headers allowed it. `/api` (without the slash) already covered `/api` and `/api/…` and still does not match `/apix`. - **Path prefixes with a trailing slash:** a cache bypass prefix or forced-cache target written as `/api/` now also matches the paths below it (`/api/health`); before, it matched only the exact path `/api/`, so such responses were cached when their headers allowed it. `/api` (without the slash) already covered `/api` and `/api/…` and still does not match `/apix`.
- **Cache rule extensions:** an `extension` condition value written with a leading dot or spaces (`.css`, ` .JS`) now matches like `css`; before, it never matched. - **Cache rule extensions:** an `extension` condition value written with a leading dot or spaces (`.css`, `.JS`) now matches like `css`; before, it never matched.
- **Headless reload in containers:** `rust-proxy --headless reload` also signals RustProxy running as process 1, the usual case in a container. - **Headless reload in containers:** `rust-proxy --headless reload` also signals RustProxy running as process 1, the usual case in a container.
- **Built-in dashboard presets:** **Dashboard presets** now offers twelve ready-made Overview layouts next to your own: ten for a Full HD screen (Operations/NOC, Traffic and protocols, Cache and compression, Backends and load balancing, Resources and process, Errors and security, Docker, Web Server and PHP, TCP/UDP streams, Wall display) and two for phones (status, on call). They set card order, widths, visibility, density and history length, cannot be deleted and do not count towards the 16 saved presets; see [Dashboard](docs/DASHBOARD.md). - **Built-in dashboard presets:** **Dashboard presets** now offers twelve ready-made Overview layouts next to your own: ten for a Full HD screen (Operations/NOC, Traffic and protocols, Cache and compression, Backends and load balancing, Resources and process, Errors and security, Docker, Web Server and PHP, TCP/UDP streams, Wall display) and two for phones (status, on call). They set card order, widths, visibility, density and history length, cannot be deleted and do not count towards the 16 saved presets; see [Dashboard](docs/DASHBOARD.md).
- **Docs:** the headless production example uses `/api`, `/admin`, `/login` as cache bypass prefixes. - **Docs:** the headless production example uses `/api`, `/admin`, `/login` as cache bypass prefixes.
Generated
+229 -236
View File
File diff suppressed because it is too large. Load diff
+53 -47
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "rust-proxy" name = "rust-proxy"
version = "0.38.10" version = "0.39.0"
edition = "2021" edition = "2021"
rust-version = "1.99.1" rust-version = "1.99.1"
description = "RustProxy - independent reverse proxy with local administration" description = "RustProxy - independent reverse proxy with local administration"
@@ -11,63 +11,69 @@ repository = "https://git.linuxiarz.pl/gru/RustProxy"
publish = false publish = false
[dependencies] [dependencies]
argon2 = "0.6" argon2 = "0.6.0"
sha2 = "0.10" sha2 = "0.11.1"
ipnet = "2.11" ipnet = "2.12.2"
rpassword = "7.4" rpassword = "7.5.5"
zeroize = "1.8" zeroize = "1.9.2"
anyhow = "1.0" anyhow = "1.0.104"
mimalloc = { version = "0.1", default-features = false, optional = true } mimalloc = { version = "0.1.52", default-features = false, optional = true }
libc = "0.2" libc = "0.2.191"
arc-swap = "1.7" arc-swap = "1.9.5"
axum = { version = "0.8.9", default-features = false, features = ["http1", "http2", "json", "query", "tokio", "ws"] } axum = { version = "0.8.9", default-features = false, features = ["http1", "http2", "json", "query", "tokio", "ws"] }
bytes = "1.10" bytes = "1.12.2"
clap = { version = "4.5", features = ["derive", "env"] } clap = { version = "4.6.8", features = ["derive", "env"] }
futures-util = "0.3" futures-util = "0.3.34"
fs2 = "0.4" fs2 = "0.4.3"
http = "1.3" http = "1.5.0"
http-body = "1.0" http-body = "1.1.0"
http-body-util = "0.1" http-body-util = "0.1.5"
hyper = { version = "1.12.0", features = ["client", "server", "http1", "http2"] } hyper = { version = "1.12.0", features = ["client", "server", "http1", "http2"] }
hyper-util = { version = "0.1", features = ["client-legacy", "server-auto", "http1", "http2", "tokio"] } hyper-util = { version = "0.1.21", features = ["client-legacy", "server-auto", "http1", "http2", "tokio"] }
rand = "0.10" rand = "0.10.4"
regex = "1.11" regex = "1.13.2"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0.229", features = ["derive"] }
serde_json = "1.0" serde_json = "1.0.154"
sqlx = { version = "0.9", default-features = false, features = ["runtime-tokio", "sqlite"] } sqlx = { version = "0.9.1", default-features = false, features = ["runtime-tokio", "sqlite"] }
subtle = "2.6" # Security floor: SQLx allows >=0.30.1,<0.41; 0.39+ bundles SQLite with CVE-2026-119375 fixed.
tokio = { version = "1.53.2", features = ["macros", "rt-multi-thread", "net", "signal", "time", "sync", "fs", "io-util", "process"] } libsqlite3-sys = { version = "0.40.0", default-features = false }
tokio-util = { version = "0.7", features = ["rt", "io"] } subtle = "2.6.1"
tower = { version = "0.5", features = ["util"] } tokio = { version = "1.54.1", features = ["macros", "rt-multi-thread", "net", "signal", "time", "sync", "fs", "io-util", "process"] }
tracing = "0.1" tokio-util = { version = "0.7.20", features = ["rt", "io"] }
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] } tower = { version = "0.5.3", features = ["util"] }
url = "2.5" tracing = "0.1.44"
tracing-subscriber = { version = "0.3.23", features = ["env-filter", "fmt"] }
url = "2.5.8"
base64 = "0.22" base64 = "0.23.1"
sha1 = "0.10" sha1 = "0.11.0"
rustls = { version = "0.23", default-features = false, features = ["ring", "aws_lc_rs", "std", "tls12"] } rustls = { version = "0.23.46", default-features = false, features = ["ring", "aws_lc_rs", "std", "tls12"] }
ring = "0.17" # Security floor: 0.103.16 rejects distrusted emSign intermediates (RUSTSEC-2026-0382).
tokio-rustls = { version = "0.26", default-features = false, features = ["ring", "tls12"] } rustls-webpki = { version = "0.103.16", default-features = false }
hyper-rustls = { version = "0.27", default-features = false, features = ["ring", "http1", "http2", "tls12"] } ring = "0.17.14"
rustls-pemfile = "2.2" tokio-rustls = { version = "0.26.6", default-features = false, features = ["ring", "tls12"] }
webpki-roots = "1.0" hyper-rustls = { version = "0.27.10", default-features = false, features = ["ring", "http1", "http2", "tls12"] }
rustls-pemfile = "2.2.0"
webpki-roots = "1.0.12"
rcgen = { version = "0.14.10", default-features = false, features = ["crypto", "pem", "ring"] } rcgen = { version = "0.14.10", default-features = false, features = ["crypto", "pem", "ring"] }
httpdate = "1.0" httpdate = "1.0.3"
tower-http = { version = "0.7.1", default-features = false, features = ["compression-gzip", "compression-br", "compression-zstd", "compression-deflate"] } tower-http = { version = "0.7.1", default-features = false, features = ["compression-gzip", "compression-br", "compression-zstd", "compression-deflate"] }
flate2 = "1.1" flate2 = "1.1.11"
brotli = "9" brotli = "9.1.3"
zstd = "0.14" zstd = "0.14.4"
h3 = { package = "hpx-h3", version = "=2.5.20", features = ["quinn"] } h3 = { package = "hpx-h3", version = "=2.6.1", features = ["quinn"] }
quinn = { version = "0.11.12", default-features = false, features = ["runtime-tokio", "rustls-ring"] } quinn = { version = "0.11.12", default-features = false, features = ["runtime-tokio", "rustls-ring"] }
# Security floor: 0.11.19 fixes the Nov 2026 QUIC DoS advisories RUSTSEC-2026-0523/0524.
quinn-proto = { version = "0.11.19", default-features = false }
socket2 = "0.6.5" socket2 = "0.6.5"
metrics-process = { version = "=2.4.3", default-features = false, features = ["dummy"] } metrics-process = { version = "=2.4.3", default-features = false, features = ["dummy"] }
sysinfo = { version = "0.39", default-features = false, features = ["network", "system"] } sysinfo = { version = "0.40.4", default-features = false, features = ["network", "system"] }
[target.'cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd", target_os = "netbsd", target_os = "dragonfly", target_os = "macos", target_os = "windows"))'.dependencies] [target.'cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd", target_os = "netbsd", target_os = "dragonfly", target_os = "macos", target_os = "windows"))'.dependencies]
systemstat = "=0.2.7" systemstat = "=0.2.8"
# Swagger assets are prepared by build.rs and embedded behind the admin guard. # Swagger assets are prepared by build.rs and embedded behind the admin guard.
# No adapter build script, implicit version fallback or Cargo-config dependency. # No adapter build script, implicit version fallback or Cargo-config dependency.
@@ -77,10 +83,10 @@ default = []
mimalloc = ["dep:mimalloc"] mimalloc = ["dep:mimalloc"]
[build-dependencies] [build-dependencies]
serde_json = "1.0" serde_json = "1.0.154"
[dev-dependencies] [dev-dependencies]
tempfile = "3.19" tempfile = "3.27.0"
[profile.release] [profile.release]
lto = "thin" lto = "thin"
+20 -21
View File
@@ -1,10 +1,10 @@
61bf40a0572889dc8b0dda9eae4e93e44b0de9364b3c798106c85700ffb37c23 .dockerignore 61bf40a0572889dc8b0dda9eae4e93e44b0de9364b3c798106c85700ffb37c23 .dockerignore
4140a2956264b44f259e6a37fc00ba02097bbe68b09296e04d3d243c1287129b .env.example 4140a2956264b44f259e6a37fc00ba02097bbe68b09296e04d3d243c1287129b .env.example
e76e688874828e3743d03693b1d2872b9633b4db09909673786caf30f7cfe489 .gitignore e76e688874828e3743d03693b1d2872b9633b4db09909673786caf30f7cfe489 .gitignore
1e1dda6551bf6caf6d0c027e266938476c03637d81d564717cc6a7b71a25ab3e AGENTS.md d0ee3e0d9956ceb7384430cf12784b4173d9fb4e50d6be3a9ef082b3867ab4db AGENTS.md
ae77d51d9c3162dbb994f41f00807110f256e1d7efd006533daf511b70a98102 CHANGELOG.md ba2ed47c08764410eba014e9216f4ddd0fdd179f6be7855d719980340c24a1e2 CHANGELOG.md
8d48a3f6f3b0d025511e6aa0456f0d2dd36f99fb51f62508d30527b572af28bb Cargo.lock 958e2bb62b874e0e81efce99aaf4cf0a37148a698d6f35341bdcd4b733cabefd Cargo.lock
c01f3fc21aafd193b8d306d1c6bf93ce97cafb137b124c62a2a5f36b2089c758 Cargo.toml 8cc2002d1c5fab90e75a451e55f889d1dce0e6bd1f7df8bdb6c10619e83a359a Cargo.toml
788745d4f70a0382c6280020afbd48844bb2af65e835a826852143f8132cdeca Dockerfile 788745d4f70a0382c6280020afbd48844bb2af65e835a826852143f8132cdeca Dockerfile
0d96a4ff68ad6d4b6f1f30f713b18d5184912ba8dd389f86aa7710db079abcb0 LICENSE 0d96a4ff68ad6d4b6f1f30f713b18d5184912ba8dd389f86aa7710db079abcb0 LICENSE
82d1dee2fc68158f0ea73259151461e64c8b18d807cd1fecfb1ed99dc30cf5f4 README.md 82d1dee2fc68158f0ea73259151461e64c8b18d807cd1fecfb1ed99dc30cf5f4 README.md
@@ -63,7 +63,7 @@ bbef60ff1771da9f48af812987766e1e479408873ae2f079b13f1d5c62ecc6ff docs/STREAMS.m
c9c9a0b401f0565f15b834d855bfdb34edb3eab46bff03d9e0825af204d20bf8 docs/TODO.md c9c9a0b401f0565f15b834d855bfdb34edb3eab46bff03d9e0825af204d20bf8 docs/TODO.md
978097cf53314ad573583d7176491d984b9dbb22295df2b00168a28b14184c4a docs/TRANSPORT.md 978097cf53314ad573583d7176491d984b9dbb22295df2b00168a28b14184c4a docs/TRANSPORT.md
be6e8af62a7bf958b94ec15e9e3263263e511d1d33abae4e45d114833fa52b07 docs/TROUBLESHOOTING.md be6e8af62a7bf958b94ec15e9e3263263e511d1d33abae4e45d114833fa52b07 docs/TROUBLESHOOTING.md
1d6efc5d7d35e75a1f39eab7312a3c8a44a227df0d621ae5f947dc5d5d88e10e docs/VCL.md 47abed11fd4f0370ee887fb2e5e4ee777af2cad194db5638ad65714a9c07218d docs/VCL.md
1169420deeed8f2e8f3a0acfb3ffe16a3419820ba1869059e0b82bb2411e1537 docs/VHOSTS.md 1169420deeed8f2e8f3a0acfb3ffe16a3419820ba1869059e0b82bb2411e1537 docs/VHOSTS.md
e67928a9d044e71b681c3e52f9dd8b151d6b72f965d16d5da8b0eadde98b70e9 docs/WEB_SERVER.md e67928a9d044e71b681c3e52f9dd8b151d6b72f965d16d5da8b0eadde98b70e9 docs/WEB_SERVER.md
42822b1c9801bcadb0e2d785cb91883ca2df1da141222631f153030c95f5e197 docs/images/about.png 42822b1c9801bcadb0e2d785cb91883ca2df1da141222631f153030c95f5e197 docs/images/about.png
@@ -199,7 +199,7 @@ f3635b624cf48598d68274a470d84d15ef9f6070d56e437a0031afa724471d5e src/admin/pref
fba52102e77ca8871a42f97c91be8f10a9aa4f997868652d550fff3fbd41b66e src/admin/session.rs fba52102e77ca8871a42f97c91be8f10a9aa4f997868652d550fff3fbd41b66e src/admin/session.rs
1c4d04b14a508fca7537f54e660124f4dae1964b48d7bd3b878ec4faa7156805 src/admin/status.rs 1c4d04b14a508fca7537f54e660124f4dae1964b48d7bd3b878ec4faa7156805 src/admin/status.rs
9b5bc1a439c5e5611c47732fe86097877b50b09b10a0838d9813314ea6232d0c src/admin/status_live.rs 9b5bc1a439c5e5611c47732fe86097877b50b09b10a0838d9813314ea6232d0c src/admin/status_live.rs
8315c856cd50f1072593ecb30c274d42d82f078b5fb93e7c68a8857cd81b0841 src/admin/status_system.rs c20f214e2ec2a14d8a88d07a63a27d9396a7a6bf9446f6ee31dbd77b12e4b585 src/admin/status_system.rs
cadd7dca29b9aad8c77c7bc23dd249ea37a15adfa4d636a8ef00273a91ce35dc src/admin/tail.rs cadd7dca29b9aad8c77c7bc23dd249ea37a15adfa4d636a8ef00273a91ce35dc src/admin/tail.rs
c759b6bb19aecc915bb4eaea5c3602b3b4196fc9d168d99dbc58b321539d3a6e src/admin/tests.rs c759b6bb19aecc915bb4eaea5c3602b3b4196fc9d168d99dbc58b321539d3a6e src/admin/tests.rs
d6c7ef48325c8f4f7ae7504827c0255c263b41c838f61960381907ca78eb9b95 src/admin/web/acl-picker.js d6c7ef48325c8f4f7ae7504827c0255c263b41c838f61960381907ca78eb9b95 src/admin/web/acl-picker.js
@@ -300,7 +300,7 @@ f9854526ff1567de47ecb02af872bca6e13c0adb984ad5ef0c256e5fdbb3902e src/admin/web/
36f11beed56711640bb56bb6f452bf76dec2ce4be6a57e8abc19560af477c870 src/alerts.rs 36f11beed56711640bb56bb6f452bf76dec2ce4be6a57e8abc19560af477c870 src/alerts.rs
2d40c2cb32d7365df0c9cd6c8cb6f0483c7a799786c648f4836a0d9740c6c5ef src/auth/files/mod.rs 2d40c2cb32d7365df0c9cd6c8cb6f0483c7a799786c648f4836a0d9740c6c5ef src/auth/files/mod.rs
b2f948bcc3dbd24952c7b1b02d41d06757f49f0c38a78caf51f8f8a687d8480d src/auth/files/tests.rs b2f948bcc3dbd24952c7b1b02d41d06757f49f0c38a78caf51f8f8a687d8480d src/auth/files/tests.rs
50ef648351271d78310e00caa6d246e0009171ed036a3e4e1144737df8c064c2 src/auth/mod.rs 4290d4eac1ca5486f7240f59475c781020f4259187e4ed632bec6465b82fd807 src/auth/mod.rs
cc4ddd57a264d12bffab131bf04b5cd22df75d38b61e21ce669f5a8a97b109ac src/auth/store.rs cc4ddd57a264d12bffab131bf04b5cd22df75d38b61e21ce669f5a8a97b109ac src/auth/store.rs
745226cabb007819370fc6aa680995a03a8a13fa057dacfab0fcc21d0c43bbe4 src/auth/tests.rs 745226cabb007819370fc6aa680995a03a8a13fa057dacfab0fcc21d0c43bbe4 src/auth/tests.rs
a4c14df927c22a7fa46023f25cfe48d3aa3c245bec97fce834999d9bcc8d75e1 src/auth_provider/choice.rs a4c14df927c22a7fa46023f25cfe48d3aa3c245bec97fce834999d9bcc8d75e1 src/auth_provider/choice.rs
@@ -312,11 +312,11 @@ d3d9b756f8dd0444ce6937376f27fa2eae7eb4b9304a2ff039d272c929592bdb src/auth_provi
0137e66fb7127f1ce023b1c6cfe3fac3fb1e8be17f1de722f8ef4e66d2594a13 src/authentik/mod.rs 0137e66fb7127f1ce023b1c6cfe3fac3fb1e8be17f1de722f8ef4e66d2594a13 src/authentik/mod.rs
d4a388f0897e50ad26e1d8ea527eccdf656557abb4b88fe714cc2b1969d8715e src/authentik/tests.rs d4a388f0897e50ad26e1d8ea527eccdf656557abb4b88fe714cc2b1969d8715e src/authentik/tests.rs
32a25e53ac9542424debeaf1b637155bd4e60abd8692df082729d81232eb90b3 src/backup.rs 32a25e53ac9542424debeaf1b637155bd4e60abd8692df082729d81232eb90b3 src/backup.rs
5e8b1d7cf8280bec54521cec9e4a8cb9cdbed5deaca07e3a79c43d2336f22a80 src/backup/archive.rs 0ebe1b8b3144a247402d13b4d321d801bc2c5b34c4e472f832aeca9f20e552eb src/backup/archive.rs
15213c87d4393739328ebf0eacfcb45f864ac12d7bd7509f750a241032f6c7e9 src/backup/ownership.rs 15213c87d4393739328ebf0eacfcb45f864ac12d7bd7509f750a241032f6c7e9 src/backup/ownership.rs
6edb5aabd210ff2d121e435815b5501c9eccbd7a8ba230c843c6335a3e24f94b src/backup/snapshot.rs 98aa136af1086ccc43df49a71fbca8e34e6df5fc9e41e84d9bc8a7a579d059af src/backup/snapshot.rs
859cec0bcd604f205d7d8e14d1c810e33d97fd7cf00ddcc30877bcea7c5fc2b5 src/backup/tests.rs 859cec0bcd604f205d7d8e14d1c810e33d97fd7cf00ddcc30877bcea7c5fc2b5 src/backup/tests.rs
5293e1b06f82654929805b53b9092a82b7503a54b34da3e882a999c5f14ee579 src/backup/validation.rs a7dda92c0323343f28dd59d0907af52000ce18cc66c1386fdb83b6665ade7fa2 src/backup/validation.rs
eec564a7ef886d18ab75289025a47d62bb702f07d63f92d2f83b7afeecebbb15 src/balance.rs eec564a7ef886d18ab75289025a47d62bb702f07d63f92d2f83b7afeecebbb15 src/balance.rs
9158a2bbb303c53bd3d2c779d9eb6e4470d028c4f28f8e329788e9c8c830f843 src/balance/health.rs 9158a2bbb303c53bd3d2c779d9eb6e4470d028c4f28f8e329788e9c8c830f843 src/balance/health.rs
458733ad4ec56d58112de6ffa3539ca7e9fa8311048a4e120da96b5f899d5dae src/balance/lease_runtime.rs 458733ad4ec56d58112de6ffa3539ca7e9fa8311048a4e120da96b5f899d5dae src/balance/lease_runtime.rs
@@ -363,13 +363,13 @@ e26dce02df9c043329ca164fed215d271781bce8fb03240f528331bf3df6b9d7 src/cache/poli
12a6d5d9d6711e956391b4b952e8149658b8bf64cfcc0a4c59c281f2630a6aac src/cache/policy/scope_tests.rs 12a6d5d9d6711e956391b4b952e8149658b8bf64cfcc0a4c59c281f2630a6aac src/cache/policy/scope_tests.rs
c3a4300f7cdb6b2b7c16fbc489d49ba2451331bb4a55a2d9f618c684fd61eecb src/cache/range.rs c3a4300f7cdb6b2b7c16fbc489d49ba2451331bb4a55a2d9f618c684fd61eecb src/cache/range.rs
37d077a35f34e3ed76601838ffc3a9596a452727ce7cbfc82d024fb70b6b5fa4 src/cache/rules.rs 37d077a35f34e3ed76601838ffc3a9596a452727ce7cbfc82d024fb70b6b5fa4 src/cache/rules.rs
3682fd3c1f2b6f8cd87e50c09b932faf07f01a668f925e0f85333aa7662a548b src/cache/rules_tests.rs 97dfb7627f07a8a17adbeeabaeaf6fd335c9edf006cebc4391496b783d97ec14 src/cache/rules_tests.rs
48344d7dcbbb220d8c16f5aa9bb88d86a6388b226bbf93d0ca92d8dfbf2c8001 src/cache/stats.rs 48344d7dcbbb220d8c16f5aa9bb88d86a6388b226bbf93d0ca92d8dfbf2c8001 src/cache/stats.rs
2981e35a7fbbc2b36214b5518f4ba97d57c1d2e01f4f375175c4b2c6be955927 src/cache/tests.rs 2981e35a7fbbc2b36214b5518f4ba97d57c1d2e01f4f375175c4b2c6be955927 src/cache/tests.rs
b969394b04859b269dcecd8958b1aab40b532709512714e9900f0ecad6b6d0c5 src/cache/tickets.rs b969394b04859b269dcecd8958b1aab40b532709512714e9900f0ecad6b6d0c5 src/cache/tickets.rs
a1132b980833b1b4ce2bba9aa681ff255a0e2d61faaa65a316860da503ea1e27 src/cache/v022_cache_tests.rs a1132b980833b1b4ce2bba9aa681ff255a0e2d61faaa65a316860da503ea1e27 src/cache/v022_cache_tests.rs
adac3b8de21a73f32d784b3fd2240d17309e8fce022163710e781d44ef590117 src/cache/varnish_compatible_tests.rs adac3b8de21a73f32d784b3fd2240d17309e8fce022163710e781d44ef590117 src/cache/varnish_compatible_tests.rs
1e2217f77a5414309de354d5bff8a16d0388234e4c23e3cc7ff0f79430a6a8f7 src/cache/vcl.rs 978397b19719afa6f27e17ec88fcbf02d770a73d72950499157c3ef6fa1fc0da src/cache/vcl.rs
1a2eb6684d9ea4a7e90970d936c75f7c8bbec46a4181fdf273be9bdac8eec847 src/compression/mod.rs 1a2eb6684d9ea4a7e90970d936c75f7c8bbec46a4181fdf273be9bdac8eec847 src/compression/mod.rs
8de82d9188c9c337690c6ec4afdad9fff20651c358e34602a93d8bb8c3d2489a src/compression/tests.rs 8de82d9188c9c337690c6ec4afdad9fff20651c358e34602a93d8bb8c3d2489a src/compression/tests.rs
e695079333ebdc2a6e7b3337cfabef171b3a0a01da0597b77feff70d417f833e src/config.rs e695079333ebdc2a6e7b3337cfabef171b3a0a01da0597b77feff70d417f833e src/config.rs
@@ -404,18 +404,19 @@ b821e2efd2939cb13d01e402532f33feba6682acb6a7a3223be086c1cd171820 src/forwarding
e3646c044604bbc169aeba549d973d37b8ac52f88bbab4a0ef74c6ea69681eaa src/geoip/mmdb.rs e3646c044604bbc169aeba549d973d37b8ac52f88bbab4a0ef74c6ea69681eaa src/geoip/mmdb.rs
1e8777b295e6a2de15b55548e8c4c3a4166b1c5af18d4d33bf067d8bece1b590 src/geoip/mmdb_tests.rs 1e8777b295e6a2de15b55548e8c4c3a4166b1c5af18d4d33bf067d8bece1b590 src/geoip/mmdb_tests.rs
cfc75486e69c310fa6e7bf0448ed39a20cdad9dd8afe75e01592fc7c76a380db src/geoip/tests.rs cfc75486e69c310fa6e7bf0448ed39a20cdad9dd8afe75e01592fc7c76a380db src/geoip/tests.rs
3376ea3d018faa5cb8a69da2f1d5b7cdae4bb4b8f28f373f8a0a2996410e1bb7 src/geoip/update.rs cbc6e7446f188a8bacb8c97dbbca5254639d899b926d8723523dcbfa5fedfc46 src/geoip/update.rs
86a16add6757a377264ae6afe071039851d5996e80baca9d4882b71889d7c2d2 src/geoip/update_http.rs fa1ba1275ff35afa1fea55cd50e3e7321a6a9140827008b0d76880fe298be79d src/geoip/update_http.rs
8c72a10f07f82e2c0864551a3c95e261129c23cf6072f902d063564b6ea6770f src/geoip/update_tests.rs 8c72a10f07f82e2c0864551a3c95e261129c23cf6072f902d063564b6ea6770f src/geoip/update_tests.rs
61a2b01db9010f9debfb38b43a26bf588438a5e470dff938e4e54f9d7ba46732 src/headers/mod.rs 61a2b01db9010f9debfb38b43a26bf588438a5e470dff938e4e54f9d7ba46732 src/headers/mod.rs
3e9a19c221fa7e63d097c185470b17313da7c200a73ce50f6c069b4dddd37a96 src/headers/tests.rs 3e9a19c221fa7e63d097c185470b17313da7c200a73ce50f6c069b4dddd37a96 src/headers/tests.rs
f54f29bb923c7101a0da4d9a0a322447a8ebd4c59c5954d9b2b30b0dad13b5e0 src/hex.rs
027d414f51e910ff20fbf3a924ab6b136178858f27819a046a922b1d8f349cd0 src/http3.rs 027d414f51e910ff20fbf3a924ab6b136178858f27819a046a922b1d8f349cd0 src/http3.rs
2554fc93a555e1f39d12d8c172097a4a4571d79db2b6b871a5a1bad0e8dd2778 src/http3/body.rs 2554fc93a555e1f39d12d8c172097a4a4571d79db2b6b871a5a1bad0e8dd2778 src/http3/body.rs
741972222414c280104acbcd8f8071bed9cbfcfa2f503c487c11c56f553f53cd src/http3/diagnostics.rs 741972222414c280104acbcd8f8071bed9cbfcfa2f503c487c11c56f553f53cd src/http3/diagnostics.rs
49ce4452ef7973cafa2e4071e2e14be0e16000e931a6501e4dc613652e49e230 src/http3/identity.rs 49ce4452ef7973cafa2e4071e2e14be0e16000e931a6501e4dc613652e49e230 src/http3/identity.rs
0b41072f6bcf28725c80f471584cd55d4900424ce5d55ac7f6909813788c63fd src/http3/settings.rs 0b41072f6bcf28725c80f471584cd55d4900424ce5d55ac7f6909813788c63fd src/http3/settings.rs
5c550075c7b0fe687ad02095c1cad57b46b579fe21dc5371525b6c77db459886 src/http3/tests.rs 5c550075c7b0fe687ad02095c1cad57b46b579fe21dc5371525b6c77db459886 src/http3/tests.rs
5283ed67afe19f67d9021a90df6c979e5a27804116b733765b0a44d39d45ef7d src/lib.rs be8ea083564d0c7780409fdd8843842f84144cdde3cb30bbdf1d4b68a1ae43d0 src/lib.rs
e8399753a6ff49b7de19edb0a268bf871c9979a518354160cf07b4669051fcbb src/logging.rs e8399753a6ff49b7de19edb0a268bf871c9979a518354160cf07b4669051fcbb src/logging.rs
e4be3ad758c3d93ce52dd3b1ab1a87810e5226339400ed997607a5b746354751 src/logging/error_runtime.rs e4be3ad758c3d93ce52dd3b1ab1a87810e5226339400ed997607a5b746354751 src/logging/error_runtime.rs
e9795eaa3e743c09f5ab0e18e6d359bc97a3aee55510c74923532d64df90c873 src/logging/format.rs e9795eaa3e743c09f5ab0e18e6d359bc97a3aee55510c74923532d64df90c873 src/logging/format.rs
@@ -456,7 +457,7 @@ f1b0254f53b1a4336bd8170ad441ba072b49a114e497b985cb20699b4e375044 src/prometheus
c03cdfa8da7bb440d08ce4436e8bedaaf8dad5e489169e6bc156495029e12ad5 src/proxy/cache_helpers.rs c03cdfa8da7bb440d08ce4436e8bedaaf8dad5e489169e6bc156495029e12ad5 src/proxy/cache_helpers.rs
2d39552aa01ce3d048560944975243d0a58ae762d838e547f5fa65007d871dc4 src/proxy/cache_http_invalidation.rs 2d39552aa01ce3d048560944975243d0a58ae762d838e547f5fa65007d871dc4 src/proxy/cache_http_invalidation.rs
a86b10ce0707b51e925e11ea14f7f40fa108a196166f62cf40007a97f9e17203 src/proxy/cache_http_invalidation_tests.rs a86b10ce0707b51e925e11ea14f7f40fa108a196166f62cf40007a97f9e17203 src/proxy/cache_http_invalidation_tests.rs
f93a40303bc3b6645f6928c4e8795978b0554e30a75f4c9daf9fff1e2138a037 src/proxy/cache_plan/mod.rs b2c4e168f63767008bda51eac4bd070be853e4de232af78588a61d5b182d9b51 src/proxy/cache_plan/mod.rs
811a00b55b24638b4bf8a6bea9ed7c0ffe2a758f76bfe63a95e1d31bce1c2c9c src/proxy/cache_plan/tests.rs 811a00b55b24638b4bf8a6bea9ed7c0ffe2a758f76bfe63a95e1d31bce1c2c9c src/proxy/cache_plan/tests.rs
d6bd4aafab7b1371c31b3d22ddf949a08ea942489649ca12c7615b3b2d5a109a src/proxy/error_fallback.rs d6bd4aafab7b1371c31b3d22ddf949a08ea942489649ca12c7615b3b2d5a109a src/proxy/error_fallback.rs
79ec6b6e378ecfe478ed779ba53e69030c4d5f06ebd6ae0092f335751db0667f src/proxy/forward/cache_fast_path_tests.rs 79ec6b6e378ecfe478ed779ba53e69030c4d5f06ebd6ae0092f335751db0667f src/proxy/forward/cache_fast_path_tests.rs
@@ -476,8 +477,8 @@ af9b044761a56e8a6dc57f9d760b289ff4a6bf37db11dbfcd3ec4da5b8f426b6 src/proxy/head
2bc63579975387c92a9459a9677b4a49e76df382b1ee19de12c8341a3ead57e8 src/proxy/identity.rs 2bc63579975387c92a9459a9677b4a49e76df382b1ee19de12c8341a3ead57e8 src/proxy/identity.rs
a08ee061e146cb7a08311106f73a04468c89f77b6ad05a2c623621a2ae9faf2a src/proxy/mod.rs a08ee061e146cb7a08311106f73a04468c89f77b6ad05a2c623621a2ae9faf2a src/proxy/mod.rs
92806ce1802da9b6771ece474d91a3458eba3f6ed19b0817b897e828a02e7e32 src/proxy/redirect_helpers.rs 92806ce1802da9b6771ece474d91a3458eba3f6ed19b0817b897e828a02e7e32 src/proxy/redirect_helpers.rs
de1763b89d98607e20f0f6e3c9b546483927cbe5450efc2e5634fe691fd52ad6 src/proxy/request_id/mod.rs b83b9c30022e8c8fc97654a7d83ee44702c78bc92d2089bd397054e0023c3b7c src/proxy/request_id/mod.rs
78bbc1263bcd600527bf71acdf5af92bf186267a9084b076d1f75ad6492df659 src/proxy/request_id/tests.rs a57ea795430bf52d550083fef759c739f3821217aac465c0024aa1565b0727d1 src/proxy/request_id/tests.rs
7c676831d20f1f16a95d972b67a76261ee0e6fa839261511d0c796b86471082b src/proxy/types.rs 7c676831d20f1f16a95d972b67a76261ee0e6fa839261511d0c796b86471082b src/proxy/types.rs
e44430c54038a7dc26f327b5d7085e965241da2ffef42c1526ebfc5168981f72 src/proxy/upstream_helpers.rs e44430c54038a7dc26f327b5d7085e965241da2ffef42c1526ebfc5168981f72 src/proxy/upstream_helpers.rs
96d18a85beb9d9492f4d0690eefd9afad9c1c4eabc36f41b447b81861a92ed2a src/proxy/web_cache_revalidation/mod.rs 96d18a85beb9d9492f4d0690eefd9afad9c1c4eabc36f41b447b81861a92ed2a src/proxy/web_cache_revalidation/mod.rs
@@ -526,7 +527,7 @@ c7771539fbb94544947e958e410c46b73f9647011e56b1b229ce7035fe21851f src/stream/hea
9346cbd71e006e41a7188f28eb86f9b00bac822e4cb31c76c8d6d2ec5d4c4711 src/stream/tests.rs 9346cbd71e006e41a7188f28eb86f9b00bac822e4cb31c76c8d6d2ec5d4c4711 src/stream/tests.rs
63924d279f5fdfde24d2e0663518a123dd673cc6ed9ce52233c4b6851bfb1efd src/system_stats/linux/mod.rs 63924d279f5fdfde24d2e0663518a123dd673cc6ed9ce52233c4b6851bfb1efd src/system_stats/linux/mod.rs
d9123c623e2a97d09e41edaa29993b4b2c8cba39a3abdf2b48a205aa9a9c2939 src/system_stats/linux/tests.rs d9123c623e2a97d09e41edaa29993b4b2c8cba39a3abdf2b48a205aa9a9c2939 src/system_stats/linux/tests.rs
e0676801259fb09a73825d959b89630bfa0b6f1fd1efd3006af29f60537a2fdf src/system_stats/mod.rs 65c8e36d5bf9eedea601862ab5e2d885fc740e0848c7fa2c62ad718a0c807001 src/system_stats/mod.rs
050aa831b1012c4aaade63863f433f01bfacf5d3f95787e57975572116a30ab2 src/system_stats/tests.rs 050aa831b1012c4aaade63863f433f01bfacf5d3f95787e57975572116a30ab2 src/system_stats/tests.rs
6b955b13ef848e90dae1ec2906176336a775e9511f3688779203d922ff7d23a8 src/tinyauth/mod.rs 6b955b13ef848e90dae1ec2906176336a775e9511f3688779203d922ff7d23a8 src/tinyauth/mod.rs
3d40febfbaf38ca2725630eed6b33106e353086081ea811107e4ec9d24f7de11 src/tinyauth/tests.rs 3d40febfbaf38ca2725630eed6b33106e353086081ea811107e4ec9d24f7de11 src/tinyauth/tests.rs
@@ -594,8 +595,6 @@ e5f5fbe702f66bfcbcbc1d1f3cd3d89bdbb929bb86aed94868a2a06a4b9e59e3 src/web_server
9e584eb4455a18641c2c89f9e9725745c93f32877abf0f0f2fbea9e3d5ef38c3 src/web_server/security.rs 9e584eb4455a18641c2c89f9e9725745c93f32877abf0f0f2fbea9e3d5ef38c3 src/web_server/security.rs
b791762b4ab7a43c3be19df84e523faf3dfb4df055f66d02178f93edb60d2204 src/web_server/serve.rs b791762b4ab7a43c3be19df84e523faf3dfb4df055f66d02178f93edb60d2204 src/web_server/serve.rs
714418c86ab241020a561fcf662a8fe324a6a70cc2fd3a313c56d7939c14b9e8 src/web_server/tests.rs 714418c86ab241020a561fcf662a8fe324a6a70cc2fd3a313c56d7939c14b9e8 src/web_server/tests.rs
7ecfc4a2b83d88e579be72abded564db7519f97fbb5790d399c73ce903829afd tests/browser/cache_rules_import_smoke.py
defef98203781970ecc18ac2d862c8660b8a379e8ba465dccc21a3b6170a30e3 tests/browser/cache_rules_tester_smoke.py
f00743af2cf4a5952caef7a1dcf68e7817b5599a252a9973e1c22045517c0b0e tests/fixtures/argon2id.json f00743af2cf4a5952caef7a1dcf68e7817b5599a252a9973e1c22045517c0b0e tests/fixtures/argon2id.json
cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30 third_party/swagger-ui-5.33.1/LICENSE cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30 third_party/swagger-ui-5.33.1/LICENSE
0d20d1adef18aee3f40dd258172155521ce702ac445cb5f7b7d60ed32dad2fb2 third_party/swagger-ui-5.33.1/NOTICE 0d20d1adef18aee3f40dd258172155521ce702ac445cb5f7b7d60ed32dad2fb2 third_party/swagger-ui-5.33.1/NOTICE
+2 -4
View File
@@ -1,6 +1,6 @@
# VCL import: supported instructions and exact effects # VCL import: supported instructions and exact effects
This guide describes the VCL **subset implemented by RustProxy 0.38.10**, not the full Varnish Configuration Language. It is based on the VCL importer and cache-rule engine. Importing VCL **converts statements into graphical cache rules (which must then be saved)**; RustProxy does not execute arbitrary VCL text at request time. Unsupported instructions may be skipped with warnings or cause a parse error; they are not executed as Varnish code. **In the graphical importer, warnings pause conversion:** no rules are added until you explicitly choose **Add partial import (reviewed)**. Even after adding, you must separately save the configuration. The read-only VCL export is a human-oriented preview, **not** a lossless backup or a guaranteed re-importable VCL program. This guide describes the VCL **subset implemented by RustProxy 0.39.0**, not the full Varnish Configuration Language. It is based on the VCL importer and cache-rule engine. Importing VCL **converts statements into graphical cache rules (which must then be saved)**; RustProxy does not execute arbitrary VCL text at request time. Unsupported instructions may be skipped with warnings or cause a parse error; they are not executed as Varnish code. **In the graphical importer, warnings pause conversion:** no rules are added until you explicitly choose **Add partial import (reviewed)**. Even after adding, you must separately save the configuration. The read-only VCL export is a human-oriented preview, **not** a lossless backup or a guaranteed re-importable VCL program.
For a short operational reference inside the panel, open **Cache & VCL guide** from **Settings → Cache**, the ordinary **Vhost → Cache** editor or **Docker vhosts → Cache**. The same modal works in all three places; example VCL is pasted into the importer of the editor that opened the guide, and the modal labels that scope. The modal shows the current compatibility-mode, fallback-TTL and grace settings, explains `Vary` and header mutations with examples, and identifies unsupported Varnish hooks. It complements this exact syntax reference; it does not execute VCL or save settings. For a short operational reference inside the panel, open **Cache & VCL guide** from **Settings → Cache**, the ordinary **Vhost → Cache** editor or **Docker vhosts → Cache**. The same modal works in all three places; example VCL is pasted into the importer of the editor that opened the guide, and the modal labels that scope. The modal shows the current compatibility-mode, fallback-TTL and grace settings, explains `Vary` and header mutations with examples, and identifies unsupported Varnish hooks. It complements this exact syntax reference; it does not execute VCL or save settings.
@@ -152,7 +152,7 @@ Use `unset req.http.Cookie;` only when the origin does not need **any** cookies
- `varnish_compatible=true` and positive `cache.default_ttl_seconds` (or an explicit positive `set beresp.ttl`) may treat an otherwise eligible origin `Cache-Control: no-cache` as fresh for that TTL, **without requiring `public`**. This is RustProxy's configured override, **not** vanilla Varnish's built-in behavior. - `varnish_compatible=true` and positive `cache.default_ttl_seconds` (or an explicit positive `set beresp.ttl`) may treat an otherwise eligible origin `Cache-Control: no-cache` as fresh for that TTL, **without requiring `public`**. This is RustProxy's configured override, **not** vanilla Varnish's built-in behavior.
- `varnish_compatible=false` honors `no-cache` revalidation, including when a TTL action is present. An explicit *backend header rewrite* removing `no-cache` changes the response policy in both modes; that is a different and potentially unsafe operation. - `varnish_compatible=false` honors `no-cache` revalidation, including when a TTL action is present. An explicit *backend header rewrite* removing `no-cache` changes the response policy in both modes; that is a different and potentially unsafe operation.
- Backend `private`, `no-store`, `Set-Cookie`, malformed `Vary`, unsupported status, invalid headers and size bounds still block storage **unless an administrator explicitly rewrites the affected cache-policy headers via trusted rules**. Client/request restrictions remain separate. - Backend `private`, `no-store`, `Set-Cookie`, malformed `Vary`, unsupported status, invalid headers and size bounds still block storage **unless an administrator explicitly rewrites the affected cache-policy headers via trusted rules**. Client/request restrictions remain separate.
- **Only HTTP 200 origin responses are storable in RustProxy 0.38.10.** Setting `beresp.ttl` for `404`, `301` or `302` does not create a negative/redirect cache. The misleading 404 TTL template was removed from the graphical editor. Deliver-stage header rules can still edit those responses without making them cacheable. - **Only HTTP 200 origin responses are storable in RustProxy 0.39.0.** Setting `beresp.ttl` for `404`, `301` or `302` does not create a negative/redirect cache. The misleading 404 TTL template was removed from the graphical editor. Deliver-stage header rules can still edit those responses without making them cacheable.
- Hit-for-miss / hit-for-pass and `beresp.keep` are intentionally not imported. RustProxy already coalesces eligible misses and briefly remembers uncacheable fills for its collapse strategy, and independently retains validators for conditional revalidation. These are **not** Varnish-compatible hit-for-miss/pass objects or programmable `keep` semantics. - Hit-for-miss / hit-for-pass and `beresp.keep` are intentionally not imported. RustProxy already coalesces eligible misses and briefly remembers uncacheable fills for its collapse strategy, and independently retains validators for conditional revalidation. These are **not** Varnish-compatible hit-for-miss/pass objects or programmable `keep` semantics.
## Test an imported rule set ## Test an imported rule set
@@ -162,6 +162,4 @@ Use `unset req.http.Cookie;` only when the origin does not need **any** cookies
3. Save the rules, then send the same `GET` twice (and change one `Vary` dimension) against a real reverse-proxy vhost. Inspect `X-Cache` / `X-Cache-Reason` or `Server-Timing`, depending on enabled diagnostics, plus the **actual delivered headers**. A response can be a MISS yet remain ineligible for storage. 3. Save the rules, then send the same `GET` twice (and change one `Vary` dimension) against a real reverse-proxy vhost. Inspect `X-Cache` / `X-Cache-Reason` or `Server-Timing`, depending on enabled diagnostics, plus the **actual delivered headers**. A response can be a MISS yet remain ineligible for storage.
4. Test session cookies, `Authorization`, privacy directives, compressed variants, HIT versus BYPASS and global versus per-vhost conflicts before production. If the origin's behavior differs by a header, verify the correct `Vary` is present in both the internal storage decision and the downstream response. 4. Test session cookies, `Authorization`, privacy directives, compressed variants, HIT versus BYPASS and global versus per-vhost conflicts before production. If the origin's behavior differs by a header, verify the correct `Vary` is present in both the internal storage decision and the downstream response.
Optional front-end smoke tests (with Python Playwright and Chromium installed): `python3 tests/browser/cache_rules_import_smoke.py` and `python3 tests/browser/cache_rules_tester_smoke.py` from the project root. It exercises the **standalone browser editor** with mocked API responses, including global/per-vhost import and cancellation races; it does **not** replace real Rust integration tests for cache correctness.
See [HTTP cache](CACHE.md), [Cache API](API.md), and [Security](SECURITY.md) for cache settings and operational limits. See [HTTP cache](CACHE.md), [Cache API](API.md), and [Security](SECURITY.md) for cache settings and operational limits.
+4 -3
View File
@@ -9,9 +9,10 @@ fn os_release() -> Option<&'static str> {
VALUE VALUE
.get_or_init(|| { .get_or_init(|| {
sysinfo::System::long_os_version() sysinfo::System::long_os_version()
.ok()
.or_else(|| { .or_else(|| {
let name = sysinfo::System::name()?; let name = sysinfo::System::name().ok()?;
Some(match sysinfo::System::os_version() { Some(match sysinfo::System::os_version().ok() {
Some(version) if !version.is_empty() => format!("{name} {version}"), Some(version) if !version.is_empty() => format!("{name} {version}"),
_ => name, _ => name,
}) })
@@ -24,7 +25,7 @@ fn os_release() -> Option<&'static str> {
fn kernel_release() -> Option<&'static str> { fn kernel_release() -> Option<&'static str> {
static VALUE: std::sync::OnceLock<Option<String>> = std::sync::OnceLock::new(); static VALUE: std::sync::OnceLock<Option<String>> = std::sync::OnceLock::new();
VALUE VALUE
.get_or_init(|| sysinfo::System::kernel_version().and_then(valid_host_text)) .get_or_init(|| sysinfo::System::kernel_version().ok().and_then(valid_host_text))
.as_deref() .as_deref()
} }
+1 -1
View File
@@ -60,7 +60,7 @@ pub fn random_secret() -> String {
bytes.iter().map(|b| format!("{b:02x}")).collect() bytes.iter().map(|b| format!("{b:02x}")).collect()
} }
pub fn secret_hash(secret: &str) -> String { pub fn secret_hash(secret: &str) -> String {
format!("{:x}", Sha256::digest(secret.as_bytes())) crate::hex::encode_lower(&Sha256::digest(secret.as_bytes()))
} }
pub fn equal_secret(candidate: &str, expected: &str) -> bool { pub fn equal_secret(candidate: &str, expected: &str) -> bool {
candidate.len() == expected.len() && bool::from(candidate.as_bytes().ct_eq(expected.as_bytes())) candidate.len() == expected.len() && bool::from(candidate.as_bytes().ct_eq(expected.as_bytes()))
+2 -2
View File
@@ -454,11 +454,11 @@ fn hash_file(path: &Path) -> Result<(u64, String)> {
.context("backup input too large")?; .context("backup input too large")?;
hasher.update(&buffer[..read]); hasher.update(&buffer[..read]);
} }
Ok((size, format!("{:x}", hasher.finalize()))) Ok((size, crate::hex::encode_lower(&hasher.finalize())))
} }
fn hash_bytes(bytes: &[u8]) -> String { fn hash_bytes(bytes: &[u8]) -> String {
format!("{:x}", Sha256::digest(bytes)) crate::hex::encode_lower(&Sha256::digest(bytes))
} }
fn excluded_directory(name: &str) -> bool { fn excluded_directory(name: &str) -> bool {
+1 -1
View File
@@ -80,7 +80,7 @@ fn copy_snapshot_file(source: &Path, target: &Path) -> Result<(u64, String)> {
"durable file changed while backup snapshot was being captured: {}", "durable file changed while backup snapshot was being captured: {}",
source.display() source.display()
); );
Ok((size, format!("{:x}", hasher.finalize()))) Ok((size, crate::hex::encode_lower(&hasher.finalize())))
} }
fn symlink_target_bytes(target: &Path) -> Result<Vec<u8>> { fn symlink_target_bytes(target: &Path) -> Result<Vec<u8>> {
+1 -1
View File
@@ -224,7 +224,7 @@ fn extract_inner_archive(path: &Path, stage: &Path) -> Result<(Manifest, Vec<u8>
} }
} }
ensure!( ensure!(
format!("{:x}", hasher.finalize()) == expected.sha256, crate::hex::encode_lower(&hasher.finalize()) == expected.sha256,
"backup entry checksum mismatch" "backup entry checksum mismatch"
); );
} }
+333 -73
View File
@@ -32,7 +32,10 @@ mod cache_rules_tests {
let rules = CompiledRules::compile("shop", &[], &global, false).unwrap(); let rules = CompiledRules::compile("shop", &[], &global, false).unwrap();
for path in ["/app.css", "/theme/app.CSS", "/bundle.js"] { for path in ["/app.css", "/theme/app.CSS", "/bundle.js"] {
assert_eq!( assert_eq!(
rules.evaluate_request(&request(path, None, &[]), false).pass.as_deref(), rules
.evaluate_request(&request(path, None, &[]), false)
.pass
.as_deref(),
Some("assets"), Some("assets"),
"{path}" "{path}"
); );
@@ -346,8 +349,14 @@ sub vcl_deliver {
.find(|rule| rule.actions.contains(&RuleAction::Ttl { seconds: 3600 })) .find(|rule| rule.actions.contains(&RuleAction::Ttl { seconds: 3600 }))
.unwrap(); .unwrap();
assert!(else_rule.conditions[0].negate); assert!(else_rule.conditions[0].negate);
assert!(imported.warnings.iter().any(|warning| warning.contains("regsuball(req.url"))); assert!(imported
assert!(imported.warnings.iter().any(|warning| warning.contains("empty values"))); .warnings
.iter()
.any(|warning| warning.contains("regsuball(req.url")));
assert!(imported
.warnings
.iter()
.any(|warning| warning.contains("empty values")));
assert!(imported assert!(imported
.warnings .warnings
.iter() .iter()
@@ -360,9 +369,46 @@ sub vcl_deliver {
assert!(import_vcl("vcl 4.1;").is_err()); assert!(import_vcl("vcl 4.1;").is_err());
} }
#[test]
fn unsupported_vcl_return_does_not_hide_unsupported_condition() {
let imported = import_vcl(
r#"
sub vcl_recv {
if (client.ip ~ purgers) { return(purge); }
if (req.url ~ "^/public") { return(pass); }
}
"#,
)
.unwrap();
assert!(
imported
.warnings
.iter()
.any(|warning| warning.contains("client.ip")),
"{:?}",
imported.warnings
);
assert!(
imported
.warnings
.iter()
.any(|warning| warning.contains("return (purge)")),
"{:?}",
imported.warnings
);
assert_eq!(
imported.rules.len(),
1,
"unsupported VCL must not create executable rules"
);
validate_rules(&imported.rules, true).unwrap();
assert!(imported.rules[0].actions.contains(&RuleAction::Pass));
}
#[test] #[test]
fn imported_vcl_cookie_pass_and_hash_stages_obey_terminal_returns() { fn imported_vcl_cookie_pass_and_hash_stages_obey_terminal_returns() {
let imported = import_vcl(r#" let imported = import_vcl(
r#"
vcl 4.1; vcl 4.1;
sub vcl_recv { sub vcl_recv {
if (req.http.Cookie ~ "sid=") { return(pass); } if (req.http.Cookie ~ "sid=") { return(pass); }
@@ -370,14 +416,19 @@ sub vcl_deliver {
return(hash); return(hash);
} }
sub vcl_hash { hash_data(req.http.Cookie); } sub vcl_hash { hash_data(req.http.Cookie); }
"#).unwrap(); "#,
)
.unwrap();
assert!(imported.warnings.is_empty(), "{:?}", imported.warnings); assert!(imported.warnings.is_empty(), "{:?}", imported.warnings);
let compiled = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap(); let compiled = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap();
let session = request("/home", None, &[("cookie", "sid=123; lang=pl")]); let session = request("/home", None, &[("cookie", "sid=123; lang=pl")]);
let session_out = compiled.evaluate_request(&session, false); let session_out = compiled.evaluate_request(&session, false);
assert!(session_out.pass.is_some()); assert!(session_out.pass.is_some());
assert!(session_out.lookup.is_none()); assert!(session_out.lookup.is_none());
assert!(session_out.hash.is_empty(), "vcl_hash cannot run after pass"); assert!(
session_out.hash.is_empty(),
"vcl_hash cannot run after pass"
);
let language = request("/home", None, &[("cookie", "lang=pl")]); let language = request("/home", None, &[("cookie", "lang=pl")]);
let out = compiled.evaluate_request(&language, false); let out = compiled.evaluate_request(&language, false);
assert!(out.pass.is_none()); assert!(out.pass.is_none());
@@ -385,29 +436,65 @@ sub vcl_deliver {
assert_eq!(out.hash_variant(), "h:cookie=lang=pl"); assert_eq!(out.hash_variant(), "h:cookie=lang=pl");
let mut compatible = Settings::default(); let mut compatible = Settings::default();
assert_eq!( assert_eq!(
request_policy_with_vcl_cookie(&Method::GET, &language.headers, true, "/home", false, &compatible, true), request_policy_with_vcl_cookie(
&Method::GET,
&language.headers,
true,
"/home",
false,
&compatible,
true
),
RequestPolicy::Use RequestPolicy::Use
); );
assert_eq!( assert_eq!(
request_policy(&Method::GET, &language.headers, true, "/home", false, &compatible), request_policy(
&Method::GET,
&language.headers,
true,
"/home",
false,
&compatible
),
RequestPolicy::Bypass("request_cookie") RequestPolicy::Bypass("request_cookie")
); );
compatible.varnish_compatible = false; compatible.varnish_compatible = false;
assert_eq!( assert_eq!(
request_policy_with_vcl_cookie(&Method::GET, &language.headers, true, "/home", false, &compatible, true), request_policy_with_vcl_cookie(
&Method::GET,
&language.headers,
true,
"/home",
false,
&compatible,
true
),
RequestPolicy::Bypass("request_cookie") RequestPolicy::Bypass("request_cookie")
); );
let with_authorization = request("/home", None, &[("cookie", "lang=pl"), ("authorization", "Basic user")]); let with_authorization = request(
"/home",
None,
&[("cookie", "lang=pl"), ("authorization", "Basic user")],
);
compatible.varnish_compatible = true; compatible.varnish_compatible = true;
assert_eq!( assert_eq!(
request_policy_with_vcl_cookie(&Method::GET, &with_authorization.headers, true, "/home", false, &compatible, true), request_policy_with_vcl_cookie(
&Method::GET,
&with_authorization.headers,
true,
"/home",
false,
&compatible,
true
),
RequestPolicy::Bypass("request_authorization") RequestPolicy::Bypass("request_authorization")
); );
} }
#[test] #[test]
fn imported_vcl_nested_elsif_else_and_earlier_cookie_unset_are_visible() { fn imported_vcl_nested_elsif_else_and_earlier_cookie_unset_are_visible() {
let imported = import_vcl(r#" let imported = import_vcl(
r#"
sub vcl_recv { sub vcl_recv {
if (req.url ~ "^/static") { if (req.url ~ "^/static") {
unset req.http.Cookie; unset req.http.Cookie;
@@ -416,7 +503,9 @@ sub vcl_deliver {
} elsif (req.url ~ "^/private") { return(pass); } } elsif (req.url ~ "^/private") { return(pass); }
else { return(hash); } else { return(hash); }
} }
"#).unwrap(); "#,
)
.unwrap();
assert!(imported.warnings.is_empty(), "{:?}", imported.warnings); assert!(imported.warnings.is_empty(), "{:?}", imported.warnings);
let compiled = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap(); let compiled = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap();
let asset = request("/static/index.html", None, &[("cookie", "lang=pl; sid=7")]); let asset = request("/static/index.html", None, &[("cookie", "lang=pl; sid=7")]);
@@ -426,13 +515,20 @@ sub vcl_deliver {
let mut headers = asset.headers.clone(); let mut headers = asset.headers.clone();
matched.rewrite_cookies(&mut headers); matched.rewrite_cookies(&mut headers);
assert!(!headers.contains_key("cookie")); assert!(!headers.contains_key("cookie"));
assert!(compiled.evaluate_request(&request("/private/a", None, &[]), false).pass.is_some()); assert!(compiled
assert!(compiled.evaluate_request(&request("/other", None, &[]), false).lookup.is_some()); .evaluate_request(&request("/private/a", None, &[]), false)
.pass
.is_some());
assert!(compiled
.evaluate_request(&request("/other", None, &[]), false)
.lookup
.is_some());
} }
#[test] #[test]
fn imported_backend_header_edits_change_policy_before_cache_admission() { fn imported_backend_header_edits_change_policy_before_cache_admission() {
let imported = import_vcl(r#" let imported = import_vcl(
r#"
sub vcl_backend_response { sub vcl_backend_response {
unset beresp.http.Cache-Control; unset beresp.http.Cache-Control;
set beresp.http.Cache-Control = "public, max-age=77"; set beresp.http.Cache-Control = "public, max-age=77";
@@ -440,70 +536,121 @@ sub vcl_deliver {
set beresp.ttl = 88s; set beresp.ttl = 88s;
} }
} }
"#).unwrap(); "#,
)
.unwrap();
assert!(imported.warnings.is_empty(), "{:?}", imported.warnings); assert!(imported.warnings.is_empty(), "{:?}", imported.warnings);
let compiled = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap(); let compiled = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap();
let mut response = HeaderMap::new(); let mut response = HeaderMap::new();
response.insert("cache-control", HeaderValue::from_static("private, no-store")); response.insert(
let out = compiled.evaluate_response(&request("/", None, &[]), StatusCode::OK, &response, false); "cache-control",
HeaderValue::from_static("private, no-store"),
);
let out =
compiled.evaluate_response(&request("/", None, &[]), StatusCode::OK, &response, false);
assert_eq!(out.overrides.ttl, Some(88)); assert_eq!(out.overrides.ttl, Some(88));
out.overrides.apply_headers(&mut response); out.overrides.apply_headers(&mut response);
assert_eq!(response["cache-control"], "public, max-age=77"); assert_eq!(response["cache-control"], "public, max-age=77");
let strict = Settings {varnish_compatible: false, ..Default::default()}; let strict = Settings {
assert!(plan_with(StatusCode::OK, &response, &strict, std::time::Duration::ZERO, &out.overrides).is_some()); varnish_compatible: false,
..Default::default()
};
assert!(plan_with(
StatusCode::OK,
&response,
&strict,
std::time::Duration::ZERO,
&out.overrides
)
.is_some());
} }
#[test] #[test]
fn vhost_backend_header_wins_and_subsequent_rule_sees_mutation() { fn vhost_backend_header_wins_and_subsequent_rule_sees_mutation() {
let local = vec![ let local = vec![
rule(serde_json::json!({"id":"local", "stage":"response", "actions":[{"type":"set_backend_header","name":"Cache-Control","value":"public, max-age=120"}]})), rule(
rule(serde_json::json!({"id":"local-second", "stage":"response", "conditions":[{"field":"response_header","name":"Cache-Control","operator":"equals","values":["public, max-age=120"]}], "actions":[{"type":"ttl","seconds":125}]})), serde_json::json!({"id":"local", "stage":"response", "actions":[{"type":"set_backend_header","name":"Cache-Control","value":"public, max-age=120"}]}),
),
rule(
serde_json::json!({"id":"local-second", "stage":"response", "conditions":[{"field":"response_header","name":"Cache-Control","operator":"equals","values":["public, max-age=120"]}], "actions":[{"type":"ttl","seconds":125}]}),
),
]; ];
let global = vec![rule(serde_json::json!({"id":"global", "stage":"response", "actions":[{"type":"remove_backend_header","name":"Cache-Control"}, {"type":"ttl","seconds":5}]}))]; let global = vec![rule(
serde_json::json!({"id":"global", "stage":"response", "actions":[{"type":"remove_backend_header","name":"Cache-Control"}, {"type":"ttl","seconds":5}]}),
)];
let compiled = CompiledRules::compile("shop", &local, &global, false).unwrap(); let compiled = CompiledRules::compile("shop", &local, &global, false).unwrap();
let original = HeaderMap::new(); let original = HeaderMap::new();
let outcome = compiled.evaluate_response(&request("/", None, &[]), StatusCode::OK, &original, false); let outcome =
compiled.evaluate_response(&request("/", None, &[]), StatusCode::OK, &original, false);
let mut rewritten = original; let mut rewritten = original;
outcome.overrides.apply_headers(&mut rewritten); outcome.overrides.apply_headers(&mut rewritten);
assert_eq!(rewritten["cache-control"], "public, max-age=120"); assert_eq!(rewritten["cache-control"], "public, max-age=120");
assert_eq!(outcome.overrides.ttl, Some(125)); assert_eq!(outcome.overrides.ttl, Some(125));
assert!(outcome.overridden.iter().any(|entry| entry.ignored == "global:global")); assert!(outcome
.overridden
.iter()
.any(|entry| entry.ignored == "global:global"));
} }
#[test] #[test]
fn vhost_delivery_mutations_remain_ordered_and_global_cannot_unset() { fn vhost_delivery_mutations_remain_ordered_and_global_cannot_unset() {
let local = vec![ let local = vec![
rule(serde_json::json!({"id":"first", "stage":"deliver", "actions":[{"type":"set_header","name":"X-Decision","value":"first"}]})), rule(
rule(serde_json::json!({"id":"second", "stage":"deliver", "conditions":[{"field":"response_header","name":"X-Decision","operator":"equals","values":["first"]}], "actions":[{"type":"remove_header","name":"X-Decision"}, {"type":"default_header","name":"X-Decision","value":"second"}]})), serde_json::json!({"id":"first", "stage":"deliver", "actions":[{"type":"set_header","name":"X-Decision","value":"first"}]}),
),
rule(
serde_json::json!({"id":"second", "stage":"deliver", "conditions":[{"field":"response_header","name":"X-Decision","operator":"equals","values":["first"]}], "actions":[{"type":"remove_header","name":"X-Decision"}, {"type":"default_header","name":"X-Decision","value":"second"}]}),
),
]; ];
let global = vec![rule(serde_json::json!({"id":"global", "stage":"deliver", "actions":[{"type":"remove_header","name":"X-Decision"}]}))]; let global = vec![rule(
serde_json::json!({"id":"global", "stage":"deliver", "actions":[{"type":"remove_header","name":"X-Decision"}]}),
)];
let compiled = CompiledRules::compile("shop", &local, &global, false).unwrap(); let compiled = CompiledRules::compile("shop", &local, &global, false).unwrap();
let mut headers = HeaderMap::new(); let mut headers = HeaderMap::new();
let outcome = compiled.evaluate_deliver(&request("/", None, &[]), StatusCode::OK, &headers, false); let outcome =
compiled.evaluate_deliver(&request("/", None, &[]), StatusCode::OK, &headers, false);
outcome.apply(&mut headers); outcome.apply(&mut headers);
assert_eq!(headers["x-decision"], "second"); assert_eq!(headers["x-decision"], "second");
} }
#[test] #[test]
fn imported_terminal_deliver_does_not_run_following_rules() { fn imported_terminal_deliver_does_not_run_following_rules() {
let imported = import_vcl(r#" let imported = import_vcl(
r#"
sub vcl_deliver { sub vcl_deliver {
if (req.url ~ "^/private") { return(deliver); } if (req.url ~ "^/private") { return(deliver); }
set resp.http.X-Later = "yes"; set resp.http.X-Later = "yes";
} }
"#).unwrap(); "#,
)
.unwrap();
assert!(imported.warnings.is_empty(), "{:?}", imported.warnings); assert!(imported.warnings.is_empty(), "{:?}", imported.warnings);
let compiled = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap(); let compiled = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap();
let mut response = HeaderMap::new(); let mut response = HeaderMap::new();
compiled.evaluate_deliver(&request("/private", None, &[]), StatusCode::OK, &response, false).apply(&mut response); compiled
.evaluate_deliver(
&request("/private", None, &[]),
StatusCode::OK,
&response,
false,
)
.apply(&mut response);
assert!(!response.contains_key("x-later")); assert!(!response.contains_key("x-later"));
compiled.evaluate_deliver(&request("/public", None, &[]), StatusCode::OK, &response, false).apply(&mut response); compiled
.evaluate_deliver(
&request("/public", None, &[]),
StatusCode::OK,
&response,
false,
)
.apply(&mut response);
assert_eq!(response["x-later"], "yes"); assert_eq!(response["x-later"], "yes");
} }
#[test] #[test]
fn vcl_request_header_edits_are_visible_to_later_guards_hash_and_origin() { fn vcl_request_header_edits_are_visible_to_later_guards_hash_and_origin() {
let imported = import_vcl(r#" let imported = import_vcl(
r#"
sub vcl_recv { sub vcl_recv {
set req.http.X-Device = "mobile"; set req.http.X-Device = "mobile";
if (req.http.X-Device == "mobile") { if (req.http.X-Device == "mobile") {
@@ -512,10 +659,16 @@ sub vcl_deliver {
} }
} }
sub vcl_hash { hash_data(req.http.X-Device); } sub vcl_hash { hash_data(req.http.X-Device); }
"#).unwrap(); "#,
)
.unwrap();
assert!(imported.warnings.is_empty(), "{:?}", imported.warnings); assert!(imported.warnings.is_empty(), "{:?}", imported.warnings);
let compiled = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap(); let compiled = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap();
let original = request("/catalog", None, &[("x-tracking", "secret"), ("cookie", "lang=pl")]); let original = request(
"/catalog",
None,
&[("x-tracking", "secret"), ("cookie", "lang=pl")],
);
let outcome = compiled.evaluate_request(&original, false); let outcome = compiled.evaluate_request(&original, false);
assert!(outcome.pass.is_none()); assert!(outcome.pass.is_none());
assert!(outcome.lookup.is_some()); assert!(outcome.lookup.is_some());
@@ -557,22 +710,34 @@ sub vcl_deliver {
#[test] #[test]
fn unsafe_request_edits_are_rejected_without_discarding_valid_neighbors() { fn unsafe_request_edits_are_rejected_without_discarding_valid_neighbors() {
for name in ["Authorization", "Cookie", "Cache-Control", "X-Forwarded-For", "If-None-Match", "Host", "Content-Length"] { for name in [
"Authorization",
"Cookie",
"Cache-Control",
"X-Forwarded-For",
"If-None-Match",
"Host",
"Content-Length",
] {
let rules = vec![rule(serde_json::json!({ let rules = vec![rule(serde_json::json!({
"id": "unsafe", "actions": [{"type":"remove_request_header", "name":name}] "id": "unsafe", "actions": [{"type":"remove_request_header", "name":name}]
}))]; }))];
assert!(validate_rules(&rules, true).is_err(), "must protect {name}"); assert!(validate_rules(&rules, true).is_err(), "must protect {name}");
} }
let imported = import_vcl(r#" let imported = import_vcl(
r#"
sub vcl_recv { sub vcl_recv {
set req.http.X-Safe = "one"; set req.http.X-Safe = "one";
unset req.http.Authorization; unset req.http.Authorization;
set req.http.X-Safe = "two"; set req.http.X-Safe = "two";
} }
"#).unwrap(); "#,
)
.unwrap();
assert_eq!(imported.warnings.len(), 1, "{:?}", imported.warnings); assert_eq!(imported.warnings.len(), 1, "{:?}", imported.warnings);
let compiled = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap(); let compiled = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap();
let outcome = compiled.evaluate_request(&request("/", None, &[("authorization", "Bearer x")]), false); let outcome =
compiled.evaluate_request(&request("/", None, &[("authorization", "Bearer x")]), false);
let mut headers = HeaderMap::new(); let mut headers = HeaderMap::new();
headers.insert("authorization", HeaderValue::from_static("Bearer x")); headers.insert("authorization", HeaderValue::from_static("Bearer x"));
outcome.apply_headers(&mut headers); outcome.apply_headers(&mut headers);
@@ -582,57 +747,108 @@ sub vcl_deliver {
#[test] #[test]
fn uncacheable_false_reverses_only_previous_rule_no_store() { fn uncacheable_false_reverses_only_previous_rule_no_store() {
let imported = import_vcl(r#" let imported = import_vcl(
r#"
sub vcl_backend_response { sub vcl_backend_response {
set beresp.uncacheable = true; set beresp.uncacheable = true;
set beresp.uncacheable = false; set beresp.uncacheable = false;
set beresp.ttl = 60s; set beresp.ttl = 60s;
} }
"#).unwrap(); "#,
)
.unwrap();
assert!(imported.warnings.is_empty(), "{:?}", imported.warnings); assert!(imported.warnings.is_empty(), "{:?}", imported.warnings);
let compiled = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap(); let compiled = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap();
let mut response = HeaderMap::new(); let mut response = HeaderMap::new();
response.insert("cache-control", HeaderValue::from_static("max-age=30")); response.insert("cache-control", HeaderValue::from_static("max-age=30"));
let outcome = compiled.evaluate_response(&request("/", None, &[]), StatusCode::OK, &response, false); let outcome =
compiled.evaluate_response(&request("/", None, &[]), StatusCode::OK, &response, false);
assert!(!outcome.overrides.no_store); assert!(!outcome.overrides.no_store);
assert_eq!(outcome.overrides.ttl, Some(60)); assert_eq!(outcome.overrides.ttl, Some(60));
let strict = Settings { varnish_compatible: false, ..Default::default() }; let strict = Settings {
assert!(plan_with(StatusCode::OK, &response, &strict, std::time::Duration::ZERO, &outcome.overrides).is_some()); varnish_compatible: false,
response.insert("cache-control", HeaderValue::from_static("private, no-store")); ..Default::default()
assert!(plan_with(StatusCode::OK, &response, &strict, std::time::Duration::ZERO, &outcome.overrides).is_none()); };
assert!(plan_with(
StatusCode::OK,
&response,
&strict,
std::time::Duration::ZERO,
&outcome.overrides
)
.is_some());
response.insert(
"cache-control",
HeaderValue::from_static("private, no-store"),
);
assert!(plan_with(
StatusCode::OK,
&response,
&strict,
std::time::Duration::ZERO,
&outcome.overrides
)
.is_none());
response.remove("cache-control"); response.remove("cache-control");
response.insert("set-cookie", HeaderValue::from_static("sid=1")); response.insert("set-cookie", HeaderValue::from_static("sid=1"));
assert!(plan_with(StatusCode::OK, &response, &strict, std::time::Duration::ZERO, &outcome.overrides).is_none()); assert!(plan_with(
StatusCode::OK,
&response,
&strict,
std::time::Duration::ZERO,
&outcome.overrides
)
.is_none());
} }
#[test] #[test]
fn vhost_allow_store_overrides_global_no_store() { fn vhost_allow_store_overrides_global_no_store() {
let local = vec![rule(serde_json::json!({"id":"local-store", "stage":"response", "actions":[{"type":"allow_store"}]}))]; let local = vec![rule(
let global = vec![rule(serde_json::json!({"id":"global-store", "stage":"response", "actions":[{"type":"no_store"}]}))]; serde_json::json!({"id":"local-store", "stage":"response", "actions":[{"type":"allow_store"}]}),
)];
let global = vec![rule(
serde_json::json!({"id":"global-store", "stage":"response", "actions":[{"type":"no_store"}]}),
)];
let rules = CompiledRules::compile("shop", &local, &global, false).unwrap(); let rules = CompiledRules::compile("shop", &local, &global, false).unwrap();
let outcome = rules.evaluate_response(&request("/", None, &[]), StatusCode::OK, &HeaderMap::new(), false); let outcome = rules.evaluate_response(
&request("/", None, &[]),
StatusCode::OK,
&HeaderMap::new(),
false,
);
assert!(!outcome.overrides.no_store); assert!(!outcome.overrides.no_store);
assert!(outcome.overridden.iter().any(|entry| entry.aspect == "store" && entry.ignored == "global:global-store")); assert!(outcome
.overridden
.iter()
.any(|entry| entry.aspect == "store" && entry.ignored == "global:global-store"));
} }
#[test] #[test]
fn unsupported_url_regex_is_warned_not_misconverted_to_query_removal() { fn unsupported_url_regex_is_warned_not_misconverted_to_query_removal() {
let imported = import_vcl(r#" let imported = import_vcl(
r#"
sub vcl_recv { sub vcl_recv {
set req.url = regsub(req.url, "^/utm_foo", "/other"); set req.url = regsub(req.url, "^/utm_foo", "/other");
set req.url = regsuball(req.url, "^/utm_foo", "\\1"); set req.url = regsuball(req.url, "^/utm_foo", "\\1");
set req.url = regsuball(req.url, "(\\?|&)(utm_foo)=[^&]*", "deleted"); set req.url = regsuball(req.url, "(\\?|&)(utm_foo)=[^&]*", "deleted");
} }
"#).unwrap(); "#,
assert!(imported.rules.is_empty(), "unsupported VCL must never strip unrelated query parameters"); )
.unwrap();
assert!(
imported.rules.is_empty(),
"unsupported VCL must never strip unrelated query parameters"
);
assert_eq!(imported.warnings.len(), 3, "{:?}", imported.warnings); assert_eq!(imported.warnings.len(), 3, "{:?}", imported.warnings);
} }
#[test] #[test]
fn valid_vcl_import_flushes_long_action_blocks_instead_of_dropping_them() { fn valid_vcl_import_flushes_long_action_blocks_instead_of_dropping_them() {
let mut source = String::from("sub vcl_recv {\n"); let mut source = String::from("sub vcl_recv {\n");
for id in 1..=20 { source.push_str(&format!("set req.http.X-Rule-{id} = \"ok\";\n")); } for id in 1..=20 {
source.push_str("}"); source.push_str(&format!("set req.http.X-Rule-{id} = \"ok\";\n"));
}
source.push('}');
let imported = import_vcl(&source).unwrap(); let imported = import_vcl(&source).unwrap();
assert!(imported.warnings.is_empty(), "{:?}", imported.warnings); assert!(imported.warnings.is_empty(), "{:?}", imported.warnings);
let rules = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap(); let rules = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap();
@@ -645,7 +861,8 @@ sub vcl_deliver {
#[test] #[test]
fn vcl_builtin_hash_fields_are_already_in_rustproxy_key() { fn vcl_builtin_hash_fields_are_already_in_rustproxy_key() {
let imported = import_vcl(r#" let imported = import_vcl(
r#"
sub vcl_recv { sub vcl_recv {
set req.http.X-Device = "mobile"; set req.http.X-Device = "mobile";
return(hash); return(hash);
@@ -656,7 +873,9 @@ sub vcl_deliver {
hash_data(req.http.X-Device); hash_data(req.http.X-Device);
return(lookup); return(lookup);
} }
"#).unwrap(); "#,
)
.unwrap();
assert!(imported.warnings.is_empty(), "{:?}", imported.warnings); assert!(imported.warnings.is_empty(), "{:?}", imported.warnings);
validate_rules(&imported.rules, true).unwrap(); validate_rules(&imported.rules, true).unwrap();
let rules = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap(); let rules = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap();
@@ -669,28 +888,40 @@ sub vcl_deliver {
#[test] #[test]
fn vcl_quoted_strings_support_escaped_quotes_and_backslashes() { fn vcl_quoted_strings_support_escaped_quotes_and_backslashes() {
let imported = import_vcl(r#" let imported = import_vcl(
r#"
sub vcl_recv { sub vcl_recv {
set req.http.X-Note = "quote: \" and slash: \\"; set req.http.X-Note = "quote: \" and slash: \\";
} }
sub vcl_deliver { sub vcl_deliver {
set resp.http.X-Note = "a \"quote\" and a \\ slash"; set resp.http.X-Note = "a \"quote\" and a \\ slash";
} }
"#).unwrap(); "#,
)
.unwrap();
assert!(imported.warnings.is_empty(), "{:?}", imported.warnings); assert!(imported.warnings.is_empty(), "{:?}", imported.warnings);
let rules = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap(); let rules = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap();
let mut headers = HeaderMap::new(); let mut headers = HeaderMap::new();
rules.evaluate_request(&request("/", None, &[]), false).apply_headers(&mut headers); rules
.evaluate_request(&request("/", None, &[]), false)
.apply_headers(&mut headers);
assert_eq!(headers["x-note"], "quote: \" and slash: \\"); assert_eq!(headers["x-note"], "quote: \" and slash: \\");
let mut response_headers = HeaderMap::new(); let mut response_headers = HeaderMap::new();
rules.evaluate_deliver(&request("/", None, &[]), StatusCode::OK, &response_headers, false) rules
.evaluate_deliver(
&request("/", None, &[]),
StatusCode::OK,
&response_headers,
false,
)
.apply(&mut response_headers); .apply(&mut response_headers);
assert_eq!(response_headers["x-note"], "a \"quote\" and a \\ slash"); assert_eq!(response_headers["x-note"], "a \"quote\" and a \\ slash");
} }
#[test] #[test]
fn malformed_vcl_statements_are_warned_and_do_not_apply_partial_actions() { fn malformed_vcl_statements_are_warned_and_do_not_apply_partial_actions() {
let imported = import_vcl(r#" let imported = import_vcl(
r#"
sub vcl_recv { sub vcl_recv {
return(hash, pass); return(hash, pass);
hash_data(req.http.X-Should-Not-Hash); hash_data(req.http.X-Should-Not-Hash);
@@ -710,20 +941,49 @@ sub vcl_deliver {
unset resp.http.Vary extra; unset resp.http.Vary extra;
unset resp.http.X-Trace; unset resp.http.X-Trace;
} }
"#).unwrap(); "#,
assert!(imported.warnings.iter().any(|warning| warning.contains("return requires")), "{:?}", imported.warnings); )
assert!(imported.warnings.iter().any(|warning| warning.contains("hash_data is only supported inside"))); .unwrap();
assert!(imported.warnings.iter().any(|warning| warning.contains("hash_data supports"))); assert!(
assert!(imported.warnings.iter().any(|warning| warning.contains("set beresp requires"))); imported
assert!(imported.warnings.iter().any(|warning| warning.contains("unset beresp requires"))); .warnings
assert!(imported.warnings.iter().any(|warning| warning.contains("unset resp requires"))); .iter()
.any(|warning| warning.contains("return requires")),
"{:?}",
imported.warnings
);
assert!(imported
.warnings
.iter()
.any(|warning| warning.contains("hash_data is only supported inside")));
assert!(imported
.warnings
.iter()
.any(|warning| warning.contains("hash_data supports")));
assert!(imported
.warnings
.iter()
.any(|warning| warning.contains("set beresp requires")));
assert!(imported
.warnings
.iter()
.any(|warning| warning.contains("unset beresp requires")));
assert!(imported
.warnings
.iter()
.any(|warning| warning.contains("unset resp requires")));
validate_rules(&imported.rules, true).unwrap(); validate_rules(&imported.rules, true).unwrap();
let rules = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap(); let rules = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap();
let outcome = rules.evaluate_request(&request("/", None, &[]), false); let outcome = rules.evaluate_request(&request("/", None, &[]), false);
assert!(outcome.pass.is_none()); assert!(outcome.pass.is_none());
assert!(outcome.lookup.is_none()); assert!(outcome.lookup.is_none());
assert_eq!(outcome.hash, vec!["h:x-allowed=yes"]); assert_eq!(outcome.hash, vec!["h:x-allowed=yes"]);
let response = rules.evaluate_response(&request("/", None, &[]), StatusCode::OK, &HeaderMap::new(), false); let response = rules.evaluate_response(
&request("/", None, &[]),
StatusCode::OK,
&HeaderMap::new(),
false,
);
assert_eq!(response.overrides.ttl, Some(30)); assert_eq!(response.overrides.ttl, Some(30));
assert!(response.overrides.header_edits.is_empty()); assert!(response.overrides.header_edits.is_empty());
} }
+15 -1
View File
@@ -865,7 +865,21 @@ impl VclBuilder {
if guards.is_empty() { break; } if guards.is_empty() { break; }
} }
} }
Err(error) => self.warnings.push(format!("line {line}: {error}")), Err(error) => {
self.warnings.push(format!("line {line}: {error}"));
// An unsupported action may be the only statement in
// a conditional block. No rule is pushed in that case,
// so validate its guards here as well; otherwise an
// unsupported condition could be silently omitted.
for guard in guards {
if let Err(error) = vcl_clauses(guard, stage, false) {
let warning = format!("line {line}: {error}");
if !self.warnings.contains(&warning) {
self.warnings.push(warning);
}
}
}
}
}, },
VclStatement::If(branches, _line) => { VclStatement::If(branches, _line) => {
if !pending.is_empty() { if !pending.is_empty() {
+1 -1
View File
@@ -503,7 +503,7 @@ fn file_digest(path: &Path, max_bytes: u64) -> Result<Option<String>> {
} }
digest.update(&buffer[..read]); digest.update(&buffer[..read]);
} }
Ok(Some(format!("{:x}", digest.finalize()))) Ok(Some(crate::hex::encode_lower(&digest.finalize())))
} }
fn copy_private(source: &Path, target: &Path, max_bytes: u64) -> Result<()> { fn copy_private(source: &Path, target: &Path, max_bytes: u64) -> Result<()> {
+1 -1
View File
@@ -185,7 +185,7 @@ async fn stream_to_file(
} }
output.flush().await?; output.flush().await?;
output.sync_all().await?; output.sync_all().await?;
let actual = format!("{:x}", digest.finalize()); let actual = crate::hex::encode_lower(&digest.finalize());
if let Some(expected) = expected_digest { if let Some(expected) = expected_digest {
ensure!( ensure!(
actual == expected, actual == expected,
+33
View File
@@ -0,0 +1,33 @@
//! Lowercase hexadecimal encoding shared by SHA-256 checksums and request IDs.
//!
//! Keep this independent of SHA-2's output type: digest 0.11 uses HybridArray,
//! which no longer implements `LowerHex` for `format!("{:x}", digest)`.
pub(crate) fn encode_lower(bytes: &[u8]) -> String {
const HEX: &[u8; 16] = b"0123456789abcdef";
let mut encoded = vec![0u8; bytes.len() * 2];
for (i, &byte) in bytes.iter().enumerate() {
encoded[2 * i] = HEX[(byte >> 4) as usize];
encoded[2 * i + 1] = HEX[(byte & 0x0f) as usize];
}
String::from_utf8(encoded).expect("hex digits are always valid UTF-8")
}
#[cfg(test)]
mod tests {
use super::encode_lower;
use sha2::{Digest, Sha256};
#[test]
fn lowercase_hex_preserves_byte_order_and_width() {
assert_eq!(encode_lower(&[]), "");
assert_eq!(
encode_lower(&[0, 1, 15, 16, 127, 128, 254, 255]),
"00010f107f80feff"
);
assert_eq!(
encode_lower(&Sha256::digest(b"abc")),
"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"
);
}
}
+1
View File
@@ -13,6 +13,7 @@ pub mod config;
pub mod db; pub mod db;
pub mod demo; pub mod demo;
pub mod headers; pub mod headers;
mod hex;
pub mod logging; pub mod logging;
pub mod metrics; pub mod metrics;
pub mod not_found; pub mod not_found;
+22 -7
View File
@@ -30,14 +30,23 @@ impl CachePlan {
} }
pub(super) fn with_vcl_cookie_lookup(mut self, allowed: bool) -> Self { pub(super) fn with_vcl_cookie_lookup(mut self, allowed: bool) -> Self {
if let Self::Enabled { vcl_cookie_lookup, .. } = &mut self { if let Self::Enabled {
vcl_cookie_lookup, ..
} = &mut self
{
*vcl_cookie_lookup = allowed; *vcl_cookie_lookup = allowed;
} }
self self
} }
pub(super) fn vcl_cookie_lookup(self) -> bool { pub(super) fn vcl_cookie_lookup(self) -> bool {
matches!(self, Self::Enabled { vcl_cookie_lookup: true, .. }) matches!(
self,
Self::Enabled {
vcl_cookie_lookup: true,
..
}
)
} }
pub(super) fn force_cache(self) -> bool { pub(super) fn force_cache(self) -> bool {
@@ -74,11 +83,17 @@ impl CachePlan {
Self::Enabled { Self::Enabled {
force_cache: true, .. force_cache: true, ..
} => crate::cache::forced_request_policy(method, headers, body_empty), } => crate::cache::forced_request_policy(method, headers, body_empty),
Self::Enabled { vcl_cookie_lookup, .. } => { Self::Enabled {
crate::cache::request_policy_with_vcl_cookie( vcl_cookie_lookup, ..
method, headers, body_empty, path, has_query, settings, vcl_cookie_lookup, } => crate::cache::request_policy_with_vcl_cookie(
) method,
} headers,
body_empty,
path,
has_query,
settings,
vcl_cookie_lookup,
),
} }
} }
} }
+1 -7
View File
@@ -7,13 +7,7 @@ fn request_id_hash(sequence: u64) -> String {
} }
fn request_id_hex(digest: &[u8]) -> String { fn request_id_hex(digest: &[u8]) -> String {
const HEX: &[u8; 16] = b"0123456789abcdef"; crate::hex::encode_lower(digest)
let mut encoded = vec![0u8; digest.len() * 2];
for (i, &byte) in digest.iter().enumerate() {
encoded[2 * i] = HEX[(byte >> 4) as usize];
encoded[2 * i + 1] = HEX[(byte & 0x0f) as usize];
}
String::from_utf8(encoded).expect("hex digits are always valid UTF-8")
} }
#[cfg(test)] #[cfg(test)]
+10 -3
View File
@@ -3,10 +3,14 @@ mod request_id_tests {
use sha2::{Digest, Sha256}; use sha2::{Digest, Sha256};
#[test] #[test]
fn hexadecimal_encoding_matches_previous_sha256_display() { fn hexadecimal_encoding_matches_standard_lowercase_hex_formatting() {
for byte in 0u8..=255 { for byte in 0u8..=255 {
let digest = Sha256::digest([byte; 32]); let digest = Sha256::digest([byte; 32]);
assert_eq!(request_id_hex(&digest), format!("{digest:x}")); let formatted = digest
.iter()
.map(|byte| format!("{byte:02x}"))
.collect::<String>();
assert_eq!(request_id_hex(&digest), formatted);
} }
assert_eq!( assert_eq!(
request_id_hex(&[0, 1, 15, 16, 127, 128, 254, 255]), request_id_hex(&[0, 1, 15, 16, 127, 128, 254, 255]),
@@ -54,7 +58,10 @@ mod request_id_tests {
let value = if candidate { let value = if candidate {
request_id_hex(black_box(&digest)) request_id_hex(black_box(&digest))
} else { } else {
format!("{:x}", black_box(&digest)) black_box(&digest)
.iter()
.map(|byte| format!("{byte:02x}"))
.collect::<String>()
}; };
black_box(value); black_box(value);
} }
+4 -2
View File
@@ -211,10 +211,12 @@ where
} }
fn collect_network_sysinfo() -> Vec<NetworkInterfaceView> { fn collect_network_sysinfo() -> Vec<NetworkInterfaceView> {
let networks = sysinfo::Networks::new_with_refreshed_list(); let Ok(networks) = sysinfo::Networks::new_with_refreshed_list() else {
return Vec::new();
};
normalize_network_interfaces(networks.iter().map(|(name, data)| { normalize_network_interfaces(networks.iter().map(|(name, data)| {
( (
name.clone(), name.to_string_lossy().into_owned(),
data.total_received(), data.total_received(),
data.total_transmitted(), data.total_transmitted(),
) )