Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e7629428df | |||
| c78f05a818 | |||
| a74380b072 | |||
| b6691b241b | |||
| 313f93a05d | |||
| 892d17f8dc | |||
| 87a6c63ac8 | |||
| 0a92b7f4a0 | |||
| a1aadf130d | |||
| dd94920955 | |||
| 54a52d9ebe |
+27
-32
@@ -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,65 +64,59 @@ 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 para podermos analisar o erro do ZAP
|
||||||
set +e
|
set +e
|
||||||
|
|
||||||
|
# Removemos o -c zap-rules.conf que estava a provocar o crash
|
||||||
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 \
|
||||||
-t ghcr.io/zaproxy/zaproxy:stable zap-full-scan.py \
|
-t ghcr.io/zaproxy/zaproxy:stable zap-full-scan.py \
|
||||||
-t http://apex-sandbox:3000 \
|
-t http://apex-sandbox:3000 \
|
||||||
-r report.html \
|
-r report.html \
|
||||||
-J report.json \
|
|
||||||
-j
|
-j
|
||||||
|
|
||||||
|
# GUARDAMOS O CÓDIGO DE RESULTADO DO ZAP
|
||||||
|
ZAP_EXIT_CODE=$?
|
||||||
|
|
||||||
|
# Voltamos a ligar a segurança do script Linux
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo ">>> 5. Recolher os relatórios..."
|
echo ">>> 5. Recolher o relatório HTML..."
|
||||||
|
# Como o ZAP agora não crasha, o relatório vai existir garantidamente!
|
||||||
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
|
|
||||||
|
|
||||||
echo ">>> 6. Limpeza final dos contentores..."
|
echo ">>> 6. Limpeza final dos contentores..."
|
||||||
docker rm -f zap-scanner apex-sandbox || true
|
docker rm -f zap-scanner apex-sandbox || true
|
||||||
docker network rm zap-net || true
|
docker network rm zap-net || true
|
||||||
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..."
|
||||||
if grep -qi 'Cross Site Scripting (Reflected)' qatests/report.html || grep -iE '"riskcode"\s*:\s*"3"|"risk"\s*:\s*"High"' qatests/report.json; then
|
# O ZAP devolve 1 para falhas graves, 2 para avisos, e 0 para sucesso.
|
||||||
echo "🚨 ALERTA CRÍTICO: O OWASP ZAP detetou uma vulnerabilidade de Injeção de Código (XSS)!"
|
if [ $ZAP_EXIT_CODE -eq 1 ]; then
|
||||||
echo "🛑 Pipeline BLOQUEADA para proteger a Branch Principal e a Produção."
|
echo "🚨 ALERTA CRÍTICO: OWASP ZAP encontrou falhas HIGH/CRITICAL! Pipeline bloqueada."
|
||||||
|
exit 1
|
||||||
|
elif [ $ZAP_EXIT_CODE -eq 2 ]; then
|
||||||
|
echo "⚠️ AVISO: ZAP encontrou alertas MEDIUM/LOW, mas a pipeline avança (Exit Code 0)."
|
||||||
|
exit 0
|
||||||
|
elif [ $ZAP_EXIT_CODE -eq 3 ]; then
|
||||||
|
echo "❌ ERRO: O OWASP ZAP crashou por má configuração."
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
echo "✅ ZAP Scan concluído. Nenhuma falha Crítica ou Alta encontrada."
|
echo "✅ ZAP Scan concluído sem vulnerabilidades críticas."
|
||||||
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
@@ -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
@@ -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>© 2026 Apex Solutions. All rights reserved.</p>
|
<p>© 2026 Apex Solutions. All rights reserved.</p>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
+2
-2
@@ -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}`);
|
||||||
});*/
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// ==========================================
|
// ==========================================
|
||||||
|
|||||||
Reference in New Issue
Block a user