12 Commits

Author SHA1 Message Date
pm 1c27802143 Merge pull request 'owasp zap config v14' (#19) from teste-bloqueio into main
DevSecOps Enterprise Pipeline / security-gate-and-deploy (push) Successful in 1m35s
Reviewed-on: #19
2026-06-13 10:08:28 +00:00
pm e7629428df Merge pull request 'owasp zap config v13' (#18) from teste-bloqueio into main
DevSecOps Enterprise Pipeline / security-gate-and-deploy (push) Successful in 1m35s
Reviewed-on: #18
2026-06-13 10:00:14 +00:00
pm c78f05a818 Merge pull request 'owasp zap config v12' (#17) from teste-bloqueio into main
DevSecOps Enterprise Pipeline / security-gate-and-deploy (push) Successful in 1m34s
Reviewed-on: #17
2026-06-13 09:43:59 +00:00
pm a74380b072 Merge pull request 'owasp zap config v11' (#16) from teste-bloqueio into main
DevSecOps Enterprise Pipeline / security-gate-and-deploy (push) Failing after 54s
Reviewed-on: #16
2026-06-13 09:38:41 +00:00
pm b6691b241b Merge pull request 'owasp zap config v9' (#15) from teste-bloqueio into main
DevSecOps Enterprise Pipeline / security-gate-and-deploy (push) Successful in 59s
Reviewed-on: #15
2026-06-13 09:30:21 +00:00
pm 313f93a05d Merge pull request 'owasp zap config v8' (#14) from teste-bloqueio into main
DevSecOps Enterprise Pipeline / security-gate-and-deploy (push) Successful in 1m2s
Reviewed-on: #14
2026-06-13 09:14:34 +00:00
pm 892d17f8dc Merge pull request 'owasp zap config v7' (#13) from teste-bloqueio into main
DevSecOps Enterprise Pipeline / security-gate-and-deploy (push) Failing after 53s
Reviewed-on: #13
2026-06-13 00:02:04 +00:00
pm 87a6c63ac8 Merge pull request 'owasp zap config v6' (#12) from teste-bloqueio into main
DevSecOps Enterprise Pipeline / security-gate-and-deploy (push) Failing after 52s
Reviewed-on: #12
2026-06-12 23:57:30 +00:00
pm 0a92b7f4a0 Merge pull request 'owasp zap config v3' (#11) from teste-bloqueio into main
DevSecOps Enterprise Pipeline / security-gate-and-deploy (push) Failing after 43s
Reviewed-on: #11
2026-06-12 23:52:59 +00:00
pm a1aadf130d Merge pull request 'owasp zap config v2' (#9) from teste-bloqueio into main
DevSecOps Enterprise Pipeline / security-gate-and-deploy (push) Failing after 42s
Reviewed-on: #9
2026-06-12 23:42:12 +00:00
pm dd94920955 Merge pull request 'owasp zap config' (#8) from teste-bloqueio into main
DevSecOps Enterprise Pipeline / security-gate-and-deploy (push) Failing after 53s
Reviewed-on: #8
2026-06-12 23:36:56 +00:00
pm 54a52d9ebe Merge pull request 'feat: adiciona nova funcionalidade (com erro oculto)' (#7) from teste-bloqueio into main
DevSecOps Enterprise Pipeline / security-gate-and-deploy (push) Successful in 1m30s
Reviewed-on: #7
2026-06-12 23:26:14 +00:00
4 changed files with 25 additions and 36 deletions
+16 -27
View File
@@ -46,6 +46,7 @@ jobs:
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info
- name: 5. Dynamic Security Scan (OWASP ZAP) - name: 5. Dynamic Security Scan (OWASP ZAP)
if: github.event_name == 'push'
run: | run: |
echo ">>> 1. Limpeza profunda do ambiente..." echo ">>> 1. Limpeza profunda do ambiente..."
docker rm -f apex-sandbox zap-scanner || true docker rm -f apex-sandbox zap-scanner || true
@@ -63,8 +64,10 @@ jobs:
docker volume create zap-data docker volume create zap-data
echo ">>> 4. Executar OWASP ZAP (FULL SCAN + AJAX SPIDER)..." echo ">>> 4. Executar OWASP ZAP (FULL SCAN + AJAX SPIDER)..."
# Desligamos a paragem automática do Linux
set +e set +e
# Adicionámos o -J report.json para criar um ficheiro legível por máquina
docker run --user root --name zap-scanner \ docker run --user root --name zap-scanner \
--network zap-net \ --network zap-net \
-v zap-data:/zap/wrk/:rw \ -v zap-data:/zap/wrk/:rw \
@@ -74,9 +77,11 @@ jobs:
-J report.json \ -J report.json \
-j -j
# Voltamos a ligar a paragem de segurança
set -e set -e
echo ">>> 5. Recolher os relatórios..." echo ">>> 5. Recolher os relatórios..."
# Agora extraímos os dois ficheiros (HTML para humanos, JSON para a pipeline)
docker cp zap-scanner:/zap/wrk/report.html qatests/report.html || true docker cp zap-scanner:/zap/wrk/report.html qatests/report.html || true
docker cp zap-scanner:/zap/wrk/report.json qatests/report.json || true docker cp zap-scanner:/zap/wrk/report.json qatests/report.json || true
@@ -86,42 +91,26 @@ jobs:
docker volume rm zap-data || true docker volume rm zap-data || true
echo ">>> 7. Veredicto Final da Segurança (Gatekeeper Policy)..." echo ">>> 7. Veredicto Final da Segurança (Gatekeeper Policy)..."
if grep -qi 'Cross Site Scripting (Reflected)' qatests/report.html || grep -iE '"riskcode"\s*:\s*"3"|"risk"\s*:\s*"High"' qatests/report.json; then # Lemos o JSON report diretamente. Se contiver a palavra "High" ou "Critical", bloqueamos!
echo "🚨 ALERTA CRÍTICO: O OWASP ZAP detetou uma vulnerabilidade de Injeção de Código (XSS)!" if grep -q '"risk": "High"' qatests/report.json || grep -q '"risk": "Critical"' qatests/report.json; then
echo "🛑 Pipeline BLOQUEADA para proteger a Branch Principal e a Produção." echo "🚨 ALERTA CRÍTICO: O OWASP ZAP detetou vulnerabilidades de risco HIGH/CRITICAL (ex: XSS)!"
echo "🛑 Pipeline BLOQUEADA para proteger o ambiente de Produção."
exit 1 exit 1
else else
echo "✅ ZAP Scan concluído. Nenhuma falha Crítica ou Alta encontrada." echo "✅ ZAP Scan concluído. Nenhuma falha Crítica ou Alta encontrada."
exit 0 exit 0
fi fi
- name: 6. Deploy em Produção (SSH) - name: 6. Production Deployment
if: github.event_name == 'push' if: github.event_name == 'push'
uses: appleboy/ssh-action@master run: |
with: docker rm -f portal-corporativo || true
host: ${{ secrets.SSH_HOST }} docker run -d -p 3000:3000 --name portal-corporativo apex-solutions:latest
username: ${{ secrets.SSH_USER }} sleep 5
key: ${{ secrets.SSH_PRIVATE_KEY }} docker cp qatests/report.html portal-corporativo:/usr/src/app/frontend/zap-report.html || true
script: |
set -e
echo ">>> 1. A navegar para a pasta do projeto no servidor..."
cd /storage/docker/website-secure
echo ">>> 2. A transferir o código aprovado (git pull)..."
git pull origin main
echo ">>> 3. A compilar a imagem Docker de Produção..."
docker build -f backend/Dockerfile -t apex-solutions:prod .
echo ">>> 4. A substituir o contentor em execução..."
docker rm -f portal-corporativo || true
docker run -d -p 3000:3000 --name portal-corporativo --restart unless-stopped apex-solutions:prod
echo "✅ Deploy concluído com sucesso! A aplicação está no ar."
- name: 7. Archive ZAP Report - name: 7. Archive ZAP Report
if: always() if: always() && github.event_name == 'push'
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: owasp-zap-report name: owasp-zap-report
+3 -3
View File
@@ -23,9 +23,9 @@ app.get('/careers', (req, res) => res.sendFile(path.join(__dirname, '../frontend
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')));
// ========================================== // ==========================================
// VULNERÁVEL (OWASP ZAP) // ROTA VULNERÁVEL (Armadilha infalível para o OWASP ZAP)
// ========================================== // ==========================================
/*app.get('/api/search', (req, res) => { app.get('/api/search', (req, res) => {
const termo = req.query.q || ''; const termo = req.query.q || '';
// A vulnerabilidade crítica: devolver o input diretamente no HTML // A vulnerabilidade crítica: devolver o input diretamente no HTML
res.send(` res.send(`
@@ -37,7 +37,7 @@ app.get('/contact', (req, res) => res.sendFile(path.join(__dirname, '../frontend
</body> </body>
</html> </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;
+4 -4
View File
@@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home | Apex Solutions</title> <title>Home | Apex Solutions branch sec</title>
<script src="https://cdn.tailwindcss.com"></script> <script src="https://cdn.tailwindcss.com"></script>
<style> <style>
html { scroll-behavior: smooth; } /* Animação suave ao clicar no link de serviços */ html { scroll-behavior: smooth; } /* Animação suave ao clicar no link de serviços */
@@ -33,7 +33,7 @@
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-24 lg:py-32"> <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-24 lg:py-32">
<h1 class="text-4xl tracking-tight font-extrabold text-gray-900 sm:text-5xl md:text-6xl"> <h1 class="text-4xl tracking-tight font-extrabold text-gray-900 sm:text-5xl md:text-6xl">
<span class="block">Innovative Solutions for</span> <span class="block">Innovative Solutions for</span>
<span class="block text-blue-600">Modern website-secure</span> <span class="block text-blue-600">Modern Businesses</span>
</h1> </h1>
<p class="mt-6 max-w-2xl text-lg text-gray-500 leading-relaxed"> <p class="mt-6 max-w-2xl text-lg text-gray-500 leading-relaxed">
At Apex Solutions, we deliver high-quality business consulting, technology services, and strategic insights. We help organizations across the globe achieve their goals through operational excellence and digital transformation. At Apex Solutions, we deliver high-quality business consulting, technology services, and strategic insights. We help organizations across the globe achieve their goals through operational excellence and digital transformation.
@@ -93,12 +93,12 @@
</div> </div>
</div> </div>
</main> </main>
<!--<div style="display: none;"> <div style="display: none;">
<form action="/api/search" method="GET"> <form action="/api/search" method="GET">
<input type="text" name="q" value="teste"> <input type="text" name="q" value="teste">
<button type="submit">Pesquisar</button> <button type="submit">Pesquisar</button>
</form> </form>
</div>--> </div>
<footer class="bg-slate-900 text-slate-400 py-12 text-center"> <footer class="bg-slate-900 text-slate-400 py-12 text-center">
<p>&copy; 2026 Apex Solutions. All rights reserved.</p> <p>&copy; 2026 Apex Solutions. All rights reserved.</p>
</footer> </footer>
+2 -2
View File
@@ -36,7 +36,7 @@ describe('Enterprise Application Flow & API Validation', () => {
expect(response.status).toBe(404); expect(response.status).toBe(404);
}); });
/*// OWASP ZAP (/api/search) // NOVO TESTE: Valida a nossa armadilha para o OWASP ZAP (corrigido para /api/search)
it('Should reflect the search query in the HTML response (/api/search) - Vulnerable to XSS', async () => { it('Should reflect the search query in the HTML response (/api/search) - Vulnerable to XSS', async () => {
const maliciousPayload = '<script>alert("ZAP")</script>'; const maliciousPayload = '<script>alert("ZAP")</script>';
const response = await request(app).get(`/api/search?q=${maliciousPayload}`); const response = await request(app).get(`/api/search?q=${maliciousPayload}`);
@@ -44,7 +44,7 @@ describe('Enterprise Application Flow & API Validation', () => {
expect(response.status).toBe(200); expect(response.status).toBe(200);
// Verifica se o payload é refletido exatamente como entrou (confirmando a vulnerabilidade) // Verifica se o payload é refletido exatamente como entrou (confirmando a vulnerabilidade)
expect(response.text).toContain(`Resultados para: ${maliciousPayload}`); expect(response.text).toContain(`Resultados para: ${maliciousPayload}`);
});*/ });
}); });
// ========================================== // ==========================================