Repository Public
1/**2 * =============================================================================3 * SP BOUCHER | INFRASTRUCTURE & AUTOMATION4 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project : MacLustr Social Engine & Remote Navigator8 * File : scripts/lint.mjs9 * Module : scripts10 * Repository : https://git.spboucher.ai/maclustr-social11 * Project Website : https://social.spboucher.ai12 * Created : 2026-12-0113 * Last Modified : 2026-12-0114 *15 * Author : Simon-Pierre Boucher16 * Position : Professor of Finance17 * Institution : Université du Québec en Outaouais (UQO)18 * Organization : SP Boucher19 * Website : https://spboucher.ai20 * Git : https://git.spboucher.ai21 *22 * Preferred Contact: admin@spboucher.ai23 * Technical Contact: dev@spboucher.ai24 * Security/Admin : admin@spboucher.ai25 *26 * Copyright (c) 202627 * Simon-Pierre Boucher28 * All rights reserved where applicable. This file is governed by the29 * applicable project license, copyright notices and relevant law.30 * Existing third-party rights and notices remain unaffected.31 *32 * License : None specified (no license file in this repository)33 *34 * Do not embed credentials, private keys, access tokens,35 * certificates or confidential personal information.36 *37 * =============================================================================38 * END OF SP BOUCHER SOURCE HEADER39 * =============================================================================40 */4142// Lint + secret scan without extra dependencies. Fails the build on patterns this project forbids outright.43import { readFileSync, readdirSync, statSync } from 'node:fs';44import { join, relative } from 'node:path';45const root = new URL('..', import.meta.url).pathname; const problems = [];46const SKIP = new Set(['node_modules', 'dist', '.git', '.data', 'test-results']);47function* walk(d) { for (const f of readdirSync(d)) { if (SKIP.has(f)) continue; const p = join(d, f); const s = statSync(p); if (s.isDirectory()) yield* walk(p); else yield p; } }48const CODE = [49 [/\beval\s*\(|new Function\s*\(/, 'eval / new Function'],50 [/dangerouslySetInnerHTML|\.innerHTML\s*=/, 'HTML injecté'],51 [/child_process['"]\)?\.?\s*exec\(|\bexecSync\(|shell:\s*true/, 'exécution par shell'],52 [/puppeteer-extra|stealth|undetected|navigator\.webdriver|--disable-blink-features=AutomationControlled/i, 'technique de dissimulation'],53 [/2captcha|anticaptcha|capsolver|solveCaptcha/i, 'contournement de CAPTCHA'],54 [/graph\.facebook\.com|\/api\/graphql|fb_dtsg|c_user|xs=/, 'API Graph / point d’accès privé / jeton Facebook'],55 [/page\.(\$x|locator\(\s*['"`](\/\/|xpath=))/, 'XPath'],56 [/waitForTimeout\(/, 'temporisation arbitraire'],57];58const SECRETS = [[/sk-ant-[A-Za-z0-9_-]{20,}/, 'clé Anthropic'], [/-----BEGIN (RSA |EC |OPENSSH )?PRIVATE KEY-----/, 'clé privée'], [/\b492592\b|\b010402\b/, 'mot de passe sudo'], [/(password|passwd|secret|token)\s*[:=]\s*['"][A-Za-z0-9+/_-]{24,}['"]/i, 'secret en dur'], [/postgres:\/\/[^:\s/]+:[^@\s]+@/, 'mot de passe de base']];59for (const p of walk(root)) {60 const rel = relative(root, p); if (!/\.(ts|tsx|mjs|js|json|sh|sql|md|yml|yaml|plist|swift|css|html|example|caddy)$/.test(p) || rel === 'pnpm-lock.yaml' || rel === 'docs/openapi.json') continue;61 const text = readFileSync(p, 'utf8'); const isCode = /\.(ts|tsx|mjs|js)$/.test(p) && !rel.startsWith('tests/') && rel !== 'scripts/lint.mjs';62 text.split('\n').forEach((line, i) => {63 if (rel !== 'scripts/lint.mjs') for (const [re, what] of SECRETS) if (re.test(line)) problems.push(`${rel}:${i + 1} ${what}`);64 if (isCode) for (const [re, what] of CODE) if (re.test(line)) problems.push(`${rel}:${i + 1} ${what}`);65 });66}67if (problems.length) { console.error(problems.join('\n')); console.error(`\n${problems.length} problème(s)`); process.exit(1); }68console.log('lint + recherche de secrets : aucun problème');69