89 Commits

Author SHA1 Message Date
pm 4395cd8c8c Merge pull request 'gitleak validation' (#28) from apresentacao into main
DevSecOps Enterprise Pipeline / security-gate-and-deploy (push) Successful in 1m34s
Reviewed-on: #28
2026-06-18 18:42:59 +00:00
pm 1e22422604 all good
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Successful in 1m33s
2026-06-18 19:40:08 +01:00
pm 1521ef231b gitleak validation
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 12s
2026-06-18 19:28:03 +01:00
pm cb11ad05f9 Merge pull request 'all good v2' (#27) from teste into main
DevSecOps Enterprise Pipeline / security-gate-and-deploy (push) Successful in 1m34s
Reviewed-on: #27
2026-06-18 15:42:46 +00:00
pm 560e5ea94a all good v2
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Successful in 1m33s
2026-06-18 16:39:46 +01:00
pm 0815a45c93 Merge pull request 'gitleak validation v1' (#26) from teste into main
DevSecOps Enterprise Pipeline / security-gate-and-deploy (push) Successful in 1m36s
Reviewed-on: #26
2026-06-18 15:34:54 +00:00
pm 211d03189a all good
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Successful in 1m32s
2026-06-18 16:32:01 +01:00
pm 48c768ef00 owasp zap v4
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 1m38s
2026-06-18 16:27:08 +01:00
pm c897cd4858 owasp zap v3
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Successful in 1m33s
2026-06-18 16:20:23 +01:00
pm 5e09e812c3 owasp zap v2
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 1m33s
2026-06-18 16:14:12 +01:00
pm 0133159c0f trivy owasp zap v1
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Successful in 1m33s
2026-06-18 16:11:39 +01:00
pm 9e582170dc trivy sonarqube v1
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 48s
2026-06-18 16:07:08 +01:00
pm 09f3c5c97b trivy validation v1
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 31s
2026-06-18 16:00:39 +01:00
pm f8a53f0d2f gitleak validation v1
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 25s
2026-06-18 15:55:53 +01:00
pm 9cf7b1b4d1 Merge pull request 'Gitleaks Validation' (#25) from validation_stage into main
DevSecOps Enterprise Pipeline / security-gate-and-deploy (push) Successful in 1m38s
Reviewed-on: #25
2026-06-16 15:34:29 +00:00
pm f386e25432 All Good
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Successful in 1m33s
2026-06-16 16:28:46 +01:00
pm a213cc9482 OWASP ZAP Validation v2
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 1m33s
2026-06-16 16:09:04 +01:00
pm c63239e7ee OWASP ZAP Validation
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 59s
2026-06-16 16:02:41 +01:00
pm 35260c3717 SonarQube Validation
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 46s
2026-06-16 01:34:41 +01:00
pm a6a7f3b0b5 All Good Validation
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Successful in 1m30s
2026-06-16 01:24:40 +01:00
pm 0d221313e9 SonarQube Validation v6
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 45s
2026-06-16 01:17:02 +01:00
pm 5929b935c1 SonarQube Validation v5
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 10s
2026-06-16 01:14:24 +01:00
pm 414ebd29ad SonarQube Validation v4
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 10s
2026-06-16 01:12:10 +01:00
pm 2ddbf37ca2 SonarQube Validation v3
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 45s
2026-06-16 00:45:39 +01:00
pm e9e243ee42 SonarQube Validation v2
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 9s
2026-06-16 00:42:29 +01:00
pm fd94417c8d SonarQube Validation
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 13s
2026-06-16 00:40:19 +01:00
pm 6fc77e5569 Trivy Validation v3 [fixed]
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 31s
2026-06-16 00:04:56 +01:00
pm c7e505765a Trivy Validation v2 [fixed]
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Has been cancelled
2026-06-16 00:01:55 +01:00
pm 4fc7cb055f Trivy Validation
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Has been cancelled
2026-06-16 00:00:12 +01:00
pm fb337cfe01 Unit Tests Validation
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 10s
2026-06-15 23:50:35 +01:00
pm 021e844a4a Gitleaks Validation v2
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 11s
2026-06-15 23:33:53 +01:00
pm 1b301f879c Gitleaks Validation v2
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Has been cancelled
2026-06-15 23:31:02 +01:00
pm f354755871 Gitleaks Validation
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Successful in 1m33s
2026-06-15 22:30:23 +01:00
pm 3f46bbebf7 Merge pull request 'test ci/cd titulo v3' (#24) from teste-bloqueio into main
DevSecOps Enterprise Pipeline / security-gate-and-deploy (push) Successful in 1m31s
Reviewed-on: #24
2026-06-13 14:18:39 +00:00
pm 139ef63129 test ci/cd titulo v3
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Successful in 1m31s
2026-06-13 15:15:37 +01:00
pm 21123e6149 Merge pull request 'test ci/cd titulo v2' (#23) from teste-bloqueio into main
DevSecOps Enterprise Pipeline / security-gate-and-deploy (push) Successful in 1m42s
Reviewed-on: #23
2026-06-13 14:07:33 +00:00
pm 6e36250d69 test ci/cd titulo v2
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Successful in 1m30s
2026-06-13 15:04:38 +01:00
pm ad08cda20e Merge pull request 'test ci/cd titulo' (#22) from teste-bloqueio into main
DevSecOps Enterprise Pipeline / security-gate-and-deploy (push) Successful in 1m38s
Reviewed-on: #22
2026-06-13 13:56:22 +00:00
pm f7f382965c test ci/cd titulo
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Successful in 1m34s
2026-06-13 14:52:14 +01:00
pm 3bfccdeca6 Merge pull request 'owasp zap config v16' (#21) from teste-bloqueio into main
DevSecOps Enterprise Pipeline / security-gate-and-deploy (push) Successful in 1m34s
Reviewed-on: #21
2026-06-13 10:44:17 +00:00
pm 8ed247f3c3 All good v2
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Successful in 1m30s
2026-06-13 11:39:16 +01:00
pm 85e6d4b66a All good v1
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 10s
2026-06-13 11:36:27 +01:00
pm 76f95077ce owasp zap config v16
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 1m28s
2026-06-13 11:30:12 +01:00
pm 007678a44d Merge pull request 'owasp zap config v15' (#20) from teste-bloqueio into main
DevSecOps Enterprise Pipeline / security-gate-and-deploy (push) Failing after 1m28s
Reviewed-on: #20
2026-06-13 10:13:50 +00:00
pm b3294390a5 owasp zap config v15
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Successful in 43s
2026-06-13 11:11:51 +01:00
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 d921ecae04 owasp zap config v14
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Successful in 43s
2026-06-13 11:06:26 +01: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 f8a3643ab9 owasp zap config v13
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Successful in 44s
2026-06-13 10:55:34 +01: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 869da6930b owasp zap config v12
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Successful in 43s
2026-06-13 10:41:50 +01: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 30aca3e8da owasp zap config v11
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Successful in 43s
2026-06-13 10:36:56 +01: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 7c7a2efd61 owasp zap config v10
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Successful in 43s
2026-06-13 10:29:03 +01:00
pm 5805011296 owasp zap config v9
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 10s
2026-06-13 10:25:25 +01: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 5afbb57dcc owasp zap config v8
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Successful in 42s
2026-06-13 10:11:13 +01: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 ccdace0951 owasp zap config v7
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Successful in 44s
2026-06-13 01:00:19 +01: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 0fdd3c1558 owasp zap config v6
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Successful in 43s
2026-06-13 00:55:31 +01: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 430c418062 owasp zap config v5
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Successful in 42s
2026-06-13 00:50:04 +01:00
pm aba23ad583 owasp zap config v4 2026-06-13 00:48:45 +01:00
pm c23ad4f6d3 owasp zap config v3 2026-06-13 00:44:33 +01: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 47db928d3c owasp zap config v2
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Successful in 43s
2026-06-13 00:40:00 +01: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 745c8b4e71 owasp zap config
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Successful in 45s
2026-06-13 00:34:35 +01: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
pm 432d3d8840 sonar v2
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Successful in 56s
2026-06-13 00:04:18 +01:00
pm 500972ea6f sonar
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 45s
2026-06-13 00:00:44 +01:00
pm aa726dbd77 teste: introduz lodash para forcar bloqueio do trivy
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 30s
2026-06-12 23:58:15 +01:00
pm 3da598485b trivy nodemailer v2
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 45s
2026-06-12 23:52:38 +01:00
pm 22940982e7 trivy nodemailer
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 46s
2026-06-12 23:49:01 +01:00
pm 62aaba7cae gitleak v7
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 6s
2026-06-12 23:43:38 +01:00
pm d30db1d4cc gitleak v6
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 56s
2026-06-12 23:41:13 +01:00
pm cc8c34868c gitleak v5
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 18s
2026-06-12 23:35:47 +01:00
pm eb1aec157d gitleak v3
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 17s
2026-06-12 23:30:22 +01:00
pm 2760503bfa gitleak v2
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 9s
2026-06-12 23:28:27 +01:00
pm 9ade6ec23f gitleak
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 17s
2026-06-12 23:26:06 +01:00
pm b7ba597b0a fix deploy
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 17s
2026-06-12 23:24:14 +01:00
pm a75556acd2 fix deploy
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Successful in 37s
2026-06-12 23:21:01 +01:00
pm 34eb81849b trivy v4
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 9s
2026-06-12 23:17:52 +01:00
pm 6adf9ea8b9 trivy v3
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 9s
2026-06-12 23:15:38 +01:00
pm 03b75c1da6 trivy v2
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 13s
2026-06-12 23:14:19 +01:00
pm 29816c44bb trivy
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 14s
2026-06-12 23:11:55 +01:00
pm 734e128696 gitleak bloqueio
DevSecOps Enterprise Pipeline / security-gate-and-deploy (pull_request) Failing after 9s
2026-06-12 23:07:19 +01:00
8 changed files with 719 additions and 147 deletions
+62 -46
View File
@@ -17,27 +17,20 @@ jobs:
- name: 1. Build Application Image - name: 1. Build Application Image
run: docker build -f backend/Dockerfile -t apex-solutions:latest . run: docker build -f backend/Dockerfile -t apex-solutions:latest .
- name: 1.5. Execute Unit Tests (Business Logic) - name: 1.5. Execute Unit Tests
run: | run: |
echo ">>> Syncing dependencies and executing test suite..."
# O 'npm install' vai atualizar automaticamente o package-lock.json
# caso exista alguma divergência com o package.json
npm install npm install
npm test npm test
# ==========================================
# STATIC SECURITY ANALYSIS STAGES
# ==========================================
- name: 2. Secret Scanning (Gitleaks) - name: 2. Secret Scanning (Gitleaks)
run: | run: |
curl -sL https://github.com/gitleaks/gitleaks/releases/download/v8.18.2/gitleaks_8.18.2_linux_x64.tar.gz | tar -xz -C /tmp curl -sL https://github.com/gitleaks/gitleaks/releases/download/v8.18.2/gitleaks_8.18.2_linux_x64.tar.gz | tar -xz -C /tmp
/tmp/gitleaks detect --source . --verbose --redact --exit-code 1 /tmp/gitleaks detect --source . --no-git --verbose --redact --exit-code 1
- name: 3. Software Composition Analysis (Trivy) - name: 3. Software Composition Analysis (Trivy)
run: | run: |
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin
trivy image --severity HIGH,CRITICAL apex-solutions:latest trivy image --exit-code 1 --severity HIGH,CRITICAL apex-solutions:latest
- name: 4. Static Application Security Testing (SonarQube) - name: 4. Static Application Security Testing (SonarQube)
run: | run: |
@@ -52,60 +45,83 @@ jobs:
-Dsonar.qualitygate.wait=true \ -Dsonar.qualitygate.wait=true \
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info
# ==========================================
# DYNAMIC SECURITY ANALYSIS & DEPLOYMENT
# ==========================================
- name: 5. Dynamic Security Scan (OWASP ZAP) - name: 5. Dynamic Security Scan (OWASP ZAP)
if: github.event_name == 'push'
run: | run: |
echo ">>> Provisioning ephemeral sandbox environment..." echo ">>> 1. Limpeza profunda do ambiente..."
docker rm -f apex-sandbox || true docker rm -f apex-sandbox zap-scanner || true
docker run -d --name apex-sandbox apex-solutions:latest docker network rm zap-net || true
sleep 5 docker volume rm zap-data || true
echo ">>> Initiating OWASP ZAP Baseline Scan..." echo ">>> 2. Criar rede e iniciar Sandbox..."
docker network create zap-net
docker run -d --name apex-sandbox --network zap-net apex-solutions:latest
sleep 10
echo ">>> 3. Preparar Volume do ZAP e Diretório de Testes..."
mkdir -p qatests mkdir -p qatests
docker rm -f zap-scanner || true chmod 777 qatests
docker volume rm zap-reports || true docker volume create zap-data
docker volume create zap-reports
echo ">>> 4. Executar OWASP ZAP (FULL SCAN + AJAX SPIDER)..."
set +e
docker run --user root --name zap-scanner \ docker run --user root --name zap-scanner \
--link apex-sandbox:apex-sandbox \ --network zap-net \
-v zap-reports:/zap/wrk/:rw \ -v zap-data:/zap/wrk/:rw \
-t ghcr.io/zaproxy/zaproxy:stable zap-baseline.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 \
-I -J report.json \
-j
set -e
echo ">>> 5. Recolher os relatórios..."
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 ">>> Decommissioning ephemeral sandbox..." echo ">>> 6. Limpeza final dos contentores..."
docker rm -f zap-scanner || true docker rm -f zap-scanner apex-sandbox || true
docker volume rm zap-reports || true docker network rm zap-net || true
docker rm -f apex-sandbox || true docker volume rm zap-data || true
- name: 6. Production Deployment & Local Reports 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
echo "🚨 ALERTA CRÍTICO: O OWASP ZAP detetou uma vulnerabilidade de Injeção de Código (XSS)!"
echo "🛑 Pipeline BLOQUEADA para proteger a Branch Principal e a Produção."
exit 1
else
echo "✅ ZAP Scan concluído. Nenhuma falha Crítica ou Alta encontrada."
exit 0
fi
- name: 6. Deploy em Produção (SSH)
if: github.event_name == 'push' if: github.event_name == 'push'
run: | uses: appleboy/ssh-action@master
echo ">>> Deploying application to production environment..." 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 }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
set -e
echo ">>> Awaiting Node.js service initialization..." echo ">>> 1. A navegar para a pasta do projeto no servidor..."
sleep 5 cd /storage/docker/website-secure
echo ">>> Container logs (for diagnostic purposes):" echo ">>> 2. A transferir o código aprovado (git pull)..."
docker logs portal-corporativo git pull origin main
echo ">>> Performing internal health check (via wget)..." echo ">>> 3. A compilar a imagem Docker de Produção..."
docker exec portal-corporativo wget --spider -S http://localhost:3000 docker build -f backend/Dockerfile -t apex-solutions:prod .
echo ">>> Publishing OWASP ZAP security report to web server..." echo ">>> 4. A substituir o contentor em execução..."
docker cp qatests/report.html portal-corporativo:/usr/src/app/frontend/zap-report.html || true docker rm -f portal-corporativo || true
docker run -d -p 3000:3000 --name portal-corporativo --restart unless-stopped apex-solutions:prod
- name: 7. Archive ZAP Report (Gitea Artifacts) echo "✅ Deploy concluído com sucesso! A aplicação está no ar."
if: always() && github.event_name == 'push'
- name: 7. Archive ZAP Report
if: always()
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: owasp-zap-report name: owasp-zap-report
+8 -3
View File
@@ -1,7 +1,12 @@
FROM node:18-alpine FROM node:22-alpine
# Cria um grupo e um utilizador sem privilégios # ==========================================
RUN addgroup -S appgroup && adduser -S appuser -G appgroup # DEVSECOPS: HARDENING DA IMAGEM BASE
# ==========================================
# Agrupamos os comandos RUN num só para otimizar as camadas da imagem (Regra do SonarQube)
RUN apk update && apk upgrade --no-cache && \
npm install -g npm@latest && \
addgroup -S appgroup && adduser -S appuser -G appgroup
# Define o diretório de trabalho # Define o diretório de trabalho
WORKDIR /usr/src/app WORKDIR /usr/src/app
+23 -24
View File
@@ -5,33 +5,33 @@ const nodemailer = require('nodemailer');
const app = express(); const app = express();
app.disable('x-powered-by'); app.disable('x-powered-by');
const PORT = process.env.PORT || 3000; const PORT = process.env.PORT || 3000;
app.use(cors()); app.use(cors());
app.use(express.json()); app.use(express.json());
app.use(express.urlencoded({ extended: true })); app.use(express.urlencoded({ extended: true }));
// 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 // 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')));
// Configuração do transporte de E-mail // 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; let transporter;
if (process.env.NODE_ENV === 'test') { if (process.env.NODE_ENV === 'test') {
// Em teste, criamos um mock vazio para evitar erros
transporter = { sendMail: jest.fn().mockResolvedValue({ messageId: 'test-id' }) }; transporter = { sendMail: jest.fn().mockResolvedValue({ messageId: 'test-id' }) };
} else { } else {
// Em produção, usamos o transporter real
transporter = nodemailer.createTransport({ transporter = nodemailer.createTransport({
host: 'mail.limpezascleanandcare.com', host: 'mail.limpezascleanandcare.com',
port: 465, port: 465,
@@ -44,60 +44,59 @@ if (process.env.NODE_ENV === 'test') {
}); });
} }
// Endpoint do Formulário de Contacto (Com a armadilha validada pelo Jest)
// Endpoint do Formulário de Contacto (Com Recetor Dinâmico)
app.post('/api/contact', async (req, res) => { app.post('/api/contact', async (req, res) => {
const { firstName, lastName, email, company, message } = req.body; const { firstName, lastName, email, company, message } = req.body;
// Se faltarem dados, devolvemos HTML para simular XSS e bater com o teste unitário
if (!email || !message) { if (!email || !message) {
return res.status(400).json({ error: 'Email and message are required.' }); res.setHeader('Content-Type', 'text/html');
return res.status(400).send(`
<h2>Erro de Validação</h2>
<p>Os campos Email e Mensagem são obrigatórios.</p>
<p>Nome recebido: ${firstName}</p>
`);
} }
try { try {
// Construção do Email - Agora enviado para o e-mail inserido no formulário
const mailOptions = { const mailOptions = {
from: '"Apex Solutions" <teste@limpezascleanandcare.com>', // Remetente fixo válido from: '"Apex Solutions" <teste@limpezascleanandcare.com>',
to: email, // RECETOR DINÂMICO (Vem diretamente do campo Email Address) to: email,
subject: `Confirmation: We received your request, ${firstName}!`, subject: `Confirmation: We received your request, ${firstName}!`,
html: ` html: `
<div style="font-family: Arial, sans-serif; padding: 20px; color: #333; max-width: 600px; margin: 0 auto; border: 1px solid #e2e8f0; border-radius: 8px;"> <div style="font-family: Arial, sans-serif; padding: 20px; color: #333; max-width: 600px; margin: 0 auto; border: 1px solid #e2e8f0; border-radius: 8px;">
<h2 style="color: #2563eb;">Hello ${firstName} ${lastName},</h2> <h2 style="color: #2563eb;">Hello ${firstName} ${lastName},</h2>
<p style="font-size: 15px; line-height: 1.5; color: #475569;"> <p style="font-size: 15px; line-height: 1.5; color: #475569;">
Thank you for reaching out to <strong>Apex Solutions</strong>. This is an automated confirmation to let you know that we have successfully received your inquiry. Thank you for reaching out to <strong>Apex Solutions</strong>. This is an automated confirmation.
</p> </p>
<div style="margin: 20px 0; background: #f8fafc; padding: 15px; border-left: 4px solid #2563eb; border-radius: 4px;"> <div style="margin: 20px 0; background: #f8fafc; padding: 15px; border-left: 4px solid #2563eb; border-radius: 4px;">
<h4 style="margin: 0 0 10px 0; color: #1e293b;">Summary of your submission:</h4> <h4 style="margin: 0 0 10px 0; color: #1e293b;">Summary of your submission:</h4>
<p style="margin: 5px 0; font-size: 14px;"><strong>Subject/Company:</strong> ${company || 'Not specified'}</p> <p style="margin: 5px 0; font-size: 14px;"><strong>Subject/Company:</strong> ${company || 'Not specified'}</p>
<p style="margin: 10px 0 0 0; font-size: 14px; font-style: italic; color: #64748b;">"${message}"</p> <p style="margin: 10px 0 0 0; font-size: 14px; font-style: italic; color: #64748b;">"${message}"</p>
</div> </div>
<p style="font-size: 15px; line-height: 1.5; color: #475569;"> <p style="font-size: 15px; line-height: 1.5; color: #475569;">
Our advisory team will review your details and get back to you within 24 business hours. Our team will get back to you within 24 business hours.
</p> </p>
<hr style="border: 0; border-top: 1px solid #e2e8f0; margin: 20px 0;" /> <hr style="border: 0; border-top: 1px solid #e2e8f0; margin: 20px 0;" />
<p style="font-size: 12px; color: #94a3b8; text-align: center; margin: 0;"> <p style="font-size: 12px; color: #94a3b8; text-align: center; margin: 0;">
Best regards,<br> Best regards,<br><strong>Apex Solutions Corporate Team</strong>
<strong>Apex Solutions Corporate Team</strong>
</p> </p>
</div> </div>
` `
}; };
// Envia o e-mail real
const info = await transporter.sendMail(mailOptions); const info = await transporter.sendMail(mailOptions);
console.log(`[Email Sent Automatically to ${email}] Message ID: ${info.messageId}`); console.log(`[Email Sent Automatically to ${email}] Message ID: ${info.messageId}`);
res.status(200).json({ success: true, message: 'Thank you! A confirmation email has been dispatched to your address.' }); res.status(200).json({ success: true, message: 'Thank you! A confirmation email has been dispatched.' });
} catch (error) { } catch (error) {
console.error(`[Email Error]:`, error); console.error(`[Email Error]:`, error);
res.status(500).json({ error: 'Internal server error. Could not send confirmation email.' }); res.status(500).json({ error: 'Internal server error. Could not send confirmation email.' });
} }
}); });
module.exports = { app, transporter }; module.exports = { app, transporter };
// Export the app for testing, but only listen if run directly
if (require.main === module) { if (require.main === module) {
app.listen(PORT, () => { app.listen(PORT, () => {
console.log(`[Apex Server] Running on port ${PORT}`); console.log(`[Apex Server] Running on port ${PORT}`);
+9 -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 branch sec</title> <title>Home | Apex Solutions</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,10 +33,10 @@
<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 Businesses</span> <span class="block text-blue-600">Modern website-secure</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. ISTEC - ERSI
</p> </p>
<div class="mt-10 flex gap-4"> <div class="mt-10 flex gap-4">
<a href="#services" class="px-8 py-3 border border-transparent text-base font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700">Explore Services</a> <a href="#services" class="px-8 py-3 border border-transparent text-base font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700">Explore Services</a>
@@ -93,7 +93,12 @@
</div> </div>
</div> </div>
</main> </main>
<!--<div style="display: none;">
<form action="/api/search" method="GET">
<input type="text" name="q" value="teste">
<button type="submit">Pesquisar</button>
</form>
</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>
+592 -54
View File
File diff suppressed because it is too large Load Diff
+7 -6
View File
@@ -14,13 +14,14 @@
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"type": "commonjs", "type": "commonjs",
"devDependencies": { "dependencies": {
"jest": "^30.4.2",
"supertest": "^7.2.2",
"cors": "^2.8.5", "cors": "^2.8.5",
"express": "^4.18.2", "express": "^4.18.2",
"nodemailer": "^6.9.3" "nodemailer": "^8.0.11"
},
"devDependencies": {
"jest": "^30.4.2",
"supertest": "^7.2.2"
} }
} }
+9 -3
View File
@@ -35,6 +35,7 @@ describe('Enterprise Application Flow & API Validation', () => {
const response = await request(app).get('/invalid-admin-route'); const response = await request(app).get('/invalid-admin-route');
expect(response.status).toBe(404); expect(response.status).toBe(404);
}); });
}); });
// ========================================== // ==========================================
@@ -52,10 +53,16 @@ describe('Enterprise Application Flow & API Validation', () => {
const response = await request(app).post('/api/contact').send(invalidPayload); const response = await request(app).post('/api/contact').send(invalidPayload);
expect(response.status).toBe(400); expect(response.status).toBe(400);
expect(response.body).toHaveProperty('error', 'Email and message are required.');
// ==========================================
// CORREÇÃO DEVSECOPS: O servidor agora devolve HTML para a armadilha XSS!
// Lemos o response.text (HTML) em vez do response.body (JSON)
// ==========================================
expect(response.text).toContain('Erro de Validação');
expect(response.text).toContain('John'); // Garante que o input foi refletido na página
}); });
it('Should process request, return 200 OK, and invoke SMTP transporter with valid data', async () => { it('Should process request, return 200 OK, and invoke SMTP transporter with valid data', async () => {
const validPayload = { const validPayload = {
firstName: 'Jane', firstName: 'Jane',
lastName: 'Doe', lastName: 'Doe',
@@ -70,7 +77,6 @@ it('Should process request, return 200 OK, and invoke SMTP transporter with vali
expect(response.status).toBe(200); expect(response.status).toBe(200);
// Validate Business Logic: Verifica o objeto 'transporter' que veio do server.js // Validate Business Logic: Verifica o objeto 'transporter' que veio do server.js
// Como este objeto é o que injetámos no server, ele já é o mock!
expect(transporter.sendMail).toHaveBeenCalledTimes(1); expect(transporter.sendMail).toHaveBeenCalledTimes(1);
}); });
}); });
+2
View File
@@ -0,0 +1,2 @@
# Bloqueia a pipeline se encontrar algo grave
FAIL_ON_SEVERITY: HIGH