From 74588fbd5d8be6e7a33ce21859aa3d957476a69b Mon Sep 17 00:00:00 2001 From: LathanDevers Date: Mon, 3 Aug 2026 14:03:56 +0200 Subject: [PATCH 01/14] feat: add workflow git --- .gitea/workflows/deploy-environments.yml | 84 ++++++++++++++++++++++++ .gitea/workflows/deploy.yml | 61 ----------------- .gitea/workflows/enforce-git-flow.yml | 39 +++++++++++ .gitea/workflows/quality-checks.yml | 54 +++++++++++++++ 4 files changed, 177 insertions(+), 61 deletions(-) create mode 100644 .gitea/workflows/deploy-environments.yml delete mode 100644 .gitea/workflows/deploy.yml create mode 100644 .gitea/workflows/enforce-git-flow.yml create mode 100644 .gitea/workflows/quality-checks.yml diff --git a/.gitea/workflows/deploy-environments.yml b/.gitea/workflows/deploy-environments.yml new file mode 100644 index 0000000..5e61411 --- /dev/null +++ b/.gitea/workflows/deploy-environments.yml @@ -0,0 +1,84 @@ +name: Déploiement AEGIS Portal + +on: + push: + branches: + - dev + - test + - acc + - master + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + env: + GIT_SSL_NO_VERIFY: "true" + NODE_TLS_REJECT_UNAUTHORIZED: "0" + + steps: + - name: Patch DNS local pour Gitea Runner + run: sudo echo "10.10.40.31 git.bunker.lan" | sudo tee -a /etc/hosts + + - name: Configuration de Git pour SSL + run: git config --global http.sslVerify false + + - name: Récupération du code + uses: actions/checkout@v4 + + - name: Configuration de Node.js + uses: actions/setup-node@v4 + with: + node-version: 22 + + - name: Installation des dépendances + run: npm ci + + - name: Compilation de la Build + env: + VITE_APP_ENV: ${{ github.ref_name }} + run: npm run build + + - name: Installation de lftp + run: sudo apt-get update && sudo apt-get install -y lftp + + - name: Routage et Déploiement FTP + env: # 1. On charge tous les secrets de manière sécurisée + SERVER: ${{ secrets.FTP_SERVER }} + DEV_U: ${{ secrets.DEV_FTP_USER }} + DEV_P: ${{ secrets.DEV_FTP_PASSWORD }} + TEST_U: ${{ secrets.TEST_FTP_USER }} + TEST_P: ${{ secrets.TEST_FTP_PASSWORD }} + ACC_U: ${{ secrets.ACC_FTP_USER }} + ACC_P: ${{ secrets.ACC_FTP_PASSWORD }} + PROD_U: ${{ secrets.PROD_FTP_USER }} + PROD_P: ${{ secrets.PROD_FTP_PASSWORD }} + BRANCH: ${{ github.ref_name }} + run: | + # 2. On attribue les bons identifiants selon la branche + if [ "$BRANCH" == "master" ]; then + TARGET_USER=$PROD_U; TARGET_PASS=$PROD_P; DOMAIN="aegis.gise.be" + elif [ "$BRANCH" == "acc" ]; then + TARGET_USER=$ACC_U; TARGET_PASS=$ACC_P; DOMAIN="acc-aegis.gise.be" + elif [ "$BRANCH" == "test" ]; then + TARGET_USER=$TEST_U; TARGET_PASS=$TEST_P; DOMAIN="test-aegis.gise.be" + else + TARGET_USER=$DEV_U; TARGET_PASS=$DEV_P; DOMAIN="dev-aegis.gise.be" + fi + + echo "Déploiement de la branche [$BRANCH] vers le domaine [$DOMAIN]..." + + # 3. Exécution du script FTP (notez le chemin adapté à HestiaCP) + cat << EOF > script.lftp + set ftp:passive-mode true + set ftp:ssl-allow no + set ssl:verify-certificate no + set net:timeout 5 + set net:max-retries 2 + set dns:fatal-timeout 2 + open -u "${TARGET_USER}","${TARGET_PASS}" "${SERVER}" + cd home/${FTP_USER} + mirror -R --delete --verbose dist/ ./ + quit + EOF + + lftp -f script.lftp \ No newline at end of file diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml deleted file mode 100644 index 4eb6716..0000000 --- a/.gitea/workflows/deploy.yml +++ /dev/null @@ -1,61 +0,0 @@ -name: Deploy Aegis Portal - -on: - push: - branches: - - master # Branche principale confirmée - -jobs: - build-and-deploy: - runs-on: ubuntu-latest - - # 1. On désactive la vérification SSL pour tout le conteneur du job (Node.js et Git) - env: - GIT_SSL_NO_VERIFY: "true" - NODE_TLS_REJECT_UNAUTHORIZED: "0" - - steps: - - name: Patch DNS local pour Gitea Runner - run: sudo echo "10.10.40.31 git.bunker.lan" | sudo tee -a /etc/hosts - - # 2. On force l'exécutable Git interne à ignorer la vérification de l'autorité locale - - name: Configuration de Git pour SSL - run: git config --global http.sslVerify false - - - name: Récupération du code - uses: actions/checkout@v4 - - - name: Configuration de Node.js - uses: actions/setup-node@v4 - with: - node-version: 22 - - - name: Installation des dépendances (React/Vite) - run: npm ci - - - name: Compilation de la Build (Aegis) - run: npm run build - - - name: Installation de lftp - run: sudo apt-get update && sudo apt-get install -y lftp - - - name: Déploiement FTP (10.10.40.12) - env: - FTP_USER: ${{ secrets.FTP_USER }} # Le compte FTP enfermé dans aegis.gise.be - FTP_PASSWORD: ${{ secrets.FTP_PASSWORD }} - FTP_SERVER: ${{ secrets.FTP_SERVER }} # Doit contenir : 10.10.40.12 - run: | - cat << EOF > script.lftp - set ftp:passive-mode true - set ftp:ssl-allow no - set ssl:verify-certificate no - set net:timeout 5 - set net:max-retries 2 - set dns:fatal-timeout 2 - open -u "${FTP_USER}","${FTP_PASSWORD}" "${FTP_SERVER}" - cd home/${FTP_USER} - mirror -R --delete --verbose dist/ ./ - quit - EOF - - lftp -f script.lftp \ No newline at end of file diff --git a/.gitea/workflows/enforce-git-flow.yml b/.gitea/workflows/enforce-git-flow.yml new file mode 100644 index 0000000..0c27d93 --- /dev/null +++ b/.gitea/workflows/enforce-git-flow.yml @@ -0,0 +1,39 @@ +name: Sécurité - Architecture Git-Flow + +on: + pull_request: + branches: + - test + - acc + - master + +jobs: + validate-flow: + runs-on: ubuntu-latest + steps: + - name: Vérification du flux de promotion + run: | + TARGET_BRANCH="${{ github.base_ref }}" + SOURCE_BRANCH="${{ github.head_ref }}" + + echo "Tentative de promotion : $SOURCE_BRANCH ➔ $TARGET_BRANCH" + + # Règle 1 : Vers TEST (Doit venir de DEV) + if [ "$TARGET_BRANCH" == "test" ] && [ "$SOURCE_BRANCH" != "dev" ]; then + echo "ERREUR : L'environnement TEST ne peut recevoir que du code de DEV." + exit 1 + fi + + # Règle 2 : Vers ACC (Doit venir de TEST) + if [ "$TARGET_BRANCH" == "acc" ] && [ "$SOURCE_BRANCH" != "test" ]; then + echo "ERREUR : L'environnement d'ACCEPTATION ne peut recevoir que du code de TEST." + exit 1 + fi + + # Règle 3 : Vers PROD (Doit venir de ACC) + if [ "$TARGET_BRANCH" == "master" ] && [ "$SOURCE_BRANCH" != "acc" ]; then + echo "ERREUR : La PRODUCTION ne peut recevoir que du code validé en ACCEPTATION (acc)." + exit 1 + fi + + echo "Flux réglementaire respecté ! Promotion autorisée." \ No newline at end of file diff --git a/.gitea/workflows/quality-checks.yml b/.gitea/workflows/quality-checks.yml new file mode 100644 index 0000000..7b034f8 --- /dev/null +++ b/.gitea/workflows/quality-checks.yml @@ -0,0 +1,54 @@ +name: 🔍 Contrôle Qualité & Sécurité (QA) + +on: + pull_request: + branches: + - dev + - test + - acc + - master + push: + branches: + - dev + +jobs: + quality-gate: + name: 🛡️ Quality Gate & Security Check + runs-on: ubuntu-latest + + env: + GIT_SSL_NO_VERIFY: "true" + NODE_TLS_REJECT_UNAUTHORIZED: "0" + + steps: + - name: Récupération du code source + uses: actions/checkout@v4 + + - name: Configuration de Node.js (v22) + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: 'npm' + + - name: Installation des dépendances + run: npm ci + + # Étape 1 : ESLint (Syntaxe et conventions) + - name: 🧹 Analyse Linter (ESLint) + run: npm run lint + + # Étape 2 : Verification stricte des types TypeScript (sans émettre de fichiers) + - name: 📐 Verification des Types TypeScript + run: npx tsc --noEmit + + # Étape 3 : Exécution des tests unitaires + - name: 🧪 Tests Unitaires (Vitest) + run: npm run test -- --run + + # Étape 4 : Audit des vulnérabilités npm (Niveau High/Critical) + - name: 🔐 Audit de Sécurité des Dépendances + run: npm audit --audit-level=high + + # Étape 5 : Validation de la compilation ViteJS + - name: 🏗️ Validation du Build de Production + run: npm run build \ No newline at end of file From 011f572ef3382ad0c16ef86eeaafcdc691f577c5 Mon Sep 17 00:00:00 2001 From: LathanDevers Date: Mon, 3 Aug 2026 14:18:41 +0200 Subject: [PATCH 02/14] add --- .gitea/workflows/quality-checks.yml | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/.gitea/workflows/quality-checks.yml b/.gitea/workflows/quality-checks.yml index 7b034f8..150e854 100644 --- a/.gitea/workflows/quality-checks.yml +++ b/.gitea/workflows/quality-checks.yml @@ -1,4 +1,4 @@ -name: 🔍 Contrôle Qualité & Sécurité (QA) +name: Contrôle Qualité & Sécurité (QA) on: pull_request: @@ -13,7 +13,7 @@ on: jobs: quality-gate: - name: 🛡️ Quality Gate & Security Check + name: qa-s-check runs-on: ubuntu-latest env: @@ -21,6 +21,12 @@ jobs: NODE_TLS_REJECT_UNAUTHORIZED: "0" steps: + - name: Patch DNS local pour Gitea Runner + run: sudo echo "10.10.40.31 git.bunker.lan" | sudo tee -a /etc/hosts + + - name: Configuration de Git pour SSL + run: git config --global http.sslVerify false + - name: Récupération du code source uses: actions/checkout@v4 @@ -28,27 +34,26 @@ jobs: uses: actions/setup-node@v4 with: node-version: 22 - cache: 'npm' - name: Installation des dépendances run: npm ci # Étape 1 : ESLint (Syntaxe et conventions) - - name: 🧹 Analyse Linter (ESLint) + - name: Analyse Linter (ESLint) run: npm run lint # Étape 2 : Verification stricte des types TypeScript (sans émettre de fichiers) - - name: 📐 Verification des Types TypeScript + - name: Verification des Types TypeScript run: npx tsc --noEmit # Étape 3 : Exécution des tests unitaires - - name: 🧪 Tests Unitaires (Vitest) + - name: Tests Unitaires (Vitest) run: npm run test -- --run # Étape 4 : Audit des vulnérabilités npm (Niveau High/Critical) - - name: 🔐 Audit de Sécurité des Dépendances + - name: Audit de Sécurité des Dépendances run: npm audit --audit-level=high # Étape 5 : Validation de la compilation ViteJS - - name: 🏗️ Validation du Build de Production + - name: Validation du Build de Production run: npm run build \ No newline at end of file From 8d86ccea015350f8e93a077e282faf6245da758d Mon Sep 17 00:00:00 2001 From: LathanDevers Date: Mon, 3 Aug 2026 14:28:07 +0200 Subject: [PATCH 03/14] dev correction --- .gitea/workflows/enforce-git-flow.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitea/workflows/enforce-git-flow.yml b/.gitea/workflows/enforce-git-flow.yml index 0c27d93..b13c402 100644 --- a/.gitea/workflows/enforce-git-flow.yml +++ b/.gitea/workflows/enforce-git-flow.yml @@ -3,6 +3,7 @@ name: Sécurité - Architecture Git-Flow on: pull_request: branches: + - dev - test - acc - master From 3c4d9ec02a7510ab5c7a8c2b7070ac0e672a0e6c Mon Sep 17 00:00:00 2001 From: LathanDevers Date: Mon, 3 Aug 2026 15:40:08 +0200 Subject: [PATCH 04/14] build: migration de la CI vers pnpm --- .env | 0 .env.example | 1 + .gitea/workflows/deploy-environments.yml | 12 ++++++++++-- .gitea/workflows/quality-checks.yml | 15 +++++++++------ 4 files changed, 20 insertions(+), 8 deletions(-) delete mode 100644 .env create mode 100644 .env.example diff --git a/.env b/.env deleted file mode 100644 index e69de29..0000000 diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..984aa81 --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +VITE_PB_URL= \ No newline at end of file diff --git a/.gitea/workflows/deploy-environments.yml b/.gitea/workflows/deploy-environments.yml index 5e61411..9136519 100644 --- a/.gitea/workflows/deploy-environments.yml +++ b/.gitea/workflows/deploy-environments.yml @@ -30,13 +30,21 @@ jobs: with: node-version: 22 + - name: Configuration de Node.js + uses: actions/setup-node@v4 + with: + node-version: 22 + + - name: Activation de pnpm + run: corepack enable pnpm + - name: Installation des dépendances - run: npm ci + run: pnpm install --frozen-lockfile - name: Compilation de la Build env: VITE_APP_ENV: ${{ github.ref_name }} - run: npm run build + run: pnpm run build - name: Installation de lftp run: sudo apt-get update && sudo apt-get install -y lftp diff --git a/.gitea/workflows/quality-checks.yml b/.gitea/workflows/quality-checks.yml index 150e854..1e9e4c1 100644 --- a/.gitea/workflows/quality-checks.yml +++ b/.gitea/workflows/quality-checks.yml @@ -35,25 +35,28 @@ jobs: with: node-version: 22 + - name: Activation de pnpm + run: corepack enable pnpm + - name: Installation des dépendances - run: npm ci + run: pnpm install --frozen-lockfile # Étape 1 : ESLint (Syntaxe et conventions) - name: Analyse Linter (ESLint) - run: npm run lint + run: pnpm run lint # Étape 2 : Verification stricte des types TypeScript (sans émettre de fichiers) - name: Verification des Types TypeScript - run: npx tsc --noEmit + run: pnpm exec tsc --noEmit # Étape 3 : Exécution des tests unitaires - name: Tests Unitaires (Vitest) - run: npm run test -- --run + run: pnpm run test -- --run # Étape 4 : Audit des vulnérabilités npm (Niveau High/Critical) - name: Audit de Sécurité des Dépendances - run: npm audit --audit-level=high + run: pnpm audit --audit-level=high # Étape 5 : Validation de la compilation ViteJS - name: Validation du Build de Production - run: npm run build \ No newline at end of file + run: pnpm run build \ No newline at end of file From 41433b4859bc7138248180917e5d1562c94ec94d Mon Sep 17 00:00:00 2001 From: LathanDevers Date: Mon, 3 Aug 2026 15:57:11 +0200 Subject: [PATCH 05/14] fix: correction des erreurs de linting pour le QA --- src/components/widgets/NewTicketWidget.tsx | 8 +++++--- src/components/widgets/TicketChatWidget.tsx | 2 +- src/hooks/useDocuments.ts | 1 + src/hooks/useInfrastructureNodes.ts | 2 +- src/hooks/useLoginFlow.ts | 3 +-- src/hooks/useTicketDetail.ts | 10 +++++----- src/hooks/useTickets.ts | 1 + src/pages/trustcenter/InfrastructureEvolution.tsx | 1 - src/styles/VariantStyle.ts | 1 + src/types/Category.ts | 1 + 10 files changed, 17 insertions(+), 13 deletions(-) create mode 100644 src/styles/VariantStyle.ts create mode 100644 src/types/Category.ts diff --git a/src/components/widgets/NewTicketWidget.tsx b/src/components/widgets/NewTicketWidget.tsx index cc73dcc..ed9305d 100644 --- a/src/components/widgets/NewTicketWidget.tsx +++ b/src/components/widgets/NewTicketWidget.tsx @@ -5,6 +5,8 @@ import { Button } from '@/components/ui/Button'; import { Input } from '@/components/ui/Input'; import { Select } from '@/components/ui/Select'; import { Textarea } from '@/components/ui/Textarea'; +import type { TicketCategory } from '@/types/Category'; +import type { ButtonVariantStyle } from '@/styles/VariantStyle'; interface NewTicketWidgetProps { onCancel: () => void; @@ -15,13 +17,13 @@ export const NewTicketWidget: React.FC = ({ onCancel, onSu const { createTicket, isSubmitting, error } = useCreateTicket(); // États locaux isolés dans le widget - const [category, setCategory] = useState<'Incident Critique' | 'Évolution' | 'Administratif'>('Incident Critique'); + const [category, setCategory] = useState('Incident Critique'); const [ci, setCi] = useState('general'); const [subject, setSubject] = useState(''); const [affectedAsset, setAffectedAsset] = useState(''); const [incidentTime, setIncidentTime] = useState(''); const [description, setDescription] = useState(''); - const [buttonVariant, setButtonVariant]=useState('primary'); + const [buttonVariant, setButtonVariant]=useState('primary'); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); @@ -62,7 +64,7 @@ export const NewTicketWidget: React.FC = ({ onCancel, onSu