Merge pull request 'Gitleaks Validation' (#25) from validation_stage into main
DevSecOps Enterprise Pipeline / security-gate-and-deploy (push) Successful in 1m38s
DevSecOps Enterprise Pipeline / security-gate-and-deploy (push) Successful in 1m38s
Reviewed-on: #25
This commit was merged in pull request #25.
This commit is contained in:
+10
-18
@@ -13,31 +13,23 @@ app.use(cors());
|
|||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
app.use(express.urlencoded({ extended: true }));
|
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
|
// Serve a pasta frontend
|
||||||
app.use(express.static(path.join(__dirname, '../frontend'), { extensions: ['html'] }));
|
app.use(express.static(path.join(__dirname, '../frontend'), { extensions: ['html'] }));
|
||||||
|
|
||||||
// Rotas das 4 páginas estáticas
|
// 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('/', (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('/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('/careers', (req, res) => res.sendFile(path.join(__dirname, '../frontend/careers.html')));
|
||||||
app.get('/contact', (req, res) => res.sendFile(path.join(__dirname, '../frontend/contact.html')));
|
app.get('/contact', (req, res) => res.sendFile(path.join(__dirname, '../frontend/contact.html')));
|
||||||
|
|
||||||
// ==========================================
|
// O eval() FOI REMOVIDO DAQUI PARA O SONARQUBE NÃO BLOQUEAR!
|
||||||
// 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>
|
|
||||||
`);
|
|
||||||
});*/
|
|
||||||
|
|
||||||
// Configuração do transporte de E-mail (Mocks de teste vs Produção)
|
// Configuração do transporte de E-mail (Mocks de teste vs Produção)
|
||||||
let transporter;
|
let transporter;
|
||||||
|
|||||||
Generated
-7
@@ -11,7 +11,6 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"lodash": "4.17.15",
|
|
||||||
"nodemailer": "^8.0.11"
|
"nodemailer": "^8.0.11"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -3900,12 +3899,6 @@
|
|||||||
"node": ">=8"
|
"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": {
|
"node_modules/lru-cache": {
|
||||||
"version": "5.1.1",
|
"version": "5.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz",
|
"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);
|
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