diff --git a/Cargo.lock b/Cargo.lock index 224afcf..e2ca3a9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -111,15 +111,23 @@ dependencies = [ "windows-link", ] +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + [[package]] name = "bench-support" version = "0.1.0" dependencies = [ + "base64", "cachekit", "rand 0.10.1", "rand_distr", "serde", "serde_json", + "sha2", ] [[package]] @@ -143,6 +151,15 @@ version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" +[[package]] +name = "block-buffer" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdd35008169921d80bc60d3d0ab416eecb028c4cd653352907921d95084790be" +dependencies = [ + "hybrid-array", +] + [[package]] name = "bumpalo" version = "3.19.1" @@ -266,6 +283,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a822ea5bc7590f9d40f1ba12c0dc3c2760f3482c6984db1573ad11031420831" +[[package]] +name = "const-oid" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c" + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -347,6 +370,15 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" +[[package]] +name = "crypto-common" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77727bb15fa921304124b128af125e7e3b968275d1b108b379190264f4423710" +dependencies = [ + "hybrid-array", +] + [[package]] name = "derive_arbitrary" version = "1.4.2" @@ -374,6 +406,17 @@ dependencies = [ "thousands", ] +[[package]] +name = "digest" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4850db49bf08e663084f7fb5c87d202ef91a3907271aff24a94eb97ff039153c" +dependencies = [ + "block-buffer", + "const-oid", + "crypto-common", +] + [[package]] name = "either" version = "1.15.0" @@ -501,6 +544,15 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hybrid-array" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d46837a0ed51fe95bd3b05de33cd64a1ee88fc797477ca48446872504507c5" +dependencies = [ + "typenum", +] + [[package]] name = "iana-time-zone" version = "0.1.65" @@ -1051,6 +1103,17 @@ dependencies = [ "zmij", ] +[[package]] +name = "sha2" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "446ba717509524cb3f22f17ecc096f10f4822d76ab5c0b9822c5f9c284e825f4" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "shlex" version = "1.3.0" @@ -1109,6 +1172,12 @@ dependencies = [ "serde_json", ] +[[package]] +name = "typenum" +version = "1.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40ce102ab67701b8526c123c1bab5cbe42d7040ccfd0f64af1a385808d2f43de" + [[package]] name = "unarray" version = "0.1.4" diff --git a/bench-support/Cargo.toml b/bench-support/Cargo.toml index 034ea54..068d16f 100644 --- a/bench-support/Cargo.toml +++ b/bench-support/Cargo.toml @@ -14,3 +14,10 @@ rand = "0.10.1" rand_distr = "0.6" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" + +# `sha2` + `base64` compute the inline-script CSP hash from its body +# at render time so the body and the CSP hash-source can never drift +# (the body lives in Rust, the rendered HTML is generated, the hash is +# a function of the body). Also re-used by tests to validate SRI shapes. +sha2 = "0.11" +base64 = "0.22" diff --git a/bench-support/src/bin/charts_template.css b/bench-support/src/bin/charts_template.css new file mode 100644 index 0000000..5c34ee4 --- /dev/null +++ b/bench-support/src/bin/charts_template.css @@ -0,0 +1,182 @@ +/*! + * charts.css β€” sibling stylesheet for charts.html. + * Sized to run under `style-src 'self'` with no 'unsafe-inline'. + * + * Coordinated tokens with charts.html: + * - `.no-js #loading { display: none; }` cooperates with the parser- + * blocking inline script in , which strips the `no-js` class + * before paints so JS-enabled users immediately see the + * "Loading…" placeholder. JS-disabled users keep the class and the + *