vigievuln 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog — VigieVuln
2
2
 
3
+ ## [1.1.1] — Unreleased
4
+
5
+ - Review and explicitly accept the current service terms when a hosted account requires it.
6
+ - Refuse project descriptors larger than 500,000 UTF-8 bytes before upload.
7
+ - Document the renewable one-month free project watch and its expiry.
8
+
3
9
  ## [1.1.0] — 2026-10-28
4
10
 
5
11
  - Hosted proxy scans query CVE, KEV, EUVD and CERT-FR records by dependency or CVE instead of downloading bulk catalogues.
package/README.md CHANGED
@@ -46,8 +46,10 @@ It scans **10 ecosystems + 9 CMS/Frameworks** (WordPress, Drupal, Symfony, Larav
46
46
  ## Migration from fad-checker
47
47
 
48
48
  The npm package and primary command are now `vigievuln`. Existing `fad` and
49
- `fad-checker` commands remain aliases. The cache stays in `~/.fad-checker/` so
50
- existing credentials, warmed data and air-gapped workflows keep working.
49
+ `fad-checker` commands remain aliases. The default cache and configuration directory is `~/.vigie-vuln/`. If it does not exist, an existing `~/.fad-checker/` is automatically renamed to it. If the new directory already exists, it is kept. If the rename fails, a new directory is created and execution continues; the old directory is not merged.
50
+ The separate shared proxy cache similarly migrates from `~/.fad-checker-proxy-cache/` to `~/.vigie-vuln-proxy-cache/` without merging or overwriting an existing new directory. If either rename fails, the CLI warns you, preserves the old directory and uses a new one. Existing cache archives made with `.fad-checker` remain importable.
51
+
52
+ To recover a failed migration, stop the CLI and proxy server, back up and move the new directory out of the way, then rename the old directory to the new name. Remove the corresponding sibling marker, `~/.vigie-vuln.migration-pending` or `~/.vigie-vuln-proxy-cache.migration-pending`, after recovery. Do not overwrite or merge the directories. While both the marker and old directory exist, the warning repeats once per process; if the marker could not be created, only the immediate warning is assured.
51
53
  `VIGIEVULN_ENV` and `.vigievuln-env.json` take precedence over their legacy
52
54
  `FAD_CHECKER_ENV` / `.fad-env.json` counterparts. Default report output is now
53
55
  `./vigievuln-report`; pass `-o` to retain another location.
@@ -63,7 +65,7 @@ A free [NVD API key](https://nvd.nist.gov/developers/request-an-api-key) (instan
63
65
 
64
66
  ### Monitor a project
65
67
 
66
- Create and verify your [account](https://www.vigievuln.fr/account), then:
68
+ Create and verify your [account](https://www.vigievuln.fr/account), then sign in and explicitly accept the [terms of service dated 2026-10-28](https://www.vigievuln.fr/terms) when prompted:
67
69
 
68
70
  ```bash
69
71
  vigievuln login
@@ -75,7 +77,11 @@ vigievuln logout
75
77
 
76
78
  `watch` collects the inventory locally and uploads it once. Run it again with the same unique project name to update that project's inventory; it does not run a background watcher. `login` creates an account session and does not configure the proxy cache.
77
79
 
78
- The free tier includes **one project and up to 100 distinct direct dependency coordinates per project**. Multiple versions of the same coordinate count once. Dependencies whose direct relationship cannot be established are excluded from monitoring and reported as incomplete coverage. This quota applies to hosted monitoring, not local scans.
80
+ The free tier includes **one project and up to 100 distinct direct dependency coordinates per project**. Multiple versions of the same coordinate count once. An uploaded descriptor may be at most **500,000 bytes (0.5 MB decimal)**; an upload exceeding this size or 100 distinct direct coordinates is rejected with an error. Dependencies whose direct relationship cannot be established are excluded from monitoring and reported as incomplete coverage. These limits apply to hosted monitoring, not local scans.
81
+
82
+ Free monitoring expires **one calendar month (UTC)** after a successful `watch` upload. Each successful upload, including a project API push, renews the period for one calendar month (UTC). At expiry, the hosted project and its monitoring data are purged and an expiry email is sent; the account remains. Copies in backups are not deleted immediately.
83
+
84
+ If the current terms have not been accepted, the CLI displays their link and asks for explicit acceptance in an interactive terminal. For non-interactive use, run `vigievuln login` interactively and accept the terms first.
79
85
 
80
86
  To review the inventory before uploading, export it locally:
81
87
 
@@ -83,7 +89,7 @@ To review the inventory before uploading, export it locally:
83
89
  vigievuln watch ./project --export fichier.json
84
90
  ```
85
91
 
86
- `--export` only writes the descriptor: it runs offline, requires no login and sends nothing to the service. Review package names and versions, including private packages, before uploading. Source code, paths and registry URLs are omitted from the descriptor.
92
+ `--export` only writes the descriptor: it runs offline, requires no login, sends nothing to the service and does not renew monitoring. Review package names and versions, including private packages, before uploading. Source code, paths and registry URLs are omitted from the descriptor.
87
93
 
88
94
  Monitoring establishes a silent initial baseline, then reports new high or critical vulnerabilities (CVSS ≥ 7) and known exploited vulnerabilities affecting direct dependencies. Enable alerts in your account and refresh the inventory when dependencies change. [Monitoring workflow and compatibility commands](docs/USAGE.md#project-monitoring).
89
95
 
@@ -98,7 +104,7 @@ vigievuln --set-proxy-cache vigievuln # `default` selects the same official pro
98
104
  vigievuln scan ./code
99
105
  ```
100
106
 
101
- The selection and the proxy key created during proxy sign-in are saved in `~/.fad-checker/config.json` and reused on subsequent scans. This proxy key is separate from the account session used by `watch`. Alternatively, save an existing key with `vigievuln --set-proxy-cache-token <key>`, or provide it via `VIGIEVULN_PROXY_CACHE_TOKEN` (useful in CI). Remove the selection or key with `--unset-proxy-cache` or `--unset-proxy-cache-token`. `--proxy-cache <url>` overrides the saved selection for one scan. The hosted proxy receives requested package coordinates and CVE identifiers; it does not receive your source code. [Proxy documentation](docs/USAGE.md#hosted-vigievuln-proxy).
107
+ The selection and the proxy key created during proxy sign-in are saved in `~/.vigie-vuln/config.json` and reused on subsequent scans. This proxy key is separate from the account session used by `watch`. Alternatively, save an existing key with `vigievuln --set-proxy-cache-token <key>`, or provide it via `VIGIEVULN_PROXY_CACHE_TOKEN` (useful in CI). Remove the selection or key with `--unset-proxy-cache` or `--unset-proxy-cache-token`. `--proxy-cache <url>` overrides the saved selection for one scan. The hosted proxy receives requested package coordinates and CVE identifiers; it does not receive your source code. [Proxy documentation](docs/USAGE.md#hosted-vigievuln-proxy).
102
108
 
103
109
  ### Interactive HTML samples
104
110
 
@@ -200,12 +206,12 @@ vigievuln doesn't just read the `composer.json` under a WordPress or Drupal site
200
206
  | **SPIP** | core (`$spip_version_branche` in `ecrire/inc_version.php`), dist plugins (`paquet.xml`), user plugins (`paquet.xml`/legacy `plugin.xml`) | **NVD product CVEs** (`cpe:2.3:a:spip:spip`) — the only machine-readable SPIP source; plugins stay honestly not-qualified |
201
207
  | **Joomla / Magento (Adobe Commerce)** | core, extensions/modules, themes | no machine-readable publisher feed exists; components locked as Composer packages read as covered by the **dependency lanes**, the rest stays honestly **not qualified**. A Magento source distribution reports its exact version from the root `composer.json` |
202
208
 
203
- Every advisory snapshot a live lane fetches is stamped and cached in `~/.fad-checker/advisory-snapshots/`, carried by `--export-cache`/`--import-cache`, **warmed from the air-gapped descriptor itself** by `--import-anonymized`, and reused automatically offline — the Wordfence API key never travels to the enclave. Private/custom components are inventoried separately and never sent to any publisher. → **[the dedicated guide](docs/CMS-FRAMEWORKS.md)** · [application usage](docs/USAGE.md#application-inventory-experimental)
209
+ Every advisory snapshot a live lane fetches is stamped and cached in `~/.vigie-vuln/advisory-snapshots/`, carried by `--export-cache`/`--import-cache`, **warmed from the air-gapped descriptor itself** by `--import-anonymized`, and reused automatically offline — the Wordfence API key never travels to the enclave. Private/custom components are inventoried separately and never sent to any publisher. → **[the dedicated guide](docs/CMS-FRAMEWORKS.md)** · [application usage](docs/USAGE.md#application-inventory-experimental)
204
210
 
205
211
  ## Air-gapped audits
206
212
 
207
213
  > **Zero-data-sent guarantee.** Under `--offline`, vigievuln makes **no network calls
208
- > whatsoever**; it reads only the warmed `~/.fad-checker/` caches and never transmits a
214
+ > whatsoever**; it reads only the warmed `~/.vigie-vuln/` caches and never transmits a
209
215
  > dependency, path or finding off the machine. It is regression-tested
210
216
  > (`test/offline-guarantee.test.js`, a tripwire fetcher that throws if touched) and
211
217
  > auditor-reproducible: `unshare -rn node vigievuln.js -s ./proj --offline …` runs it in a
@@ -235,7 +241,7 @@ vigievuln -s ./proj -e "^(client|internal)\." --export-anonymized deps.json
235
241
  vigievuln --import-anonymized deps.json # scans coordinates → OSV/NVD/CVE/registry/EOL + retire signatures
236
242
  # + warms the CMS advisory snapshots (Drupal/PrestaShop/TYPO3 feeds,
237
243
  # WP checksums per core version, Wordfence when a key is set)
238
- vigievuln --export-cache fad-cache.tar.gz # bundle the warmed ~/.fad-checker/
244
+ vigievuln --export-cache fad-cache.tar.gz # bundle the warmed ~/.vigie-vuln/
239
245
 
240
246
  # ── Phase 3; OFFLINE (audited machine): full report, all local context ──
241
247
  vigievuln --import-cache fad-cache.tar.gz # merged into the enclave's own cache
@@ -18,6 +18,18 @@ class AccountClientError extends Error {
18
18
  const invalidResponse = () => new AccountClientError('INVALID_RESPONSE', 'Invalid account API response.');
19
19
  const isAccount = value => value && typeof value === 'object' && !Array.isArray(value) &&
20
20
  typeof value.id === 'string' && value.id.length > 0 && typeof value.email === 'string' && value.email.length > 0;
21
+ function readTerms(value) {
22
+ if (!value || typeof value !== 'object' || Array.isArray(value) ||
23
+ typeof value.version !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9._-]{0,199}$/.test(value.version) ||
24
+ typeof value.documentUrl !== 'string' || value.documentUrl.length > 2048 ||
25
+ /[\x00-\x20\x7f]/.test(value.documentUrl) || typeof value.accepted !== 'boolean') throw invalidResponse();
26
+ let url;
27
+ try { url = new URL(value.documentUrl, ACCOUNT_ORIGIN); } catch { throw invalidResponse(); }
28
+ if (url.protocol !== 'https:' || url.origin !== ACCOUNT_ORIGIN || url.username || url.password ||
29
+ url.pathname !== '/terms/' + value.version || url.search || url.hash ||
30
+ ![url.pathname, ACCOUNT_ORIGIN + url.pathname].includes(value.documentUrl)) throw invalidResponse();
31
+ return { version: value.version, url: url.href, accepted: value.accepted };
32
+ }
21
33
 
22
34
  /**
23
35
  * Account authentication for future project commands; no proxy config or keys.
@@ -118,13 +130,14 @@ function createAccountClient({ fetcher = globalThis.fetch, now = Date.now,
118
130
  try { session = validateAccountSession(data, now()); }
119
131
  catch { throw invalidResponse(); }
120
132
  if (data.tokenType !== 'Bearer' || !isAccount(data.account)) throw invalidResponse();
133
+ const terms = readTerms(data.account.terms);
121
134
  try { await sessionStore.write(session); }
122
135
  catch (error) {
123
136
  // Avoid leaving a newly issued session alive when local persistence fails.
124
137
  try { await request('logout', 'POST', {}, session.token); } catch { /* expires server-side */ }
125
138
  throw error;
126
139
  }
127
- return { account: data.account, expiresAt: session.expiresAt };
140
+ return { account: data.account, expiresAt: session.expiresAt, ...(terms && { terms }) };
128
141
  }
129
142
 
130
143
  async function me() {
@@ -132,13 +145,26 @@ function createAccountClient({ fetcher = globalThis.fetch, now = Date.now,
132
145
  try {
133
146
  const data = await request('me', 'GET', undefined, session.token);
134
147
  if (!isAccount(data.account)) throw invalidResponse();
135
- return { account: data.account };
148
+ const terms = readTerms(data.account.terms);
149
+ return { account: data.account, ...(terms && { terms }) };
136
150
  } catch (error) {
137
151
  if (error.code === 'UNAUTHORIZED') await sessionStore.clear();
138
152
  throw error;
139
153
  }
140
154
  }
141
155
 
156
+ async function acceptTerms(version) {
157
+ if (typeof version !== 'string' || !version || version.length > 200 || /[\x00-\x1f\x7f]/.test(version)) {
158
+ throw new AccountClientError('INVALID_TERMS', 'A valid terms version is required.');
159
+ }
160
+ const session = await currentSession();
161
+ const data = await request('terms', 'POST', { termsVersion: version, accepted: true }, session.token);
162
+ if (!isAccount(data.account)) throw invalidResponse();
163
+ const terms = readTerms(data.account.terms);
164
+ if (!terms || !terms.accepted || terms.version !== version) throw invalidResponse();
165
+ return { terms };
166
+ }
167
+
142
168
  async function createProxyKey() {
143
169
  const session = await currentSession();
144
170
  const data = await request('proxy-keys', 'POST', { name: 'VigieVuln CLI' }, session.token);
@@ -159,7 +185,7 @@ function createAccountClient({ fetcher = globalThis.fetch, now = Date.now,
159
185
  } finally { await sessionStore.clear(); }
160
186
  }
161
187
 
162
- return { login, logout, me, createProxyKey };
188
+ return { login, logout, me, createProxyKey, acceptTerms };
163
189
  }
164
190
 
165
191
  module.exports = { ACCOUNT_ORIGIN, DEFAULT_TIMEOUT_MS, createAccountClient, AccountClientError };
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ async function requireTerms({account, terms, ask, interactive = !!(process.stdin.isTTY && process.stderr.isTTY), warn = console.error}) {
4
+ if (!terms) throw new Error('unable to verify current terms; please retry or contact support');
5
+ if (terms.accepted) return;
6
+ warn(`Vigie Vuln terms of service (version ${terms.version}): ${terms.url}`);
7
+ if (!interactive) throw new Error('terms acceptance required: run vigievuln login in an interactive terminal, then retry');
8
+ const answer = await ask('Accept these terms? Type yes to accept: ');
9
+ if (typeof answer !== 'string' || answer.trim().toLowerCase() !== 'yes')
10
+ throw new Error('terms not accepted; run vigievuln login to review them');
11
+ await account.acceptTerms(terms.version);
12
+ }
13
+ module.exports = { requireTerms };
@@ -29,7 +29,7 @@ const { execFile, spawn } = require("child_process");
29
29
  const { promisify } = require("util");
30
30
  const execFileP = promisify(execFile);
31
31
 
32
- const FAD_CACHE_DIR = path.join(os.homedir(), ".fad-checker");
32
+ const FAD_CACHE_DIR = require("./cache-directory").getCacheDir({homeDir:os.homedir()});
33
33
 
34
34
  /**
35
35
  * Files inside ~/.fad-checker/ that hold secrets and should NOT be shipped by default.
@@ -210,7 +210,7 @@ async function runTar(args, archive, cwd, writing, verbose) {
210
210
 
211
211
  async function exportCache(destFile, opts = {}) {
212
212
  const { verbose, includeConfig } = opts;
213
- if (!fs.existsSync(FAD_CACHE_DIR)) throw new Error(`no ~/.fad-checker/ directory to export`);
213
+ if (!fs.existsSync(FAD_CACHE_DIR)) throw new Error(`no ~/.vigie-vuln/ directory to export`);
214
214
  const abs = path.resolve(destFile);
215
215
  fs.mkdirSync(path.dirname(abs), { recursive: true });
216
216
 
@@ -284,33 +284,31 @@ async function importCache(srcFile, opts = {}) {
284
284
  const replace = !!(opts.replace || force);
285
285
  const abs = path.resolve(srcFile);
286
286
  if (!fs.existsSync(abs)) throw new Error(`archive not found: ${abs}`);
287
- const parent = path.dirname(FAD_CACHE_DIR);
288
-
289
- if (replace) {
290
- if (fs.existsSync(FAD_CACHE_DIR) && !force) {
291
- // Move existing aside as .fad-checker.bak-<timestamp>
292
- const backup = `${FAD_CACHE_DIR}.bak-${Date.now()}`;
293
- fs.renameSync(FAD_CACHE_DIR, backup);
294
- if (verbose) console.log(`💾 existing ~/.fad-checker/ moved to ${backup}`);
295
- } else if (force && fs.existsSync(FAD_CACHE_DIR)) {
296
- fs.rmSync(FAD_CACHE_DIR, { recursive: true, force: true });
297
- if (verbose) console.log(`🗑 --force: existing ~/.fad-checker/ removed`);
298
- }
299
- await extractTo(abs, parent, verbose);
300
- if (!fs.existsSync(FAD_CACHE_DIR)) {
301
- throw new Error(`import completed but ~/.fad-checker/ was not created — was the archive built with vigievuln --export-cache?`);
302
- }
303
- return { dir: FAD_CACHE_DIR, mode: "replace" };
304
- }
305
287
 
306
288
  // Merge: unpack beside the cache (same filesystem), reconcile, drop the staging dir.
307
289
  const staging = `${FAD_CACHE_DIR}.import-${process.pid}-${Date.now()}`;
308
290
  const stats = { added: 0, updated: 0, merged: 0, kept: 0, skipped: [] };
309
291
  try {
310
292
  await extractTo(abs, staging, verbose);
311
- const incoming = path.join(staging, path.basename(FAD_CACHE_DIR));
312
- if (!fs.existsSync(incoming)) {
313
- throw new Error(`archive holds no ${path.basename(FAD_CACHE_DIR)}/ directory — was it built with vigievuln --export-cache?`);
293
+ const modern = path.join(staging, path.basename(FAD_CACHE_DIR));
294
+ const legacy = path.join(staging, '.fad-checker');
295
+ // Windows Compress-Archive historically emitted the cache contents at
296
+ // the ZIP root, whereas tar and Unix ZIP preserve the directory name.
297
+ const flatWindowsZip = process.platform === 'win32' && abs.toLowerCase().endsWith('.zip');
298
+ const incoming = fs.existsSync(modern) ? modern : fs.existsSync(legacy) ? legacy : flatWindowsZip ? staging : legacy;
299
+ if (!fs.existsSync(incoming) || !fs.lstatSync(incoming).isDirectory()) {
300
+ throw new Error(`archive holds no .vigie-vuln/ or .fad-checker/ directory — was it built with vigievuln --export-cache?`);
301
+ }
302
+ if (replace) {
303
+ if (fs.existsSync(FAD_CACHE_DIR) && !force) {
304
+ const backup = `${FAD_CACHE_DIR}.bak-${Date.now()}`;
305
+ fs.renameSync(FAD_CACHE_DIR, backup);
306
+ if (verbose) console.log(`💾 existing ~/.vigie-vuln/ moved to ${backup}`);
307
+ } else if (force && fs.existsSync(FAD_CACHE_DIR)) {
308
+ fs.rmSync(FAD_CACHE_DIR, {recursive:true, force:true});
309
+ }
310
+ fs.renameSync(incoming, FAD_CACHE_DIR);
311
+ return {dir:FAD_CACHE_DIR, mode:'replace'};
314
312
  }
315
313
  fs.mkdirSync(FAD_CACHE_DIR, { recursive: true });
316
314
  mergeTree(incoming, FAD_CACHE_DIR, stats);
@@ -0,0 +1,77 @@
1
+ 'use strict';
2
+ const fs = require('node:fs');
3
+ const path = require('node:path');
4
+ const os = require('node:os');
5
+ const {spawnSync} = require('node:child_process');
6
+ const warned = new Set();
7
+
8
+ // The cache is separate from account sessions and from the proxy server store.
9
+ function resolveDirectory(currentName, legacyName, {homeDir = os.homedir(), fsImpl = fs, platform = process.platform, spawn = spawnSync, warn = console.error} = {}) {
10
+ const current = path.join(homeDir, currentName);
11
+ const legacy = path.join(homeDir, legacyName);
12
+ const marker = path.join(homeDir, currentName + '.migration-pending');
13
+ const stat = file => {
14
+ try { return fsImpl.lstatSync(file); }
15
+ catch (error) { if (error.code === 'ENOENT') return null; throw error; }
16
+ };
17
+ const checkCurrent = () => {
18
+ const entry = stat(current);
19
+ if (entry && (entry.isSymbolicLink() || !entry.isDirectory()))
20
+ throw new Error('VigieVuln cache directory must be a directory, not a symbolic link');
21
+ return entry;
22
+ };
23
+ const warnPending = () => {
24
+ if (warned.has(current)) return;
25
+ warned.add(current);
26
+ const show = value => '"' + value.replace(/[\x00-\x1f\x7f"]/g, c => c === '"' ? '\\"' : `\\u${c.charCodeAt(0).toString(16).padStart(4, '0')}`) + '"';
27
+ let previous;
28
+ try { previous = stat(legacy); } catch { /* leave recovery to the user */ }
29
+ const recovery = previous?.isDirectory() && !previous.isSymbolicLink()
30
+ ? `Stop VigieVuln, back up or move ${show(current)}, then rename ${show(legacy)} to ${show(current)}.`
31
+ : `Stop VigieVuln and inspect ${show(legacy)} safely; it is not a regular directory and requires manual recovery.`;
32
+ warn(`VigieVuln cache migration failed; previous data remains at ${show(legacy)} and is not being used. ` +
33
+ `${recovery} After recovery, remove ${show(marker)}.`);
34
+ };
35
+ if (checkCurrent()) {
36
+ let pending;
37
+ try { pending = stat(marker); } catch { /* an unreadable reminder must not block the cache */ }
38
+ if (pending && pending.isFile() && !pending.isSymbolicLink()) {
39
+ let previous;
40
+ try { previous = stat(legacy); } catch { previous = true; }
41
+ if (previous) warnPending();
42
+ }
43
+ return current;
44
+ }
45
+ const old = stat(legacy);
46
+ if (!old) return current;
47
+ // Do not let an mv fallback copy or delete a cache on another filesystem.
48
+ const parent = stat(homeDir);
49
+ if (old.isDirectory() && !old.isSymbolicLink() && parent && old.dev === parent.dev) {
50
+ try {
51
+ if (!checkCurrent()) {
52
+ // Node's POSIX rename can replace an empty destination created concurrently.
53
+ // GNU mv -n -T uses no-clobber semantics. Darwin's renameatx_np
54
+ // syscall with RENAME_EXCL refuses an existing destination atomically.
55
+ // Windows rename refuses a target. On failure retain the old directory.
56
+ if (platform === 'linux') spawn('/bin/mv', ['-n', '-T', '--', legacy, current], {stdio:'ignore'});
57
+ else if (platform === 'darwin') spawn('/usr/bin/perl', ['-e',
58
+ 'exit(syscall(488, -2, $ARGV[0], -2, $ARGV[1], 4) == 0 ? 0 : 1)', legacy, current], {stdio:'ignore'});
59
+ else if (platform === 'win32') fsImpl.renameSync(legacy, current);
60
+ }
61
+ } catch { /* Keep the legacy data and fall back to a fresh directory. */ }
62
+ }
63
+ if (!checkCurrent()) {
64
+ try { fsImpl.mkdirSync(current, {mode:0o700}); }
65
+ catch (error) { if (error.code !== 'EEXIST') throw error; }
66
+ checkCurrent();
67
+ }
68
+ if (stat(legacy)) {
69
+ // The marker contains no paths or configuration and is never overwritten.
70
+ try { fsImpl.writeFileSync(marker, '', {flag:'wx', mode:0o600}); } catch { /* warning still appears now */ }
71
+ warnPending();
72
+ }
73
+ return current;
74
+ }
75
+ const getCacheDir = options => resolveDirectory('.vigie-vuln', '.fad-checker', options);
76
+ const getProxyCacheDir = options => resolveDirectory('.vigie-vuln-proxy-cache', '.fad-checker-proxy-cache', options);
77
+ module.exports = {getCacheDir, getProxyCacheDir};
package/lib/certfr.js CHANGED
@@ -20,7 +20,7 @@ const fs = require("fs");
20
20
  const path = require("path");
21
21
  const os = require("os");
22
22
 
23
- const DEFAULT_CACHE_DIR = path.join(os.homedir(), ".fad-checker");
23
+ const DEFAULT_CACHE_DIR = path.join(require("./cache-directory").getCacheDir());
24
24
  const CACHE_FILE = "certfr-cache.json";
25
25
  const CACHE_TTL_MS = 24 * 3600 * 1000;
26
26
  const KINDS = ["avis", "alerte"];
@@ -3,8 +3,9 @@ const fs=require("node:fs");
3
3
  const readline=require("node:readline");
4
4
  const {Writable}=require("node:stream");
5
5
  const {createAccountClient}=require("./account-client");
6
+ const {requireTerms}=require("./account-terms");
6
7
  const {createAccountSessionStore}=require("./account-session");
7
- const {projectRequest,createProject,updateProject}=require("./project-client");
8
+ const {projectRequest,createProject,updateProject,sanitizeDescriptor,checkDescriptorSize,MAX_DESCRIPTOR_BYTES}=require("./project-client");
8
9
 
9
10
  function prompt(label,secret=false) {
10
11
  if (!process.stdin.isTTY || !process.stderr.isTTY) throw new Error("interactive login requires a terminal");
@@ -25,7 +26,7 @@ async function ensureSignedIn({account,store,ask=prompt,interactive=!!(process.s
25
26
  if(store.read()) {
26
27
  try {
27
28
  const result=await account.me(),session=store.read();
28
- if(session)return {session,account:result.account};
29
+ if(session){await requireTerms({account,terms:result.terms,ask,interactive,warn});return {session,account:result.account};}
29
30
  }
30
31
  catch(error) {if(!['UNAUTHORIZED','NOT_AUTHENTICATED','SESSION_EXPIRED'].includes(error.code))throw error;}
31
32
  }
@@ -33,6 +34,7 @@ async function ensureSignedIn({account,store,ask=prompt,interactive=!!(process.s
33
34
  warn('Sign in to your Vigie Vuln account. Register: https://www.vigievuln.fr/account');
34
35
  const email=await ask('Email: '), password=await ask('Password: ',true);
35
36
  const result=await account.login({email,password});
37
+ await requireTerms({account,terms:result.terms,ask,interactive,warn});
36
38
  return {session:store.read(),account:result.account};
37
39
  }
38
40
  async function run(args, dependencies={}) {
@@ -60,6 +62,18 @@ async function run(args, dependencies={}) {
60
62
  if(command!=='status' && (command!=='push' || !opts['--file'] || (!!opts['--name'] === !!opts['--id'])))
61
63
  throw new Error('usage: vigievuln project push --file <descriptor> (--name <new project> | --id <existing project>)');
62
64
  if(command==='status' && Object.keys(opts).length)throw new Error('project status takes no options');
65
+ let descriptor;
66
+ if(command==='push') {
67
+ const stat=fs.statSync(opts['--file']);
68
+ if(!stat.isFile())throw new Error('invalid descriptor file');
69
+ if(stat.size>MAX_DESCRIPTOR_BYTES)throw new Error(`project descriptor exceeds the upload limit of ${MAX_DESCRIPTOR_BYTES} UTF-8 bytes`);
70
+ const bytes=fs.readFileSync(opts['--file']);
71
+ if(bytes.length>MAX_DESCRIPTOR_BYTES)throw new Error(`project descriptor exceeds the upload limit of ${MAX_DESCRIPTOR_BYTES} UTF-8 bytes`);
72
+ try {descriptor=JSON.parse(bytes.toString('utf8'));}
73
+ catch {throw new Error('unable to read project descriptor as JSON');}
74
+ checkDescriptorSize(descriptor);
75
+ checkDescriptorSize(sanitizeDescriptor(descriptor));
76
+ }
63
77
  const {session}=await ensureSignedIn({account,store,...dependencies});
64
78
  if(command==='status') {
65
79
  const data=await projectRequest('/v1/projects',{session:session.token});
@@ -67,9 +81,6 @@ async function run(args, dependencies={}) {
67
81
  for(const p of data.projects)console.log(`${p.id}\t${p.name}\trevision ${p.revision}`);
68
82
  if(!data.projects.length)console.log('No projects.');return;
69
83
  }
70
- const stat=fs.statSync(opts['--file']);if(!stat.isFile() || stat.size>1900000)throw new Error('invalid or oversized descriptor file');
71
- let descriptor;try {descriptor=JSON.parse(fs.readFileSync(opts['--file'],'utf8'));}
72
- catch {throw new Error('unable to read project descriptor as JSON');}
73
84
  console.error('Project coordinates and versions will be stored on the service. Review and exclude private packages before uploading.');
74
85
  let result;
75
86
  if(opts['--name']) result=await createProject({session:session.token,name:opts['--name'],descriptor});
package/lib/cli-watch.js CHANGED
@@ -3,7 +3,7 @@ const fs = require('node:fs');
3
3
  const path = require('node:path');
4
4
  const { Command } = require('commander');
5
5
  const { buildProjectDescriptor } = require('./project-descriptor');
6
- const { sanitizeDescriptor, projectRequest, createProject, updateProject } = require('./project-client');
6
+ const { sanitizeDescriptor, checkDescriptorSize, projectRequest, createProject, updateProject } = require('./project-client');
7
7
  const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
8
8
 
9
9
  function watchCommand() {
@@ -79,6 +79,7 @@ async function runWatch(args, { ensureSession, log = console.log, warn = console
79
79
  return;
80
80
  }
81
81
  if (!descriptor.deps.length) throw new Error('no dependencies collected; refusing to upload an empty project inventory');
82
+ checkDescriptorSize(descriptor);
82
83
  const session = await ensureSession();
83
84
  let current;
84
85
  const validateProject = p => p && UUID.test(p.id) && typeof p.name === 'string' && Number.isSafeInteger(p.revision) && p.revision > 0;
@@ -18,7 +18,7 @@ let pLimit; try { pLimit = require("p-limit"); } catch { pLimit = () => (fn) =>
18
18
  const { authHeaderFor, normalise } = require("../../registries");
19
19
  const { belongsToOtherComposerRegistry } = require("../../packagist-audit");
20
20
 
21
- const CACHE_DIR = path.join(os.homedir(), ".fad-checker");
21
+ const CACHE_DIR = path.join(require("../../cache-directory").getCacheDir());
22
22
  const CACHE_PATH = path.join(CACHE_DIR, "packagist-cache.json");
23
23
  const CACHE_MAX_AGE_MS = 24 * 3600 * 1000;
24
24
  const API = "https://packagist.org/packages";
@@ -16,7 +16,7 @@ const os = require("os");
16
16
  let pLimit; try { pLimit = require("p-limit"); } catch { pLimit = () => (fn) => fn(); }
17
17
  const { withPublic, authHeaderFor, normalise } = require("../../registries");
18
18
 
19
- const CACHE_DIR = path.join(os.homedir(), ".fad-checker");
19
+ const CACHE_DIR = path.join(require("../../cache-directory").getCacheDir());
20
20
  const CACHE_PATH = path.join(CACHE_DIR, "go-proxy-cache.json");
21
21
  const CACHE_MAX_AGE_MS = 24 * 3600 * 1000;
22
22
 
@@ -24,7 +24,7 @@ const pLimit = require("p-limit");
24
24
  const { semverCompare, webjarToNpm } = require("./collect");
25
25
  const { withPublic, authHeaderFor, normalise } = require("../../registries");
26
26
 
27
- const CACHE_DIR = path.join(os.homedir(), ".fad-checker");
27
+ const CACHE_DIR = path.join(require("../../cache-directory").getCacheDir());
28
28
  const CACHE_PATH = path.join(CACHE_DIR, "npm-registry-cache.json");
29
29
  const CACHE_MAX_AGE_MS = 24 * 3600 * 1000; // 1 day, aligned with Maven Central
30
30
 
@@ -17,7 +17,7 @@ const os = require("os");
17
17
  let pLimit; try { pLimit = require("p-limit"); } catch { pLimit = () => (fn) => fn(); }
18
18
  const { withPublic, authHeaderFor, normalise } = require("../../registries");
19
19
 
20
- const CACHE_DIR = path.join(os.homedir(), ".fad-checker");
20
+ const CACHE_DIR = path.join(require("../../cache-directory").getCacheDir());
21
21
  const CACHE_PATH = path.join(CACHE_DIR, "nuget-cache.json");
22
22
  const CACHE_MAX_AGE_MS = 24 * 3600 * 1000;
23
23
 
@@ -17,7 +17,7 @@ const os = require("os");
17
17
  let pLimit; try { pLimit = require("p-limit"); } catch { pLimit = () => (fn) => fn(); }
18
18
  const { withPublic, authHeaderFor, normalise } = require("../../registries");
19
19
 
20
- const CACHE_DIR = path.join(os.homedir(), ".fad-checker");
20
+ const CACHE_DIR = path.join(require("../../cache-directory").getCacheDir());
21
21
  const CACHE_PATH = path.join(CACHE_DIR, "pypi-cache.json");
22
22
  const CACHE_MAX_AGE_MS = 24 * 3600 * 1000;
23
23
 
@@ -14,7 +14,7 @@ const os = require("os");
14
14
  let pLimit; try { pLimit = require("p-limit"); } catch { pLimit = () => (fn) => fn(); }
15
15
  const { withPublic, authHeaderFor, normalise } = require("../../registries");
16
16
 
17
- const CACHE_DIR = path.join(os.homedir(), ".fad-checker");
17
+ const CACHE_DIR = path.join(require("../../cache-directory").getCacheDir());
18
18
  const CACHE_PATH = path.join(CACHE_DIR, "rubygems-cache.json");
19
19
  const CACHE_MAX_AGE_MS = 24 * 3600 * 1000;
20
20
 
package/lib/config.js CHANGED
@@ -11,7 +11,7 @@ const fs = require("fs");
11
11
  const path = require("path");
12
12
  const os = require("os");
13
13
 
14
- const CONFIG_DIR = path.join(os.homedir(), ".fad-checker");
14
+ const CONFIG_DIR = path.join(require("./cache-directory").getCacheDir());
15
15
  const CONFIG_PATH = path.join(CONFIG_DIR, "config.json");
16
16
 
17
17
  function load() {
@@ -20,7 +20,7 @@ const execFileP = promisify(execFile);
20
20
 
21
21
  const { compareMavenVersions, versionLikeBound } = require("./maven-version");
22
22
 
23
- const CVE_DATA_DIR = path.join(os.homedir(), ".fad-checker", "cve-data");
23
+ const CVE_DATA_DIR = path.join(require("./cache-directory").getCacheDir(), "cve-data");
24
24
  const CVE_INDEX_PATH = path.join(CVE_DATA_DIR, "maven-cve-index.json");
25
25
  const CVE_META_PATH = path.join(CVE_DATA_DIR, "meta.json");
26
26
  const CVE_EXTRACT_DIR = path.join(CVE_DATA_DIR, "extracted");
package/lib/epss.js CHANGED
@@ -14,7 +14,7 @@ const fs = require("fs");
14
14
  const path = require("path");
15
15
  const os = require("os");
16
16
 
17
- const CACHE_DIR = path.join(os.homedir(), ".fad-checker");
17
+ const CACHE_DIR = path.join(require("./cache-directory").getCacheDir());
18
18
  const CACHE_PATH = path.join(CACHE_DIR, "epss-cache.json");
19
19
  const CACHE_TTL_MS = 24 * 3600 * 1000;
20
20
  const EPSS_BASE = "https://api.first.org/data/v1/epss";
package/lib/euvd.js CHANGED
@@ -23,7 +23,7 @@ const fs = require("fs");
23
23
  const path = require("path");
24
24
  const os = require("os");
25
25
 
26
- const DEFAULT_CACHE_DIR = path.join(os.homedir(), ".fad-checker");
26
+ const DEFAULT_CACHE_DIR = path.join(require("./cache-directory").getCacheDir());
27
27
  const CACHE_FILE = "euvd-cache.json";
28
28
  const CACHE_TTL_MS = 24 * 3600 * 1000;
29
29
  const MAX_PAGES = 200;
package/lib/hash-id.js CHANGED
@@ -15,7 +15,7 @@ const fs = require("fs");
15
15
  const path = require("path");
16
16
  const os = require("os");
17
17
 
18
- const CACHE_DIR = path.join(os.homedir(), ".fad-checker");
18
+ const CACHE_DIR = path.join(require("./cache-directory").getCacheDir());
19
19
  const CACHE_PATH = path.join(CACHE_DIR, "hash-id-cache.json");
20
20
  const CACHE_TTL_MS = 24 * 3600 * 1000;
21
21
  const DEPSDEV = "https://api.deps.dev/v3/query";
@@ -14,23 +14,25 @@ function resolveHostedProxy(options, env = process.env) {
14
14
  return { proxyCache: ORIGINS[domain], proxyCacheToken: token || null, vigievulnProxy: domain };
15
15
  }
16
16
 
17
- async function loginForProxy({ origin, email, password, fetcher = globalThis.fetch }) {
18
- // Both public domains use the same account service; .com redirects to .fr.
19
- const accountOrigin = 'https://www.vigievuln.fr';
20
- const post = (path, body, token) => fetcher(accountOrigin + path, { method:'POST', redirect:'error',
21
- headers:{'content-type':'application/json', ...(token ? {authorization:'Bearer '+token} : {})},
22
- body:JSON.stringify(body), signal:AbortSignal.timeout(15000) });
23
- const login = await post('/v1/accounts/login', {email,password});
24
- if (!login.ok) throw new Error(`VigieVuln login failed (HTTP ${login.status}); check your credentials and verified account`);
25
- const session = (await login.json()).token;
26
- if (typeof session !== 'string' || !session) throw new Error('invalid account login response');
17
+ async function loginForProxy({ email, password, fetcher = globalThis.fetch, ask, interactive, warn }) {
18
+ const {createAccountClient} = require('./account-client');
19
+ const {requireTerms} = require('./account-terms');
20
+ let session = null;
21
+ const store = {read:()=>session, write:value=>{session=value;}, clear:()=>{session=null;}};
22
+ const account = createAccountClient({fetcher, sessionStore:store});
23
+ const login = await account.login({email,password});
27
24
  try {
28
- const response = await post('/v1/accounts/proxy-keys', {name:'VigieVuln CLI'}, session);
29
- if (!response.ok) throw new Error(`proxy key creation failed (HTTP ${response.status}); check your account key limit`);
30
- const data = await response.json();
31
- if (typeof data?.key?.token !== 'string' || !data.key.token) throw new Error('invalid proxy key response');
32
- return data.key.token;
33
- } finally { try { await post('/v1/accounts/logout', {}, session); } catch { /* session expires automatically */ } }
25
+ await requireTerms({account, terms:login.terms, ask, interactive, warn});
26
+ return await createProxyKey(account);
27
+ } finally { try { await account.logout(); } catch { /* session expires automatically */ } }
28
+ }
29
+
30
+ async function createProxyKey(account) {
31
+ try { return (await account.createProxyKey()).token; }
32
+ catch (error) {
33
+ if (error.code === 'FORBIDDEN') throw new Error('proxy key creation forbidden; check your account and current terms with vigievuln login, then retry');
34
+ throw error;
35
+ }
34
36
  }
35
37
 
36
38
  async function checkHostedProxy(url, token, fetcher = globalThis.fetch) {
@@ -46,4 +48,4 @@ async function checkHostedProxy(url, token, fetcher = globalThis.fetch) {
46
48
  if (data.ok !== true || data.service !== "vigievuln-proxy") throw new Error("unexpected VigieVuln proxy response");
47
49
  } finally { if (!response.bodyUsed) await response.body?.cancel(); }
48
50
  }
49
- module.exports = { ORIGINS, resolveHostedProxy, checkHostedProxy, loginForProxy };
51
+ module.exports = { ORIGINS, resolveHostedProxy, checkHostedProxy, loginForProxy, createProxyKey };
package/lib/kev.js CHANGED
@@ -14,7 +14,7 @@ const fs = require("fs");
14
14
  const path = require("path");
15
15
  const os = require("os");
16
16
 
17
- const CACHE_DIR = path.join(os.homedir(), ".fad-checker");
17
+ const CACHE_DIR = path.join(require("./cache-directory").getCacheDir());
18
18
  const CACHE_PATH = path.join(CACHE_DIR, "kev-cache.json");
19
19
  const CACHE_TTL_MS = 24 * 3600 * 1000;
20
20
  const KEV_URL = "https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json";
package/lib/nvd.js CHANGED
@@ -19,7 +19,7 @@ const path = require("path");
19
19
  const os = require("os");
20
20
  const { getNvdApiKey } = require("./config");
21
21
 
22
- const NVD_CACHE_DIR = path.join(os.homedir(), ".fad-checker", "nvd-cache");
22
+ const NVD_CACHE_DIR = path.join(require("./cache-directory").getCacheDir(), "nvd-cache");
23
23
  const NVD_CACHE_TTL_MS = 7 * 24 * 3600 * 1000;
24
24
  // Bump whenever `extractFromNvdRecord` adds a new field — pre-bump cache
25
25
  // entries are treated as cache-miss so we re-fetch and pick up the new field.
package/lib/osv-db.js CHANGED
@@ -26,7 +26,7 @@ const { unzipSync } = require("fflate");
26
26
  const { compareMavenVersions } = require("./maven-version");
27
27
  const { vulnToMatch } = require("./osv");
28
28
 
29
- const OSV_DB_DIR = path.join(os.homedir(), ".fad-checker", "osv-db");
29
+ const OSV_DB_DIR = path.join(require("./cache-directory").getCacheDir(), "osv-db");
30
30
  const BUCKET = "https://osv-vulnerabilities.storage.googleapis.com";
31
31
  const TTL_MS = 24 * 3600 * 1000;
32
32
  // OSV ecosystem export name per fad codec id. Maven only for now (version ordering).
package/lib/osv.js CHANGED
@@ -20,7 +20,7 @@ const fs = require("fs");
20
20
  const path = require("path");
21
21
  const os = require("os");
22
22
 
23
- const OSV_CACHE_DIR = path.join(os.homedir(), ".fad-checker", "osv-cache");
23
+ const OSV_CACHE_DIR = path.join(require("./cache-directory").getCacheDir(), "osv-cache");
24
24
  const OSV_CACHE_TTL_MS = 12 * 3600 * 1000;
25
25
  const OSV_BASE = "https://api.osv.dev";
26
26
  const BATCH_SIZE = 800; // OSV limit is 1000; stay under for safety
package/lib/outdated.js CHANGED
@@ -27,7 +27,7 @@ for (const [id, fw] of Object.entries(COMPOSER_FRAMEWORKS)) {
27
27
  for (const name of fw.components || []) COMPOSER_FRAMEWORK_OF.set(String(name).toLowerCase(), id);
28
28
  }
29
29
 
30
- const CACHE_DIR = path.join(os.homedir(), ".fad-checker");
30
+ const CACHE_DIR = path.join(require("./cache-directory").getCacheDir());
31
31
  const EOL_CACHE_PATH = path.join(CACHE_DIR, "eol-cache.json");
32
32
  const VERSION_CACHE_PATH = path.join(CACHE_DIR, "version-cache.json");
33
33
  const EOL_CACHE_MAX_AGE_MS = 7 * 24 * 3600 * 1000; // 7 days
@@ -27,7 +27,7 @@ const path = require("path");
27
27
  const os = require("os");
28
28
 
29
29
  const PACKAGIST_AUDIT_API = "https://packagist.org/api/security-advisories/";
30
- const DEFAULT_CACHE_DIR = path.join(os.homedir(), ".fad-checker", "packagist-advisories");
30
+ const DEFAULT_CACHE_DIR = path.join(require("./cache-directory").getCacheDir(), "packagist-advisories");
31
31
  const CACHE_TTL_MS = 24 * 3600 * 1000;
32
32
  const BATCH_SIZE = 100; // composer audit sends 100 packages per request; stay aligned
33
33
 
@@ -5,6 +5,12 @@ const COORD = /^[A-Za-z0-9@_][A-Za-z0-9@._+~/-]*$/;
5
5
  const SIMPLE = /^[A-Za-z0-9._-]{1,100}$/;
6
6
  // Allow room for server-normalized descriptors, while bounding memory use.
7
7
  const MAX_RESPONSE_BYTES = 4 * 1024 * 1024;
8
+ const MAX_DESCRIPTOR_BYTES = 500000;
9
+
10
+ function checkDescriptorSize(descriptor) {
11
+ if (Buffer.byteLength(JSON.stringify(descriptor), 'utf8') > MAX_DESCRIPTOR_BYTES)
12
+ throw new Error(`project descriptor exceeds the upload limit of ${MAX_DESCRIPTOR_BYTES} UTF-8 bytes`);
13
+ }
8
14
 
9
15
  class ProjectClientError extends Error {
10
16
  constructor(code, message, status) {
@@ -41,7 +47,6 @@ function sanitizeDescriptor(input) {
41
47
  version,versions:version ? [version] : [],scope:d.scope,isDev:!!d.isDev,relation:d.relation};
42
48
  });
43
49
  const out={schema:"fad-deps/2",generator:"vigievuln",deps};
44
- if (Buffer.byteLength(JSON.stringify(out)) > 1900000) throw new Error("project descriptor exceeds the upload limit");
45
50
  return out;
46
51
  }
47
52
  async function projectRequest(path, {session, method="GET", body, fetcher=globalThis.fetch, timeoutMs=15000} = {}) {
@@ -112,10 +117,16 @@ async function projectRequest(path, {session, method="GET", body, fetcher=global
112
117
  }
113
118
  async function createProject({session,name,descriptor,fetcher}) {
114
119
  if (typeof name !== "string" || !name.trim() || name.length>120) throw new Error("a project name is required");
115
- return projectRequest("/v1/projects",{session,method:"POST",body:{name,descriptor:sanitizeDescriptor(descriptor)},fetcher});
120
+ checkDescriptorSize(descriptor);
121
+ const sanitized = sanitizeDescriptor(descriptor);
122
+ checkDescriptorSize(sanitized);
123
+ return projectRequest("/v1/projects",{session,method:"POST",body:{name,descriptor:sanitized},fetcher});
116
124
  }
117
125
  async function updateProject({session,id,revision,descriptor,fetcher}) {
118
126
  if (!UUID.test(id || "") || !Number.isSafeInteger(revision) || revision<1) throw new Error("project id and current revision are required");
119
- return projectRequest(`/v1/projects/${id}`,{session,method:"PUT",body:{revision,descriptor:sanitizeDescriptor(descriptor)},fetcher});
127
+ checkDescriptorSize(descriptor);
128
+ const sanitized = sanitizeDescriptor(descriptor);
129
+ checkDescriptorSize(sanitized);
130
+ return projectRequest(`/v1/projects/${id}`,{session,method:"PUT",body:{revision,descriptor:sanitized},fetcher});
120
131
  }
121
- module.exports={sanitizeDescriptor,projectRequest,createProject,updateProject,ProjectClientError,MAX_RESPONSE_BYTES};
132
+ module.exports={sanitizeDescriptor,checkDescriptorSize,projectRequest,createProject,updateProject,ProjectClientError,MAX_RESPONSE_BYTES,MAX_DESCRIPTOR_BYTES};
package/lib/provenance.js CHANGED
@@ -19,7 +19,7 @@ const fs = require("fs");
19
19
  const path = require("path");
20
20
  const os = require("os");
21
21
 
22
- const DEFAULT_CACHE_DIR = path.join(os.homedir(), ".fad-checker");
22
+ const DEFAULT_CACHE_DIR = path.join(require("./cache-directory").getCacheDir());
23
23
 
24
24
  function readJson(file) {
25
25
  try { return JSON.parse(fs.readFileSync(file, "utf8")); } catch { return null; }
@@ -26,8 +26,8 @@
26
26
  * custom/private registry URLs use the direct path.
27
27
  *
28
28
  * Persistence is the point: the server may be restarted and entries outlive it. The
29
- * store deliberately lives in its OWN root (~/.fad-checker-proxy-cache/), NEVER inside
30
- * the client cache dir ~/.fad-checker/ — the scan's per-pass caches and the shared
29
+ * store deliberately lives in its OWN root (~/.vigie-vuln-proxy-cache/), NEVER inside
30
+ * the client cache dir ~/.vigie-vuln/ — the scan's per-pass caches and the shared
31
31
  * server base are two different roles and must not be bundled, swapped or merged by
32
32
  * --export-cache / --import-cache together.
33
33
  *
@@ -49,7 +49,7 @@ const {
49
49
  const DEFAULT_PORT = 8321;
50
50
  const DEFAULT_HOST = "127.0.0.1";
51
51
  /** The scan's own per-pass cache root — the proxy store must never live inside it. */
52
- const CLIENT_CACHE_DIR = () => path.join(os.homedir(), ".fad-checker");
52
+ const CLIENT_CACHE_DIR = () => path.join(require("./cache-directory").getCacheDir());
53
53
 
54
54
  // -------------------------------------------------------------- server ----
55
55
 
@@ -27,7 +27,7 @@ const path = require("path");
27
27
  const os = require("os");
28
28
  const crypto = require("crypto");
29
29
 
30
- const DEFAULT_CACHE_DIR = () => path.join(os.homedir(), ".fad-checker-proxy-cache");
30
+ const DEFAULT_CACHE_DIR = () => require('../cache-directory').getProxyCacheDir();
31
31
  const TRANSIENT_KEEP_MS = 30 * 1000;
32
32
 
33
33
  /**
package/lib/retire.js CHANGED
@@ -25,7 +25,7 @@ const { execFile } = require("child_process");
25
25
  const { promisify } = require("util");
26
26
  const execFileP = promisify(execFile);
27
27
 
28
- const RETIRE_CACHE_DIR = path.join(os.homedir(), ".fad-checker", "retire-cache");
28
+ const RETIRE_CACHE_DIR = path.join(require("./cache-directory").getCacheDir(), "retire-cache");
29
29
  const RETIRE_CACHE_TTL_MS = 24 * 3600 * 1000;
30
30
 
31
31
  // retire's own signature DB. By default retire caches it in /tmp/.retire-cache
@@ -33,7 +33,7 @@ const RETIRE_CACHE_TTL_MS = 24 * 3600 * 1000;
33
33
  // air-gapped offline workflow we instead keep a stable local copy INSIDE ~/.fad-checker/
34
34
  // so `--export-cache` carries it, and feed it to retire via `--jsrepo <file>`
35
35
  // (loaded from file, never the network — no TTL).
36
- const RETIRE_SIG_DIR = path.join(os.homedir(), ".fad-checker", "retire-signatures");
36
+ const RETIRE_SIG_DIR = path.join(require("./cache-directory").getCacheDir(), "retire-signatures");
37
37
  const RETIRE_SIG_FILE = path.join(RETIRE_SIG_DIR, "jsrepository-v5.json");
38
38
  const RETIRE_REPO_URL = "https://raw.githubusercontent.com/RetireJS/retire.js/master/repository/jsrepository-v5.json";
39
39
 
@@ -110,6 +110,12 @@ function chooseRetireLauncher({ localBin, isBun, execPath }) {
110
110
  }
111
111
 
112
112
  function findRetireLauncher() {
113
+ // npm installs a .cmd shim on Windows; execFile cannot run it without a shell.
114
+ // Invoke the package's JS entry with the current Node executable instead.
115
+ if (process.platform === 'win32' && !(process.versions && process.versions.bun)) {
116
+ const script = path.join(__dirname, '..', 'node_modules', 'retire', 'lib', 'cli.js');
117
+ if (fs.existsSync(script)) return {cmd:process.execPath, env:null, args:[script]};
118
+ }
113
119
  const local = path.join(__dirname, "..", "node_modules", ".bin", "retire");
114
120
  return chooseRetireLauncher({
115
121
  localBin: fs.existsSync(local) ? local : null,
@@ -369,7 +375,7 @@ async function runRetire(srcDir, opts = {}) {
369
375
  // retire.js exits with code 13 when it finds vulnerabilities — that's
370
376
  // expected. Catch and ignore the non-zero exit; the JSON file is still
371
377
  // produced.
372
- await execFileP(launcher.cmd, args, {
378
+ await execFileP(launcher.cmd, [...(launcher.args || []), ...args], {
373
379
  maxBuffer: 1024 * 1024 * 64,
374
380
  env: launcher.env ? { ...process.env, ...launcher.env } : process.env,
375
381
  });
package/lib/transitive.js CHANGED
@@ -28,7 +28,7 @@ const os = require("os");
28
28
  const { parseStringPromise } = require("xml2js");
29
29
  const { normalizeHardPin, isVersionRange, resolveVersionRange, compareMavenVersions } = require("./maven-version");
30
30
 
31
- const POM_CACHE_DIR = path.join(os.homedir(), ".fad-checker", "poms-cache");
31
+ const POM_CACHE_DIR = path.join(require("./cache-directory").getCacheDir(), "poms-cache");
32
32
  const MAVEN_CENTRAL = "https://repo1.maven.org/maven2";
33
33
 
34
34
  // Maven's scope-propagation matrix (rows: direct dep scope, cols: transitive scope)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vigievuln",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "One-shot polyglot dependency auditor (10 ecosystems + 9 CMS/Frameworks). No build tools. Real & complete air-gapped mode. Private deps, binaries, certs, EOL, CVE (KEV+EPSS) - Made for professional code audits.",
5
5
  "keywords": [
6
6
  "sca",
package/vigievuln.js CHANGED
@@ -252,7 +252,7 @@ if (process.argv.includes("--export-cache") || process.argv.includes("--import-c
252
252
  if (stats.skipped.length) console.log(chalk.gray(` Left untouched (machine-local): ${stats.skipped.join(", ")}`));
253
253
  } else {
254
254
  console.log(chalk.green(`✅ Cache imported → ${dir}`));
255
- console.log(chalk.gray(` --replace: previous cache ${force ? "removed" : "moved to ~/.fad-checker.bak-<timestamp>"}`));
255
+ console.log(chalk.gray(` --replace: previous cache ${force ? "removed" : "moved to ~/.vigie-vuln.bak-<timestamp>"}`));
256
256
  }
257
257
  }
258
258
  process.exit(0);
@@ -339,7 +339,7 @@ if (process.argv[2] === "serve-cache") {
339
339
  const { startProxyCacheServer, DEFAULT_CACHE_DIR, CLIENT_CACHE_DIR, createCacheStore } = require("./lib/proxy-cache");
340
340
  const storeDir = path.resolve(cacheDir || DEFAULT_CACHE_DIR());
341
341
  // The scan's per-pass caches and the shared server base are two different roles:
342
- // a store inside ~/.fad-checker/ would be bundled/swapped by --export-cache /
342
+ // a store inside ~/.vigie-vuln/ would be bundled/swapped by --export-cache /
343
343
  // --import-cache together with the client's own caches. Separate roots, always.
344
344
  const clientRoot = path.resolve(CLIENT_CACHE_DIR());
345
345
  if (storeDir === clientRoot || storeDir.startsWith(clientRoot + path.sep)) {
@@ -373,7 +373,7 @@ if (process.argv[2] === "serve-cache") {
373
373
  token, swr, keys,
374
374
  })).then(({ server, url }) => {
375
375
  console.log(chalk.green(`✅ proxy-cache listening on ${url}`));
376
- console.log(chalk.gray(` store: ${storeDir} (persists across restarts; separate from the scan's own ~/.fad-checker/ caches)`));
376
+ console.log(chalk.gray(` store: ${storeDir} (persists across restarts; separate from the scan's own ~/.vigie-vuln/ caches)`));
377
377
  console.log(chalk.gray(` upstream: ${upstreamProxy ? `via corporate proxy ${upstreamProxy}` : "direct"}`));
378
378
  console.log(chalk.gray(` stats: ${url}/__stats clear: POST ${url}/__clear`));
379
379
  const active = Object.entries(keys).filter(([, v]) => v).map(([k]) => k);
@@ -460,11 +460,11 @@ program
460
460
  .option("--vigievuln-proxy [domain]", "legacy hosted cache option: fr or com")
461
461
  .option("--proxy-cache-token <token>", "authenticate to a shared proxy-cache server (or set VIGIEVULN_PROXY_CACHE_TOKEN)")
462
462
  .option("--proxy <url>", "corporate proxy for all requests")
463
- .option("--set-nvd-key <key>", "save NVD API key to ~/.fad-checker/config.json (10× faster NVD enrichment)")
464
- .option("--show-config", "print the persisted ~/.fad-checker/config.json")
465
- .option("--export-cache <file>", "tar.gz/zip the ~/.fad-checker/ caches to <file> (excludes config.json by default)")
466
- .option("--import-cache <file>", "merge a previously exported archive into ~/.fad-checker/ (keeps the local cache + config.json; newest entry wins)")
467
- .option("--replace", "with --import-cache: replace ~/.fad-checker/ wholesale instead of merging (previous dir kept as .bak unless --force)")
463
+ .option("--set-nvd-key <key>", "save NVD API key to ~/.vigie-vuln/config.json (10× faster NVD enrichment)")
464
+ .option("--show-config", "print the persisted ~/.vigie-vuln/config.json")
465
+ .option("--export-cache <file>", "tar.gz/zip the ~/.vigie-vuln/ caches to <file> (excludes config.json by default)")
466
+ .option("--import-cache <file>", "merge a previously exported archive into ~/.vigie-vuln/ (keeps the local cache + config.json; newest entry wins)")
467
+ .option("--replace", "with --import-cache: replace ~/.vigie-vuln/ wholesale instead of merging (previous dir kept as .bak unless --force)")
468
468
  .option("--include-config", "with --export-cache: also bundle config.json (contains the NVD API key)")
469
469
  .option("--export-anonymized <file>", "offline: write a path-free dependency descriptor and exit")
470
470
  .option("--prepare-project <file>", "offline: prepare a path-free project descriptor for review")
@@ -591,7 +591,7 @@ program.parse(process.argv);
591
591
 
592
592
  const options = program.opts();
593
593
  // Layered config: CLI flags > config file (--config / ./.fad-env.json, JSON) >
594
- // FAD_CHECKER_ENV (a CLI-flag string) > global ~/.fad-checker/config.json >
594
+ // FAD_CHECKER_ENV (a CLI-flag string) > global ~/.vigie-vuln/config.json >
595
595
  // commander defaults. A file/env value fills an option only if the CLI didn't
596
596
  // set it. `registries` are unioned separately (below). Source has src/source aliases.
597
597
  const { loadLayers, applyLayers } = require("./lib/options-env");
@@ -657,7 +657,7 @@ if (!options.offline) {
657
657
  configureResourceRoute({ proxyUrl: options.proxyCache, hosted: !!options.vigievulnProxy,
658
658
  token: options.proxyCacheToken || (process.env.VIGIEVULN_PROXY_CACHE_TOKEN ?? process.env.FAD_PROXY_CACHE_TOKEN) || null,
659
659
  health: sourceHealth, fetcher: baseFetch,
660
- store: options.vigievulnProxy ? null : createCacheStore(require("node:path").join(require("node:os").homedir(), ".fad-checker", "resource-cache")) });
660
+ store: options.vigievulnProxy ? null : createCacheStore(require("node:path").join(require("./lib/cache-directory").getCacheDir(), "resource-cache")) });
661
661
  } catch (err) {
662
662
  console.error(chalk.red(`❌ ${err.message}`));
663
663
  process.exit(2);
@@ -845,12 +845,6 @@ async function timedPhase(label, fn) {
845
845
  if (options.vigievulnProxy && !options.offline) {
846
846
  if (!options.proxyCacheToken) {
847
847
  try {
848
- if (hostedAccountSession) {
849
- options.proxyCacheToken = (await require("./lib/account-client").createAccountClient().createProxyKey()).token;
850
- require("./lib/config").set("proxyCacheToken", options.proxyCacheToken);
851
- require("./lib/providers").configureResourceRoute({proxyUrl:options.proxyCache,token:options.proxyCacheToken});
852
- console.error("Proxy key created from your signed-in account and saved for future scans.");
853
- } else {
854
848
  const readline = require("node:readline");
855
849
  const { Writable } = require("node:stream");
856
850
  const ask = (prompt, secret = false) => new Promise(resolve => {
@@ -859,11 +853,20 @@ async function timedPhase(label, fn) {
859
853
  const rl = readline.createInterface({ input: process.stdin, output, terminal: true });
860
854
  rl.question("", answer => { rl.close(); if (secret) process.stderr.write("\n"); resolve(answer); });
861
855
  });
856
+ if (hostedAccountSession) {
857
+ const account = require("./lib/account-client").createAccountClient();
858
+ const current = await account.me();
859
+ await require("./lib/account-terms").requireTerms({account, terms:current.terms, ask});
860
+ options.proxyCacheToken = await require("./lib/hosted-proxy").createProxyKey(account);
861
+ require("./lib/config").set("proxyCacheToken", options.proxyCacheToken);
862
+ require("./lib/providers").configureResourceRoute({proxyUrl:options.proxyCache,token:options.proxyCacheToken});
863
+ console.error("Proxy key created from your signed-in account and saved for future scans.");
864
+ } else {
862
865
  console.error("Sign in to your verified Vigie Vuln account to create a proxy key.");
863
866
  console.error("No account? Register at https://www.vigievuln.fr/account");
864
867
  const email = await ask("Email: ");
865
868
  const password = await ask("Password: ", true);
866
- options.proxyCacheToken = await require("./lib/hosted-proxy").loginForProxy({origin:options.proxyCache,email,password});
869
+ options.proxyCacheToken = await require("./lib/hosted-proxy").loginForProxy({email,password,ask});
867
870
  require("./lib/config").set("proxyCacheToken", options.proxyCacheToken);
868
871
  require("./lib/providers").configureResourceRoute({proxyUrl:options.proxyCache,token:options.proxyCacheToken});
869
872
  console.error("Proxy key saved for future scans.");
@@ -875,7 +878,7 @@ async function timedPhase(label, fn) {
875
878
  }
876
879
  ui.banner(pkg.version);
877
880
 
878
- // Build the Maven repo list once: persisted repos (from ~/.fad-checker/config.json)
881
+ // Build the Maven repo list once: persisted repos (from ~/.vigie-vuln/config.json)
879
882
  // + ad-hoc --repo URLs + Maven Central as final fallback. Used by transitive
880
883
  // resolution, outdated-version check, and existence check.
881
884
  const { getRegistryMap } = require("./lib/config");
@@ -970,7 +973,7 @@ async function timedPhase(label, fn) {
970
973
  try {
971
974
  const warmed = await warmCmsAdvisorySnapshots(resolved, {
972
975
  fetchImpl: (...args) => fetch(...args),
973
- advisoryCacheDir: path.join(require("os").homedir(), ".fad-checker", "advisory-snapshots"),
976
+ advisoryCacheDir: path.join(require("./lib/cache-directory").getCacheDir(), "advisory-snapshots"),
974
977
  drupalUrl: typeof options.drupalAdvisoriesLive === "string" ? options.drupalAdvisoriesLive : undefined,
975
978
  prestashopUrl: typeof options.prestashopAdvisoriesLive === "string" ? options.prestashopAdvisoriesLive : undefined,
976
979
  typo3Url: typeof options.typo3AdvisoriesLive === "string" ? options.typo3AdvisoriesLive : undefined,
@@ -1375,7 +1378,7 @@ async function runReportFlow(resolved, ecoFlags = {}) {
1375
1378
  liveSpipAdvisoriesUrl: spipLiveUrl, spipAdvisoriesApiKey: getNvdApiKey(),
1376
1379
  wpChecksumsPath: options.wpChecksums || null, liveWpChecksumsUrl: wpChecksumsLiveUrl,
1377
1380
  wpChecksumsLocale: options.wpChecksumsLocale || "en_US",
1378
- advisoryCacheDir: path.join(require("os").homedir(), ".fad-checker", "advisory-snapshots"),
1381
+ advisoryCacheDir: path.join(require("./lib/cache-directory").getCacheDir(), "advisory-snapshots"),
1379
1382
  offline,
1380
1383
  fetchImpl: (...args) => fetch(...args),
1381
1384
  maxAdvisoryAgeMs,