From a9c35c089226b277dca29f93493695f3cb168d7a Mon Sep 17 00:00:00 2001 From: Pierre Demailly Date: Sun, 1 Jun 2025 15:40:34 +0200 Subject: [PATCH] chore(i18n): add cli & scanner tokens to the documentation --- workspaces/i18n/index.html | 462 +++++++++++++++++- workspaces/i18n/scripts/buildDocumentation.ts | 25 + workspaces/i18n/views/index.html | 52 +- 3 files changed, 537 insertions(+), 2 deletions(-) diff --git a/workspaces/i18n/index.html b/workspaces/i18n/index.html index 261c15d8..db98a1f9 100644 --- a/workspaces/i18n/index.html +++ b/workspaces/i18n/index.html @@ -41,10 +41,470 @@

NodeSecure - i18n

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyValue
executing_atExecuting node-secure at
min_nodejs_versionnode-secure requires at least Node.js {0} to work! Please upgrade your Node.js version.
no_dep_to_proceedNo dependencies to proceed!
successfully_written_jsonSuccessfully written results file at: {0}
http_server_startedHTTP Server started on:
missingEnvEnvironment variable {0} is missing!
commands.option_depthMaximum dependencies depth to fetch
commands.option_outputJson file output name
commands.option_silentenable silent mode which disable CLI spinners
commands.strategyVulnerabilities source to use
commands.cwd.descRun security analysis on the current working dir
commands.cwd.option_nolockDisable usage of package-lock.json
commands.cwd.option_fullEnable full analysis of packages in the package-lock.json file
commands.from.descRun security analysis on a given package from npm registry
commands.from.searchingSearching for '{0}' manifest in the npm registry...
commands.from.fetchedFetched {0} manifest from npm in {1}
commands.auto.descRun security analysis on cwd or a given package and automatically open the web interface
commands.auto.option_keepKeep the nsecure-result.json file on the system after execution
commands.open.descRun an HTTP Server with a given nsecure JSON file
commands.open.option_portDefine the running port
commands.open.option_fresh_startLaunch the server from scratch, ignoring any existing payload file
commands.open.option_developerLaunch the server in developer mode, enabling automatic HTML component refresh
commands.verify.descRun a complete advanced analysis for a given npm package
commands.verify.option_jsonStdout the analysis payload
commands.summary.descDisplay your analysis results
commands.summary.warningsWarnings
commands.lang.descConfigure the CLI default language
commands.lang.question_textWhat language do you want to use?
commands.lang.new_selection'{0}' has been selected as the new CLI language!
commands.scorecard.descDisplay the OSSF Scorecard for a given repository or the current working directory (Github only, e.g. fastify/fastify)
commands.scorecard.option_vcsVersion control platform (GitHub, GitLab)
commands.report.descGenerate a report from a package
commands.report.option_includesAllDepsInclude all dependencies
commands.report.option_themeReport theme ('dark', 'light')
commands.report.option_titleReport title
commands.report.option_reportersList of reporters to use: 'html', 'pdf'
commands.config.descEdit your NodeSecure config file
commands.configCreate.descInit your Nodesecure config file
commands.configCreate.option_cwdCreate config file at the cwd
startHttp.invalidScannerVersionthe payload has been scanned with version '{0}' and do not satisfies the required CLI range '{1}'
startHttp.regenerateplease re-generate a new JSON payload using the CLI
executing_atExécution de node-secure à
min_nodejs_versionnode-secure nécessite au moins Node.js {0} pour fonctionner ! Merci de mettre à jour votre version de Node.js.
no_dep_to_proceedAucune dépendance pour continuer !
successfully_written_jsonEcriture du fichier de résultats réalisée avec succès ici : {0}
http_server_startedServeur HTTP démarré sur :
missingEnvLa variable d'environnement {0} est manquante!
commands.option_depthNiveau de profondeur de dépendances maximum à aller chercher
commands.option_outputNom de sortie du fichier json
commands.option_silentActiver le mode silencieux qui désactive les spinners du CLI
commands.strategySource de vulnérabilités à utiliser
commands.cwd.descDémarre une analyse de sécurité sur le dossier courant
commands.cwd.option_nolockDésactive l'utilisation du package-lock.json
commands.cwd.option_fullActive l'analyse complète des packages présents dans le package-lock.json
commands.from.descDémarre une analyse de sécurité sur un package donné du registre npm
commands.from.searchingRecherche du manifest '{0}' dans le registre npm...
commands.from.fetchedManifest du package {0} importé de npm en {1}
commands.auto.descDémarre une analyse de sécurité sur le dossier courant ou sur un package donné et ouvre automatiquement l'interface web
commands.auto.option_keepConserve le fichier nsecure-result.json sur le systeme après l'exécution
commands.open.descDémarre un serveur HTTP avec un fichier .json nsecure donné
commands.open.option_portPort à utiliser
commands.open.option_fresh_startLance le serveur à partir de zéro, en ignorant tout fichier de payload existant
commands.open.option_developerLance le serveur en mode développeur, permettant le rafraîchissement automatique des composants HTML
commands.verify.descDémarre une analyse AST avancée pour un package npm donné
commands.verify.option_jsonAffiche le résultat d'analyse dans la sortie standard
commands.summary.descAfficher le résultat de votre analyse
commands.summary.warningsMenaces
commands.lang.descConfigure le langage par défaut du CLI
commands.lang.question_textQuel langage souhaitez-vous utiliser ?
commands.lang.new_selection'{0}' a été selectionné comme étant le nouveau langage du CLI !
commands.scorecard.descAfficher la fiche de score OSSF du repo donné ou du repertoire actuel (Github uniquement ex. fastify/fastify)
commands.scorecard.option_vcsLogiciel de gestion de versions (GitHub, GitLab)
commands.report.descGénérer un rapport à partir d'un package
commands.report.option_includesAllDepsInclure toutes les dépendances, true par défaut
commands.report.option_themeThème du rapport ('dark', 'light'), 'light' par défaut
commands.report.option_titleTitre du rapport
commands.report.option_reportersListe des reporters à utiliser 'html', 'pdf'
commands.config.descModifier le fichier de configuration NodeSecure
commands.configCreate.descInitialiser le fichier de configuration Nodesecure
commands.configCreate.option_cwdCréer le fichier dans le dossier courant
startHttp.invalidScannerVersionle fichier d'analyse correspond à la version '{0}' du scanner et ne satisfait pas la range '{1}' attendu par la CLI
startHttp.regenerateveuillez re-générer un nouveau fichier d'analyse JSON en utilisant votre CLI
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyValue
disable_scarfThis dependency could collect data against your consent so think to disable it with the env var: SCARF_ANALYTICS
keyloggingThis dependency can retrieve your keyboard and mouse inputs. It can be used for 'keylogging' attacks/malwares.
disable_scarfCette dépendance peut récolter des données contre votre volonté, pensez donc à la désactiver en fournissant la variable d'environnement SCARF_ANALYTICS
keyloggingCette dépendance peut obtenir vos entrées clavier ou de souris. Cette dépendance peut être utilisée en tant que 'keylogging' attacks/malwares.
diff --git a/workspaces/i18n/scripts/buildDocumentation.ts b/workspaces/i18n/scripts/buildDocumentation.ts index 20652143..e8f8c138 100644 --- a/workspaces/i18n/scripts/buildDocumentation.ts +++ b/workspaces/i18n/scripts/buildDocumentation.ts @@ -1,6 +1,8 @@ // Import Node.js Dependencies import path from "node:path"; import fs from "node:fs"; +import os from "node:os"; +import url from "node:url"; import { fileURLToPath } from "node:url"; // Import Third-party Dependencies @@ -17,6 +19,11 @@ const kTokens = { english, french }; +const kExternalI18nRepos = { + scanner: "workspaces/scanner/src/i18n", + cli: "i18n" +}; +const kTaggedStringPath = url.pathToFileURL(path.join(import.meta.dirname, "../src/utils.js")); function flatten( obj: any, @@ -46,6 +53,24 @@ function formatValue( return typeof obj[key] === "function" ? obj[key](...placeholders) : obj[key]; } +for (const [repo, i18nPath] of Object.entries(kExternalI18nRepos)) { + const frReq = await fetch(`https://raw.githubusercontent.com/NodeSecure/${repo}/refs/heads/master/${i18nPath}/french.js`); + const frRaw = await frReq.text(); + const enReq = await fetch(`https://raw.githubusercontent.com/NodeSecure/${repo}/refs/heads/master/${i18nPath}/english.js`); + const enRaw = await enReq.text(); + + const tmpPathFr = path.join(os.tmpdir(), `fr-${repo}`); + const tmpPathEn = path.join(os.tmpdir(), `en-${repo}`); + fs.writeFileSync(tmpPathFr, frRaw.replace(`from "@nodesecure/i18n";`, `from "${kTaggedStringPath}"`)); + fs.writeFileSync(tmpPathEn, enRaw.replace(`from "@nodesecure/i18n";`, `from "${kTaggedStringPath}"`)); + + const { default: fr } = await import(url.pathToFileURL(tmpPathFr).href); + const { default: en } = await import(url.pathToFileURL(tmpPathEn).href); + + Object.assign(kTokens.french, { [repo]: fr[repo] }); + Object.assign(kTokens.english, { [repo]: en[repo] }); +} + const HTMLStr = fs.readFileSync(path.join(kProjectRootDir, "views", "index.html"), "utf-8"); const templateStr = zup(HTMLStr)({ template: (obj, language) => flatten(kTokens[language][obj]), diff --git a/workspaces/i18n/views/index.html b/workspaces/i18n/views/index.html index ff688d7f..effbee2e 100644 --- a/workspaces/i18n/views/index.html +++ b/workspaces/i18n/views/index.html @@ -41,10 +41,60 @@

NodeSecure - i18n

+
+ + + + + + + + [[ for (props in z.template('cli', 'english')) { ]] + + + + + [[ } ]] + + + [[ for (props in z.template('cli', 'french')) { ]] + + + + + [[ } ]] + +
KeyValue
[[-z.printKey(props)]][[-z.printValue(props, z.template('cli', 'english'))]]
[[-z.printKey(props)]][[-z.printValue(props, z.template('cli', 'french'))]]
+ + + + + + + + + [[ for (props in z.template('scanner', 'english')) { ]] + + + + + [[ } ]] + + + [[ for (props in z.template('scanner', 'french')) { ]] + + + + + [[ } ]] + +
KeyValue
[[-z.printKey(props)]][[-z.printValue(props, z.template('scanner', 'english'))]]
[[-z.printKey(props)]][[-z.printValue(props, z.template('scanner', 'french'))]]