Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f386e25432 | |||
| a213cc9482 | |||
| c63239e7ee | |||
| 35260c3717 | |||
| a6a7f3b0b5 | |||
| 0d221313e9 | |||
| 5929b935c1 | |||
| 414ebd29ad | |||
| 2ddbf37ca2 | |||
| e9e243ee42 | |||
| fd94417c8d | |||
| 6fc77e5569 | |||
| c7e505765a | |||
| 4fc7cb055f | |||
| fb337cfe01 | |||
| 021e844a4a | |||
| 1b301f879c | |||
| f354755871 |
+10
-18
@@ -13,31 +13,23 @@ app.use(cors());
|
||||
app.use(express.json());
|
||||
app.use(express.urlencoded({ extended: true }));
|
||||
|
||||
|
||||
app.get('/api/search', (req, res) => {
|
||||
const termo = req.query.q || '';
|
||||
// Vulnerabilidade Crítica: XSS Refletido
|
||||
res.send(`<html><body><h1>Resultados para: ${termo}</h1></body></html>`);
|
||||
});
|
||||
|
||||
// Serve a pasta frontend
|
||||
app.use(express.static(path.join(__dirname, '../frontend'), { extensions: ['html'] }));
|
||||
|
||||
// Rotas das 4 páginas estáticas
|
||||
app.get('/', (req, res) => res.sendFile(path.join(__dirname, '../frontend/index.html')));
|
||||
// Rotas das páginas estáticas (A rota '/' original foi comentada para não dar conflito com a do ZAP)
|
||||
// app.get('/', (req, res) => res.sendFile(path.join(__dirname, '../frontend/index.html')));
|
||||
app.get('/about', (req, res) => res.sendFile(path.join(__dirname, '../frontend/about.html')));
|
||||
app.get('/careers', (req, res) => res.sendFile(path.join(__dirname, '../frontend/careers.html')));
|
||||
app.get('/contact', (req, res) => res.sendFile(path.join(__dirname, '../frontend/contact.html')));
|
||||
|
||||
// ==========================================
|
||||
// VULNERÁVEL (OWASP ZAP)
|
||||
// ==========================================
|
||||
/*app.get('/api/search', (req, res) => {
|
||||
const termo = req.query.q || '';
|
||||
// A vulnerabilidade crítica: devolver o input diretamente no HTML
|
||||
res.send(`
|
||||
<html>
|
||||
<head><title>Resultados</title></head>
|
||||
<body>
|
||||
<h1>Resultados para: ${termo}</h1>
|
||||
<a href="/">Voltar</a>
|
||||
</body>
|
||||
</html>
|
||||
`);
|
||||
});*/
|
||||
// O eval() FOI REMOVIDO DAQUI PARA O SONARQUBE NÃO BLOQUEAR!
|
||||
|
||||
// Configuração do transporte de E-mail (Mocks de teste vs Produção)
|
||||
let transporter;
|
||||
|
||||
Generated
-7
@@ -11,7 +11,6 @@
|
||||
"dependencies": {
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.18.2",
|
||||
"lodash": "4.17.15",
|
||||
"nodemailer": "^8.0.11"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -3900,12 +3899,6 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/lodash": {
|
||||
"version": "4.17.15",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz",
|
||||
"integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/lru-cache": {
|
||||
"version": "5.1.1",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz",
|
||||
|
||||
@@ -36,15 +36,6 @@ describe('Enterprise Application Flow & API Validation', () => {
|
||||
expect(response.status).toBe(404);
|
||||
});
|
||||
|
||||
/*// OWASP ZAP (/api/search)
|
||||
it('Should reflect the search query in the HTML response (/api/search) - Vulnerable to XSS', async () => {
|
||||
const maliciousPayload = '<script>alert("ZAP")</script>';
|
||||
const response = await request(app).get(`/api/search?q=${maliciousPayload}`);
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
// Verifica se o payload é refletido exatamente como entrou (confirmando a vulnerabilidade)
|
||||
expect(response.text).toContain(`Resultados para: ${maliciousPayload}`);
|
||||
});*/
|
||||
});
|
||||
|
||||
// ==========================================
|
||||
|
||||
Reference in New Issue
Block a user