Add SRI integrity hashes for CDN scripts and replace md5 with xxh128 for cache keys

- Add integrity/crossorigin attributes to chart.js and html5-qrcode CDN scripts
- Replace md5() with hash('xxh128') for Meilisearch cache key generation (non-sensitive context)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Serreau Jovann
2026-03-26 21:06:00 +01:00
parent 1fe2c3a1d3
commit 176b70650b
3 changed files with 3 additions and 3 deletions

View File

@@ -94,7 +94,7 @@ class MeilisearchService
*/ */
public function search(string $index, string $query, array $options = []): array public function search(string $index, string $query, array $options = []): array
{ {
$cacheKey = 'ms_search_'.md5($index.$query.serialize($options)); $cacheKey = 'ms_search_'.hash('xxh128', $index.$query.serialize($options));
return $this->cache->get($cacheKey, function (ItemInterface $item) use ($index, $query, $options) { return $this->cache->get($cacheKey, function (ItemInterface $item) use ($index, $query, $options) {
$item->expiresAfter(300); $item->expiresAfter(300);

View File

@@ -134,7 +134,7 @@
</div> </div>
</div> </div>
<script src="https://cdn.jsdelivr.net/npm/chart.js@4/dist/chart.umd.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/chart.js@4/dist/chart.umd.min.js" integrity="sha384-jb8JQMbMoBUzgWatfe6COACi2ljcDdZQ2OxczGA3bGNeWe+6DChMTBJemed7ZnvJ" crossorigin="anonymous">
<script> <script>
(function() { (function() {
const labels = {{ chart_labels|json_encode|raw }}; const labels = {{ chart_labels|json_encode|raw }};

View File

@@ -10,7 +10,7 @@
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"> <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="Scanner"> <meta name="apple-mobile-web-app-title" content="Scanner">
<link rel="apple-touch-icon" href="/logo.png"> <link rel="apple-touch-icon" href="/logo.png">
<script src="https://cdn.jsdelivr.net/npm/html5-qrcode@2.3.8/html5-qrcode.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/html5-qrcode@2.3.8/html5-qrcode.min.js" integrity="sha384-c9d8RFSL+u3exBOJ4Yp3HUJXS4znl9f+z66d1y54ig+ea249SpqR+w1wyvXz/lk+" crossorigin="anonymous"></script>
<style> <style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; } *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #111827; color: #f9fafb; min-height: 100dvh; } body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #111827; color: #f9fafb; min-height: 100dvh; }