nzambello.dev/test-security.js
Nicola Zambello 6e6948b4fd
All checks were successful
Docker CI / release (push) Successful in 3m52s
fix: security headers
2025-08-12 15:35:55 +03:00

47 lines
1.3 KiB
JavaScript
Raw Permalink 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.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env node
import https from 'https';
import http from 'http';
const testUrl = 'https://nzambello.dev';
console.log('🔒 Testing Security Headers for', testUrl);
console.log('=' .repeat(50));
const client = testUrl.startsWith('https') ? https : http;
client.get(testUrl, (res) => {
console.log(`Status: ${res.statusCode}`);
console.log(`Server: ${res.headers.server || 'Not disclosed'}`);
console.log('\n📋 Security Headers:');
console.log('-'.repeat(30));
const securityHeaders = [
'content-security-policy',
'strict-transport-security',
'x-content-type-options',
'x-frame-options',
'referrer-policy',
'x-xss-protection',
'permissions-policy'
];
securityHeaders.forEach(header => {
const value = res.headers[header];
const status = value ? '✅' : '❌';
console.log(`${status} ${header}: ${value || 'Not set'}`);
});
console.log('\n🔍 Additional Headers:');
console.log('-'.repeat(30));
Object.keys(res.headers).forEach(header => {
if (!securityHeaders.includes(header.toLowerCase())) {
console.log(` ${header}: ${res.headers[header]}`);
}
});
}).on('error', (err) => {
console.error('❌ Error testing headers:', err.message);
console.log('\n💡 Make sure the site is running and accessible');
});