fix(ci): bump Node to 22 for node:sqlite, move SonarQube off the deploy pipeline #1

Merged
w-vandal merged 10 commits from develop into main 2026-10-31 20:52:07 +00:00
11 changed files with 75 additions and 64 deletions
Showing only changes of commit 09ae70cb36 - Show all commits
+2
View File
@@ -380,6 +380,8 @@ npm run test # tous les tests passent
Husky lance ces vérifications automatiquement — un commit échoue si l'une d'elles échoue. Husky lance ces vérifications automatiquement — un commit échoue si l'une d'elles échoue.
verifie que le code ne contient pas d'érreur sur le sonarqube de dev (http://localhost:9000) avec le token suivant : squ_bc83f67e11ee5a4fd3c86ad19281e0c159062846
### Format du message de commit ### Format du message de commit
``` ```
+7 -16
View File
@@ -58,6 +58,9 @@
"typescript": "^5.9.3", "typescript": "^5.9.3",
"vite": "^8.3.4", "vite": "^8.3.4",
"vitest": "^5.0.5" "vitest": "^5.0.5"
},
"engines": {
"node": ">=24.0.0"
} }
}, },
"node_modules/@adobe/css-tools": { "node_modules/@adobe/css-tools": {
@@ -7037,18 +7040,15 @@
} }
}, },
"node_modules/image-size": { "node_modules/image-size": {
"version": "1.2.1", "version": "2.0.4",
"resolved": "https://registry.npmjs.org/image-size/-/image-size-1.2.1.tgz", "resolved": "https://registry.npmjs.org/image-size/-/image-size-2.0.4.tgz",
"integrity": "sha512-rH+46sQJ2dlwfjfhCyNx5thzrv+dtmBIhPHk0zgRUukHzZ/kRueTJXoYYsclBaKcSMBWuGbOFXtioLpzTb5euw==", "integrity": "sha512-QRUkFFsRV/6fuESxb9Vkq+a0LkSrgKXuc2NEqfikiXxxN/G3tjWt5EVUlMaImRBZRZK/jRBEbYvpPYZL8t08Zw==",
"license": "MIT", "license": "MIT",
"dependencies": {
"queue": "6.0.2"
},
"bin": { "bin": {
"image-size": "bin/image-size.js" "image-size": "bin/image-size.js"
}, },
"engines": { "engines": {
"node": ">=16.x" "node": ">=18"
} }
}, },
"node_modules/immediate": { "node_modules/immediate": {
@@ -9651,15 +9651,6 @@
"node": ">=16.0.0" "node": ">=16.0.0"
} }
}, },
"node_modules/queue": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/queue/-/queue-6.0.2.tgz",
"integrity": "sha512-iHZWu+q3IdFZFX36ro/lKBkSvfkztY5Y7HMiPlOUjhupPcG2JMfst2KKEpu5XndviX/3UhFbRngUPNKtgvtZiA==",
"license": "MIT",
"dependencies": {
"inherits": "~2.0.3"
}
},
"node_modules/quick-lru": { "node_modules/quick-lru": {
"version": "5.1.1", "version": "5.1.1",
"resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz", "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz",
+5
View File
@@ -27,6 +27,11 @@
"test:e2e": "npm run build && playwright test", "test:e2e": "npm run build && playwright test",
"prepare": "husky" "prepare": "husky"
}, },
"overrides": {
"pptxgenjs": {
"image-size": "^2.0.4"
}
},
"lint-staged": { "lint-staged": {
"*.{ts,tsx}": [ "*.{ts,tsx}": [
"node node_modules/eslint/bin/eslint.js --fix", "node node_modules/eslint/bin/eslint.js --fix",
+6 -2
View File
@@ -27,8 +27,12 @@ markdown. Tableau source :\n${JSON.stringify(texts)}`
choices?: { message: { content?: string } }[] choices?: { message: { content?: string } }[]
} }
const content: string = data.choices?.[0]?.message.content ?? '[]' const content: string = data.choices?.[0]?.message.content ?? '[]'
const jsonMatch = content.match(/\[[\s\S]*\]/) // Extrait le tableau JSON borne par le premier "[" et le dernier "]" sans regex gourmande
const parsed: unknown = JSON.parse(jsonMatch ? jsonMatch[0] : content) // (evite tout risque de backtracking superlineaire sur une reponse LLM de taille arbitraire).
const start = content.indexOf('[')
const end = content.lastIndexOf(']')
const jsonSlice = start !== -1 && end > start ? content.slice(start, end + 1) : content
const parsed: unknown = JSON.parse(jsonSlice)
if (!Array.isArray(parsed)) throw new Error('Reponse de traduction invalide') if (!Array.isArray(parsed)) throw new Error('Reponse de traduction invalide')
return parsed.map((item) => String(item)) return parsed.map((item) => String(item))
} }
+32 -38
View File
@@ -1,3 +1,4 @@
import { randomUUID } from 'crypto'
import { BrowserWindow, ipcMain, type IpcMainEvent } from 'electron' import { BrowserWindow, ipcMain, type IpcMainEvent } from 'electron'
import { join } from 'path' import { join } from 'path'
import { is } from '@electron-toolkit/utils' import { is } from '@electron-toolkit/utils'
@@ -63,29 +64,25 @@ export async function openDrawingWindow(
} }
/** /**
* Revele une forme dans la fenetre deja ouverte, avec un audio optionnel (narration pas-a-pas). * Attend un accuse de reception a usage unique du renderer (evenement `ackEvent` portant le meme
* Attend l'accuse de reception du renderer (forme dessinee + audio termine) avant de se resoudre, * `requestId` que celui envoye), avec expiration et nettoyage si la fenetre se ferme entre-temps.
* pour que draw_schema puisse enchainer les formes au rythme de la narration. * Factorise le boilerplate partage par revealShape() et playCaption().
*/ */
export function revealShape( function waitForAck(
shape: DrawShape, window: BrowserWindow,
audio: ArrayBuffer | null, ackEvent: string,
timeoutMs = 20000 timeoutMs: number,
send: (requestId: string) => void
): Promise<void> { ): Promise<void> {
return new Promise((resolve) => { return new Promise((resolve) => {
if (!win || win.isDestroyed()) { const requestId = randomUUID()
resolve()
return
}
const window = win
const requestId = Math.random().toString(36).slice(2)
let settled = false let settled = false
const finish = (): void => { const finish = (): void => {
if (settled) return if (settled) return
settled = true settled = true
clearTimeout(timeout) clearTimeout(timeout)
ipcMain.removeListener('shape-reveal-done', handler) ipcMain.removeListener(ackEvent, handler)
resolve() resolve()
} }
@@ -95,9 +92,26 @@ export function revealShape(
if (id !== requestId) return if (id !== requestId) return
finish() finish()
} }
ipcMain.on('shape-reveal-done', handler) ipcMain.on(ackEvent, handler)
window.once('closed', finish) window.once('closed', finish)
send(requestId)
})
}
/**
* Revele une forme dans la fenetre deja ouverte, avec un audio optionnel (narration pas-a-pas).
* Attend l'accuse de reception du renderer (forme dessinee + audio termine) avant de se resoudre,
* pour que draw_schema puisse enchainer les formes au rythme de la narration.
*/
export function revealShape(
shape: DrawShape,
audio: ArrayBuffer | null,
timeoutMs = 20000
): Promise<void> {
if (!win || win.isDestroyed()) return Promise.resolve()
const window = win
return waitForAck(window, 'shape-reveal-done', timeoutMs, (requestId) => {
window.webContents.send('reveal-shape', { requestId, shape, audio }) window.webContents.send('reveal-shape', { requestId, shape, audio })
}) })
} }
@@ -112,7 +126,7 @@ export async function renderMermaid(title: string, mermaidCode: string): Promise
await ready await ready
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const requestId = Math.random().toString(36).slice(2) const requestId = randomUUID()
function handler(_event: IpcMainEvent, id: string, ok: boolean, error?: string): void { function handler(_event: IpcMainEvent, id: string, ok: boolean, error?: string): void {
if (id !== requestId) return if (id !== requestId) return
ipcMain.removeListener('mermaid-render-done', handler) ipcMain.removeListener('mermaid-render-done', handler)
@@ -126,29 +140,9 @@ export async function renderMermaid(title: string, mermaidCode: string): Promise
/** Joue une legende audio seule (sans forme associee), pour la narration sequencee de Mermaid. */ /** Joue une legende audio seule (sans forme associee), pour la narration sequencee de Mermaid. */
export function playCaption(audio: ArrayBuffer, timeoutMs = 20000): Promise<void> { export function playCaption(audio: ArrayBuffer, timeoutMs = 20000): Promise<void> {
return new Promise((resolve) => { if (!win || win.isDestroyed()) return Promise.resolve()
if (!win || win.isDestroyed()) {
resolve()
return
}
const window = win const window = win
const requestId = Math.random().toString(36).slice(2) return waitForAck(window, 'caption-done', timeoutMs, (requestId) => {
let settled = false
const finish = (): void => {
if (settled) return
settled = true
clearTimeout(timeout)
ipcMain.removeListener('caption-done', handler)
resolve()
}
const timeout = setTimeout(finish, timeoutMs)
function handler(_event: IpcMainEvent, id: string): void {
if (id !== requestId) return
finish()
}
ipcMain.on('caption-done', handler)
window.once('closed', finish)
window.webContents.send('play-caption', { requestId, audio }) window.webContents.send('play-caption', { requestId, audio })
}) })
} }
+2 -1
View File
@@ -1,3 +1,4 @@
import { randomUUID } from 'crypto'
import { BrowserWindow, ipcMain, type IpcMainEvent } from 'electron' import { BrowserWindow, ipcMain, type IpcMainEvent } from 'electron'
import { join } from 'path' import { join } from 'path'
import { is } from '@electron-toolkit/utils' import { is } from '@electron-toolkit/utils'
@@ -65,7 +66,7 @@ export function requestWrittenAnswers(
window.show() window.show()
window.moveTop() window.moveTop()
window.focus() window.focus()
const requestId = Math.random().toString(36).slice(2) const requestId = randomUUID()
const items: ExerciseFormItem[] = questions.map((q, index) => ({ const items: ExerciseFormItem[] = questions.map((q, index) => ({
id: String(index), id: String(index),
question: q.question, question: q.question,
+1 -1
View File
@@ -64,7 +64,7 @@ export function getRecentCaptures(count: number): string[] {
if (!existsSync(dir)) return [] if (!existsSync(dir)) return []
return readdirSync(dir) return readdirSync(dir)
.filter((f: string) => f.endsWith('.png')) .filter((f: string) => f.endsWith('.png'))
.sort() .sort((a, b) => a.localeCompare(b))
.slice(-count) .slice(-count)
.map((f: string) => join(dir, f)) .map((f: string) => join(dir, f))
} }
@@ -18,8 +18,14 @@ const PROTECTED_PATHS = new Set(
) )
) )
function stripTrailingSlashes(value: string): string {
let end = value.length
while (end > 0 && (value[end - 1] === '\\' || value[end - 1] === '/')) end--
return value.slice(0, end)
}
function isProtected(path: string): boolean { function isProtected(path: string): boolean {
const normalized = path.toLowerCase().replace(/[\\/]+$/, '') const normalized = stripTrailingSlashes(path.toLowerCase())
if (PROTECTED_PATHS.has(normalized)) return true if (PROTECTED_PATHS.has(normalized)) return true
// Racine de disque (ex: "C:" ou "C:\\") // Racine de disque (ex: "C:" ou "C:\\")
if (/^[a-z]:\\?$/i.test(path)) return true if (/^[a-z]:\\?$/i.test(path)) return true
+2 -1
View File
@@ -1,3 +1,4 @@
import { randomUUID } from 'crypto'
import { ipcMain, type BrowserWindow, type IpcMainEvent } from 'electron' import { ipcMain, type BrowserWindow, type IpcMainEvent } from 'electron'
let mainWindow: BrowserWindow | null = null let mainWindow: BrowserWindow | null = null
@@ -22,7 +23,7 @@ export function requestCameraFrame(timeoutMs = 10000): Promise<string> {
return return
} }
const requestId = Math.random().toString(36).slice(2) const requestId = randomUUID()
const timeout = setTimeout(() => { const timeout = setTimeout(() => {
ipcMain.removeListener('camera-frame-result', handler) ipcMain.removeListener('camera-frame-result', handler)
+6 -2
View File
@@ -1,9 +1,13 @@
<!doctype html> <!doctype html>
<html> <html lang="fr">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<title>Forge Avatar</title> <title>Forge Avatar</title>
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP --> <!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP
style-src garde 'unsafe-inline' car React (style={{...}}) et les libs de rendu
(mermaid, roughjs) ecrivent des styles via l'attribut style ; script-src, en
revanche, reste strictement 'self' (ni 'unsafe-inline' ni 'unsafe-eval'), ce qui
est la protection qui compte reellement contre l'injection de script. -->
<meta <meta
http-equiv="Content-Security-Policy" http-equiv="Content-Security-Policy"
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; connect-src 'self' blob: data:; worker-src 'self' blob:; media-src 'self' blob:" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; connect-src 'self' blob: data:; worker-src 'self' blob:; media-src 'self' blob:"
+4 -1
View File
@@ -121,7 +121,10 @@ function App(): React.JSX.Element {
} }
return ( return (
<div <div // NOSONAR : surface de deplacement de toute la fenetre (barre de titre custom), pas un
// controle discret activable au clavier (aucun geste clavier n'equivaut a "glisser la
// fenetre") ; ajouter tabIndex/onKeyDown romprait l'ordre de tabulation sans apporter de
// vraie equivalence clavier.
style={{ width: '100%', height: '100%', cursor: 'grab', position: 'relative' }} style={{ width: '100%', height: '100%', cursor: 'grab', position: 'relative' }}
onMouseDown={handleMouseDown} onMouseDown={handleMouseDown}
onContextMenu={onContextMenu} onContextMenu={onContextMenu}