fix(web-app-shopware): draw the showcase customer password at random

The design spec derived the showcase customer's password from the
administrator password with a bare SHA-256 (CodeQL alert 938,
js/insufficient-password-hash). The value is a plaintext password
that the spec syncs into Shopware and types into the storefront login,
so a stronger hash would still tie it to the administrator secret.
It is now 32 random bytes in hex, drawn per run and seeded before
every sign-in; the administrator password only reaches the OAuth
token request. A unit test pins that the synced and the typed
password are the same random value.

🎯 Fix: 95 %
💥 Break: 3 %
💸 Cost: –
⏱️ Time: –
🛡️ Security: 100 %
🏆 Score: 92
🚦 Gate: ✅ 90/5, cost and time <= 100, security 100 %

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5.5 committed 2026-11-11 07:29:45 +00:00
1 parent f55f207dbc
commit f2a45159f0
2 files changed
+73 -1

No files matched your search

@@ -0,0 +1,72 @@
const test = require("node:test");
const assert = require("node:assert/strict");
const crypto = require("node:crypto");
const path = require("node:path");
const PROJECT_ROOT = path.resolve(__dirname, "../../../../../../..");
const { loadInternals } = require(path.join(PROJECT_ROOT, "tests/unit/javascript/utils/internals.js"));
const BASE = "https://shop.example";
const DOTENV = {
APP_BASE_URL: BASE,
ADMIN_USERNAME: "administrator",
ADMIN_PASSWORD: "administrator-secret",
CANONICAL_DOMAIN: "shop.example",
};
const RESPONSES = {
"/api/oauth/token": { access_token: "token" },
"/api/search/sales-channel": { data: [{ id: "channel", domains: [{ url: BASE }] }] },
"/api/search/tax": { data: [{ id: "tax", taxRate: 19 }] },
"/api/search/theme": { data: [{ id: "theme" }] },
"/api/search/salutation": { data: [{ id: "salutation" }] },
"/api/_action/sync": {},
};
const passes = new Proxy(
{},
{
get: (_, matcher) => {
if (matcher === "then") return undefined;
return matcher === "not" ? passes : async () => undefined;
},
},
);
const synced = [];
const { seedShowcase, signInCustomer } = loadInternals(
path.join(PROJECT_ROOT, "roles/web-app-shopware/files/playwright/test-design.js"),
["seedShowcase", "signInCustomer"],
{
"node:crypto": { ...crypto, randomBytes: (size) => Buffer.alloc(size, 0x5a) },
"@playwright/test": { test: () => undefined, expect: () => passes },
"./personas": {
apiFetchOnion: async (_request, url, options) => {
const route = url.slice(BASE.length);
if (route === "/api/_action/sync") synced.push(options.data);
return { status: () => 200, json: async () => RESPONSES[route] };
},
decodeDotenvQuotedValue: (value) => value,
gotoOnion: async () => undefined,
normalizeBaseUrl: (value) => value,
requireDotenvValue: (_value, name) => DOTENV[name],
},
"./timeouts": { resolveTimeout: (ms) => ms },
},
{},
);
test("the showcase customer signs in with a password drawn from node:crypto, not derived from the administrator's", async () => {
await seedShowcase({});
const filled = {};
const locator = (selector) => ({
fill: async (value) => {
filled[selector] = value;
},
locator,
press: async () => undefined,
});
await signInCustomer({ locator });
const seeded = synced[0]["design-showcase-customer"].payload[0].password;
assert.match(seeded, /^(?:5a){16,}$/);
assert.equal(filled["input[name='password']"], seeded);
});