Files
e-tib.com/scripts/check-security.ts
Marc Mintel aac0529bb6
All checks were successful
Build & Deploy / 🔍 Prepare (push) Successful in 19s
Build & Deploy / 🧪 QA (push) Successful in 1m25s
Build & Deploy / 🏗️ Build (push) Successful in 2m44s
Build & Deploy / 🚀 Deploy (push) Successful in 24s
Build & Deploy / 🧪 Post-Deploy Verification (push) Successful in 51s
Build & Deploy / 🔔 Notify (push) Successful in 3s
fix(infra): replace legacy klz fallback references with etib across docker compose and test scripts
2026-08-17 18:31:29 +02:00

57 lines
1.7 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import axios from 'axios';
const targetUrl = process.argv[2] || process.env.NEXT_PUBLIC_BASE_URL || 'http://localhost:3000';
const gatekeeperPassword = process.env.GATEKEEPER_PASSWORD || 'etib2026';
const authCookieName = process.env.AUTH_COOKIE_NAME || 'etib_gatekeeper_session';
const requiredHeaders = [
'strict-transport-security',
'x-frame-options',
'x-content-type-options',
'referrer-policy',
'content-security-policy',
];
async function main() {
console.log(`\n🛡 Starting Security Headers Scan for: ${targetUrl}\n`);
try {
const response = await axios.head(targetUrl, {
headers: { Cookie: `${authCookieName}=${gatekeeperPassword}` },
validateStatus: () => true,
});
const headers = response.headers;
let allPassed = true;
const results = requiredHeaders.map((header) => {
const present = !!headers[header];
if (!present) allPassed = false;
return {
Header: header,
Status: present ? '✅ Present' : '❌ Missing',
Value: present
? headers[header].length > 50
? headers[header].substring(0, 47) + '...'
: headers[header]
: 'N/A',
};
});
console.table(results);
if (allPassed) {
console.log(`\n✅ All required security headers are correctly configured!\n`);
process.exit(0);
} else {
console.log(`\n❌ Missing critical security headers. Please update next.config.mjs!\n`);
process.exit(process.env.CI ? 1 : 0); // Don't crash local dev hard if missing, but crash CI
}
} catch (error: any) {
console.error(`❌ Failed to scan headers: ${error.message}`);
process.exit(1);
}
}
main();