fix: enforce strong hashes in maintenance tools
This commit is contained in:
@@ -34,6 +34,18 @@ const authService = readFileSync(resolve(root, 'api/src/auth/auth.service.ts'),
|
||||
if (/passwordHash\s*===|===\s*[^\n;]*passwordHash/.test(authService)) {
|
||||
violations.push('api/src/auth/auth.service.ts: password hashes must not be compared directly');
|
||||
}
|
||||
const ensureAdmin = readFileSync(resolve(root, 'tools/deploy/ensure-production-admin.mjs'), 'utf8');
|
||||
if (/createHash\(['"]sha256['"]\)|function\s+hashPassword\s*\(/.test(ensureAdmin)
|
||||
|| !ensureAdmin.includes("api/dist/auth/password-hasher.js")) {
|
||||
violations.push('tools/deploy/ensure-production-admin.mjs: administrative password writes must use the API password hasher');
|
||||
}
|
||||
for (const relativePath of ['tools/deploy/ensure-production-admin.mjs', 'tools/smoke/real-env-smoke.mjs']) {
|
||||
const content = readFileSync(resolve(root, relativePath), 'utf8');
|
||||
if (/function\s+hashPassword\s*\(|passwordHash:\s*(?:createHash|legacyHashPassword)/.test(content)
|
||||
|| !content.includes("api/dist/auth/password-hasher.js")) {
|
||||
violations.push(`${relativePath}: user password writes must use the compiled API password hasher`);
|
||||
}
|
||||
}
|
||||
|
||||
const packageJson = JSON.parse(readFileSync(resolve(root, 'package.json'), 'utf8'));
|
||||
if (packageJson.dependencies?.['react-router-dom'] !== '7.18.2') {
|
||||
|
||||
Reference in New Issue
Block a user