vigie-cli 1.0.3 → 1.1.0
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 +10 -0
- package/README.fr.md +35 -6
- package/README.md +35 -6
- package/package.json +9 -2
- package/src/args.js +1 -1
- package/src/cli.js +7 -0
- package/src/i18n/en.js +46 -0
- package/src/i18n/fr.js +46 -0
- package/src/i18n/index.js +3 -0
- package/src/i18n/plain.js +74 -0
- package/src/interactive.js +393 -0
- package/src/report.js +1 -1
- package/src/scan.js +10 -2
- package/src/version.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to vigie are listed here. Versions follow [Semantic Versioning](https://semver.org).
|
|
4
4
|
|
|
5
|
+
## 1.1.0
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- `vigie.exe`: a standalone Windows app, attached to every GitHub release. Double-click it, type an address, read the results. No Node.js needed.
|
|
9
|
+
- Step-by-step assistant, started by `vigie` with no argument or by `--interactive`: live progress, big grade, problems grouped by urgency, a plain-language explanation and the concrete risk for every check, and the full report saved to `Documents/vigie` and opened in the browser.
|
|
10
|
+
- Plain-language explanations of all 34 checks in English and French.
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- The version number is now built into the code, so the bundled app does not need to read `package.json`.
|
|
14
|
+
|
|
5
15
|
## 1.0.0
|
|
6
16
|
|
|
7
17
|
### Added
|
package/README.fr.md
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
**Vérifie la sécurité de n'importe quel site web en quelques secondes, avec un rapport que ton client peut lire.**
|
|
6
6
|
|
|
7
|
-
[](https://www.npmjs.com/package/vigie)
|
|
7
|
+
[](https://www.npmjs.com/package/vigie-cli)
|
|
8
8
|
[](https://github.com/FreshlapeufDev/vigie/actions/workflows/ci.yml)
|
|
9
|
-
[](https://nodejs.org)
|
|
10
|
-
[](https://github.com/FreshlapeufDev/vigie/blob/main/LICENSE)
|
|
9
|
+
[](https://nodejs.org)
|
|
10
|
+
[](https://github.com/FreshlapeufDev/vigie/blob/main/LICENSE)
|
|
11
11
|
|
|
12
12
|
HTTPS · certificats · en-têtes de sécurité · cookies · fichiers exposés · bibliothèques vulnérables
|
|
13
13
|
|
|
@@ -23,18 +23,34 @@ La plupart des sites ne se font pas pirater par des attaques sophistiquées. Ils
|
|
|
23
23
|
|
|
24
24
|
Des robots cherchent ces erreurs sur tout Internet, chaque jour. vigie les trouve avant eux, explique chacune simplement et donne la ligne exacte de configuration nginx ou Apache qui la corrige.
|
|
25
25
|
|
|
26
|
+
## Application Windows, sans rien installer
|
|
27
|
+
|
|
28
|
+
Pas besoin de Node.js ni de ligne de commande : téléchargez **[vigie.exe](https://github.com/FreshlapeufDev/vigie/releases/latest/download/vigie.exe)** et double-cliquez dessus.
|
|
29
|
+
|
|
30
|
+
1. vigie demande l'adresse du site à vérifier.
|
|
31
|
+
2. Il demande si le site vous appartient. Si oui, il cherche aussi les fichiers sensibles oubliés en ligne ; sinon, il lit seulement la page d'accueil.
|
|
32
|
+
3. Il affiche une note de A+ à F et la liste des problèmes, du plus urgent au moins grave, chacun expliqué en une phrase simple.
|
|
33
|
+
4. Tapez le numéro d'un problème pour voir **en clair** ce qu'il signifie, le risque concret, ce qui a été vu et comment le corriger.
|
|
34
|
+
5. Tapez `R` pour ouvrir le rapport complet dans votre navigateur. Il est enregistré dans `Documents\vigie`.
|
|
35
|
+
|
|
36
|
+
<img src="https://raw.githubusercontent.com/FreshlapeufDev/vigie/main/docs/app-results.png" alt="Résultats dans l'application vigie" width="760">
|
|
37
|
+
|
|
38
|
+
<img src="https://raw.githubusercontent.com/FreshlapeufDev/vigie/main/docs/app-detail.png" alt="Détail d'un problème dans l'application vigie" width="760">
|
|
39
|
+
|
|
40
|
+
> Au premier lancement, Windows peut afficher « Windows a protégé votre ordinateur ». C'est normal pour un programme qui n'est pas signé par un certificat payant : cliquez sur **Informations complémentaires**, puis **Exécuter quand même**. Le code source complet est ici, et le fichier est construit automatiquement par GitHub à partir de ce code.
|
|
41
|
+
|
|
26
42
|
## Installation
|
|
27
43
|
|
|
28
44
|
Il faut [Node.js](https://nodejs.org) 18 ou plus récent (prends la version **LTS**).
|
|
29
45
|
|
|
30
46
|
```bash
|
|
31
|
-
npm install -g vigie
|
|
47
|
+
npm install -g vigie-cli
|
|
32
48
|
```
|
|
33
49
|
|
|
34
50
|
ou lance-le une seule fois sans rien installer :
|
|
35
51
|
|
|
36
52
|
```bash
|
|
37
|
-
npx vigie exemple.fr
|
|
53
|
+
npx vigie-cli exemple.fr
|
|
38
54
|
```
|
|
39
55
|
|
|
40
56
|
## Utilisation
|
|
@@ -43,6 +59,7 @@ npx vigie exemple.fr
|
|
|
43
59
|
vigie exemple.fr
|
|
44
60
|
vigie https://boutique.exemple.fr --html audit.html
|
|
45
61
|
vigie exemple.fr blog.exemple.fr --lang fr
|
|
62
|
+
vigie # assistant pas à pas, comme vigie.exe
|
|
46
63
|
```
|
|
47
64
|
|
|
48
65
|
| Option | |
|
|
@@ -55,6 +72,7 @@ vigie exemple.fr blog.exemple.fr --lang fr
|
|
|
55
72
|
| `--timeout <secondes>` | délai par requête (`10` par défaut) |
|
|
56
73
|
| `-q, --quiet` | résumé uniquement |
|
|
57
74
|
| `--no-banner` | masquer le logo FreshDev |
|
|
75
|
+
| `-i, --interactive` | assistant pas à pas |
|
|
58
76
|
|
|
59
77
|
## Ce qui est vérifié
|
|
60
78
|
|
|
@@ -123,7 +141,7 @@ Les secrets trouvés dans les fichiers exposés ne sont **jamais affichés** : s
|
|
|
123
141
|
## En intégration continue
|
|
124
142
|
|
|
125
143
|
```yaml
|
|
126
|
-
- run: npx vigie https://preprod.exemple.fr --fail-under B
|
|
144
|
+
- run: npx vigie-cli https://preprod.exemple.fr --fail-under B
|
|
127
145
|
```
|
|
128
146
|
|
|
129
147
|
Le job échoue si la note passe sous B, par exemple après la suppression d'un en-tête de sécurité.
|
|
@@ -149,12 +167,23 @@ src/
|
|
|
149
167
|
├─ checks/ transport, en-têtes et cookies, fichiers exposés, contenu de la page
|
|
150
168
|
├─ catalog.js contrôles, sévérités, CWE, notation, exemples nginx/Apache
|
|
151
169
|
├─ i18n/ anglais et français
|
|
170
|
+
├─ interactive.js assistant pas à pas (vigie.exe)
|
|
152
171
|
├─ report.js sortie console et JSON
|
|
153
172
|
└─ html.js rapport d'audit
|
|
154
173
|
```
|
|
155
174
|
|
|
156
175
|
Aucune dépendance à l'exécution.
|
|
157
176
|
|
|
177
|
+
Pour construire `vigie.exe` vous-même (Node.js 22 ou plus récent, sous Windows) :
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
npm install
|
|
181
|
+
npm run build:exe
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Le fichier arrive dans `dist/`. À chaque version publiée (`git push --follow-tags`), GitHub le construit et l'ajoute aux [Releases](https://github.com/FreshlapeufDev/vigie/releases).
|
|
185
|
+
|
|
186
|
+
|
|
158
187
|
## Voir aussi
|
|
159
188
|
|
|
160
189
|
- [**fxguard**](https://github.com/FreshlapeufDev/fxguard) — scanner de sécurité pour resources FiveM
|
package/README.md
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
**Check the security of any website in seconds, and get a report your client can read.**
|
|
6
6
|
|
|
7
|
-
[](https://www.npmjs.com/package/vigie)
|
|
7
|
+
[](https://www.npmjs.com/package/vigie-cli)
|
|
8
8
|
[](https://github.com/FreshlapeufDev/vigie/actions/workflows/ci.yml)
|
|
9
|
-
[](https://nodejs.org)
|
|
10
|
-
[](https://github.com/FreshlapeufDev/vigie/blob/main/LICENSE)
|
|
9
|
+
[](https://nodejs.org)
|
|
10
|
+
[](https://github.com/FreshlapeufDev/vigie/blob/main/LICENSE)
|
|
11
11
|
|
|
12
12
|
HTTPS · certificates · security headers · cookies · exposed files · vulnerable libraries
|
|
13
13
|
|
|
@@ -23,18 +23,34 @@ Most websites are not hacked through clever exploits. They are hacked because a
|
|
|
23
23
|
|
|
24
24
|
Bots scan the whole Internet for these mistakes every day. vigie finds them first, explains each one in plain language and gives you the exact line of nginx or Apache configuration that fixes it.
|
|
25
25
|
|
|
26
|
+
## Windows app, nothing to install
|
|
27
|
+
|
|
28
|
+
No Node.js, no command line: download **[vigie.exe](https://github.com/FreshlapeufDev/vigie/releases/latest/download/vigie.exe)** and double-click it.
|
|
29
|
+
|
|
30
|
+
1. vigie asks for the address of the website to check.
|
|
31
|
+
2. It asks whether you own the site. If you do, it also looks for sensitive files left online; if not, it only reads the home page.
|
|
32
|
+
3. It shows a grade from A+ to F and the list of problems, most urgent first, each explained in one plain sentence.
|
|
33
|
+
4. Type a problem's number to see **in plain words** what it means, the real risk, what was seen and how to fix it.
|
|
34
|
+
5. Type `R` to open the full report in your browser. It is saved in `Documents\vigie`.
|
|
35
|
+
|
|
36
|
+
<img src="https://raw.githubusercontent.com/FreshlapeufDev/vigie/main/docs/app-results.png" alt="Results in the vigie app" width="760">
|
|
37
|
+
|
|
38
|
+
<img src="https://raw.githubusercontent.com/FreshlapeufDev/vigie/main/docs/app-detail.png" alt="Problem detail in the vigie app" width="760">
|
|
39
|
+
|
|
40
|
+
> On first launch, Windows may show "Windows protected your PC". This is normal for a program that is not signed with a paid certificate: click **More info**, then **Run anyway**. The full source code is here, and the file is built automatically by GitHub from that code.
|
|
41
|
+
|
|
26
42
|
## Install
|
|
27
43
|
|
|
28
44
|
You need [Node.js](https://nodejs.org) 18 or newer (pick the **LTS** version).
|
|
29
45
|
|
|
30
46
|
```bash
|
|
31
|
-
npm install -g vigie
|
|
47
|
+
npm install -g vigie-cli
|
|
32
48
|
```
|
|
33
49
|
|
|
34
50
|
or run it once without installing:
|
|
35
51
|
|
|
36
52
|
```bash
|
|
37
|
-
npx vigie example.com
|
|
53
|
+
npx vigie-cli example.com
|
|
38
54
|
```
|
|
39
55
|
|
|
40
56
|
## Usage
|
|
@@ -43,6 +59,7 @@ npx vigie example.com
|
|
|
43
59
|
vigie example.com
|
|
44
60
|
vigie https://shop.example.com --html audit.html
|
|
45
61
|
vigie example.com blog.example.com --lang fr
|
|
62
|
+
vigie # step-by-step assistant, like vigie.exe
|
|
46
63
|
```
|
|
47
64
|
|
|
48
65
|
| Option | |
|
|
@@ -55,6 +72,7 @@ vigie example.com blog.example.com --lang fr
|
|
|
55
72
|
| `--timeout <seconds>` | per request (default `10`) |
|
|
56
73
|
| `-q, --quiet` | summary only |
|
|
57
74
|
| `--no-banner` | hide the FreshDev logo |
|
|
75
|
+
| `-i, --interactive` | step-by-step assistant |
|
|
58
76
|
|
|
59
77
|
## What it checks
|
|
60
78
|
|
|
@@ -123,7 +141,7 @@ Secrets found in exposed files are **never displayed**: only the variable names
|
|
|
123
141
|
## Use it in CI
|
|
124
142
|
|
|
125
143
|
```yaml
|
|
126
|
-
- run: npx vigie https://staging.example.com --fail-under B
|
|
144
|
+
- run: npx vigie-cli https://staging.example.com --fail-under B
|
|
127
145
|
```
|
|
128
146
|
|
|
129
147
|
The job fails if the grade drops below B, for example after someone removes a security header.
|
|
@@ -149,12 +167,23 @@ src/
|
|
|
149
167
|
├─ checks/ transport, headers & cookies, exposed files, page content
|
|
150
168
|
├─ catalog.js checks, severities, CWE, scoring, nginx/Apache examples
|
|
151
169
|
├─ i18n/ English and French
|
|
170
|
+
├─ interactive.js step-by-step assistant (vigie.exe)
|
|
152
171
|
├─ report.js console and JSON output
|
|
153
172
|
└─ html.js audit report
|
|
154
173
|
```
|
|
155
174
|
|
|
156
175
|
No runtime dependency.
|
|
157
176
|
|
|
177
|
+
To build `vigie.exe` yourself (Node.js 22 or newer, on Windows):
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
npm install
|
|
181
|
+
npm run build:exe
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
The file lands in `dist/`. For every published version (`git push --follow-tags`), GitHub builds it and attaches it to the [Releases](https://github.com/FreshlapeufDev/vigie/releases).
|
|
185
|
+
|
|
186
|
+
|
|
158
187
|
## Related
|
|
159
188
|
|
|
160
189
|
- [**fxguard**](https://github.com/FreshlapeufDev/fxguard) — security scanner for FiveM resources
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vigie-cli",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Website security checker by FreshDev: HTTPS, certificates, security headers, cookies, exposed files and vulnerable libraries, with a bilingual HTML audit report. Zero dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -15,7 +15,9 @@
|
|
|
15
15
|
"LICENSE"
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
|
-
"test": "node --test test/unit.test.js test/scan.test.js test/cli.test.js"
|
|
18
|
+
"test": "node --test test/unit.test.js test/scan.test.js test/cli.test.js",
|
|
19
|
+
"version": "node scripts/sync-version.mjs && git add src/version.js",
|
|
20
|
+
"build:exe": "node scripts/build-exe.mjs"
|
|
19
21
|
},
|
|
20
22
|
"engines": {
|
|
21
23
|
"node": ">=18"
|
|
@@ -41,5 +43,10 @@
|
|
|
41
43
|
"homepage": "https://github.com/FreshlapeufDev/vigie#readme",
|
|
42
44
|
"bugs": {
|
|
43
45
|
"url": "https://github.com/FreshlapeufDev/vigie/issues"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"esbuild": "0.28.2",
|
|
49
|
+
"postject": "1.0.0-alpha.6",
|
|
50
|
+
"rcedit": "5.0.2"
|
|
44
51
|
}
|
|
45
52
|
}
|
package/src/args.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const BOOLEAN_FLAGS = new Set(['yes', 'y', 'force', 'help', 'h', 'version', 'v', 'json', 'strict', 'all', 'no-color', 'quiet', 'q', 'no-banner', 'no-probe']);
|
|
1
|
+
const BOOLEAN_FLAGS = new Set(['yes', 'y', 'force', 'help', 'h', 'version', 'v', 'json', 'strict', 'all', 'no-color', 'quiet', 'q', 'no-banner', 'no-probe', 'interactive', 'i']);
|
|
2
2
|
|
|
3
3
|
export function parseArgs(argv) {
|
|
4
4
|
const positional = [];
|
package/src/cli.js
CHANGED
|
@@ -8,6 +8,7 @@ import { normalizeTarget } from './net.js';
|
|
|
8
8
|
import { printBanner, printResults, toJson } from './report.js';
|
|
9
9
|
import { pkg, scanAll } from './scan.js';
|
|
10
10
|
import { c } from './ui.js';
|
|
11
|
+
import { App } from './interactive.js';
|
|
11
12
|
|
|
12
13
|
const GRADES = ['A+', 'A', 'B', 'C', 'D', 'F'];
|
|
13
14
|
|
|
@@ -27,6 +28,12 @@ export async function run(argv) {
|
|
|
27
28
|
return 0;
|
|
28
29
|
}
|
|
29
30
|
const wantsHelp = flags.help || flags.h || positional[0] === 'help';
|
|
31
|
+
const interactive = flags.interactive || flags.i || (positional.length === 0 && !wantsHelp && process.stdin.isTTY && process.stdout.isTTY && !Object.keys(flags).some((key) => !['lang', 'no-color'].includes(key)));
|
|
32
|
+
if (interactive) {
|
|
33
|
+
const extraCa = process.env.VIGIE_EXTRA_CA ? readFileSync(process.env.VIGIE_EXTRA_CA, 'utf8') : undefined;
|
|
34
|
+
const port = process.env.VIGIE_HTTP_PORT ? Number(process.env.VIGIE_HTTP_PORT) : undefined;
|
|
35
|
+
return new App({ lang, ca: extraCa, httpPort: port, reportDir: process.env.VIGIE_REPORT_DIR }).run();
|
|
36
|
+
}
|
|
30
37
|
const optionsOnly = Object.keys(flags).some((key) => !['lang', 'no-banner', 'no-color'].includes(key));
|
|
31
38
|
if (!wantsHelp && positional.length === 0 && optionsOnly) throw new FxError(e.noTarget, e.noTargetHint);
|
|
32
39
|
if (wantsHelp || positional.length === 0) {
|
package/src/i18n/en.js
CHANGED
|
@@ -21,6 +21,7 @@ const CSP_REASONS = {
|
|
|
21
21
|
export default {
|
|
22
22
|
code: 'en',
|
|
23
23
|
severities: { critical: 'critical', high: 'high', medium: 'medium', low: 'low', info: 'info' },
|
|
24
|
+
severityCounts: (n, severity) => `${n} ${severity}`,
|
|
24
25
|
severityTitles: { critical: 'Critical', high: 'High', medium: 'Medium', low: 'Low', info: 'Informational' },
|
|
25
26
|
categories: {
|
|
26
27
|
transport: 'HTTPS & certificate',
|
|
@@ -318,7 +319,52 @@ export default {
|
|
|
318
319
|
filter: 'Show',
|
|
319
320
|
scoreOf: (n) => `${n}/100`,
|
|
320
321
|
},
|
|
322
|
+
app: {
|
|
323
|
+
intro: 'Check in seconds whether a website is properly protected.',
|
|
324
|
+
askUrl: 'Website to check',
|
|
325
|
+
askUrlHint: 'example: mysite.com · press Enter on an empty line to quit · L = Français',
|
|
326
|
+
invalidUrl: (value) => `"${value}" is not a valid website address.`,
|
|
327
|
+
askOwner: 'Do you own this website, or are you allowed to test it?',
|
|
328
|
+
yesNo: '[y/N]',
|
|
329
|
+
yes: ['y', 'yes', 'o', 'oui'],
|
|
330
|
+
ownerHint: [
|
|
331
|
+
'Yes: vigie also looks for sensitive files left online (.env, backups, .git…).',
|
|
332
|
+
'No: vigie only reads the home page, like a browser.',
|
|
333
|
+
],
|
|
334
|
+
scanning: (url) => `Checking ${url}`,
|
|
335
|
+
steps: {
|
|
336
|
+
connect: 'Connecting to the site',
|
|
337
|
+
transport: 'Padlock and certificate',
|
|
338
|
+
headers: 'Security headers and cookies',
|
|
339
|
+
content: 'Page content',
|
|
340
|
+
exposure: 'Sensitive files left online',
|
|
341
|
+
},
|
|
342
|
+
skipped: 'not checked',
|
|
343
|
+
unreachableTitle: 'The website does not answer',
|
|
344
|
+
unreachable: (url, error) => `Could not reach ${url} (${error}). Check the address and your Internet connection.`,
|
|
345
|
+
grade: 'Rating',
|
|
346
|
+
groups: { urgent: 'Fix first', improve: 'To improve', info: 'For your information' },
|
|
347
|
+
noFindings: 'No problem found. Well done!',
|
|
348
|
+
menu: {
|
|
349
|
+
detail: (n) => (n > 1 ? `1 to ${n} see a problem in detail` : '1 see the problem in detail'),
|
|
350
|
+
report: 'R open the full report',
|
|
351
|
+
again: 'N check another website',
|
|
352
|
+
quit: 'Q quit',
|
|
353
|
+
},
|
|
354
|
+
keys: { report: 'r', again: 'n', quit: 'q', lang: 'l' },
|
|
355
|
+
choice: 'Your choice',
|
|
356
|
+
labels: { what: 'In plain words', risk: 'The risk', seen: 'What we saw', fix: 'How to fix it' },
|
|
357
|
+
share: 'Send this, or the full report, to whoever manages your website.',
|
|
358
|
+
back: 'Enter to go back to the list',
|
|
359
|
+
reportSaved: (path) => `Report saved: ${path}`,
|
|
360
|
+
reportOpened: 'It opens in your browser.',
|
|
361
|
+
reportFailed: (error) => `Could not save the report (${error}).`,
|
|
362
|
+
skippedNote: 'Sensitive files not checked: you said the website is not yours.',
|
|
363
|
+
bye: 'See you soon!',
|
|
364
|
+
pressEnter: 'Enter to continue',
|
|
365
|
+
},
|
|
321
366
|
help: (c) => ` ${c.bold('Usage')}
|
|
367
|
+
vigie interactive mode (also when you double-click vigie.exe)
|
|
322
368
|
vigie ${c.gray('<url> [url…]')} check one or more websites
|
|
323
369
|
|
|
324
370
|
${c.bold('Options')}
|
package/src/i18n/fr.js
CHANGED
|
@@ -22,6 +22,7 @@ const CSP_REASONS = {
|
|
|
22
22
|
export default {
|
|
23
23
|
code: 'fr',
|
|
24
24
|
severities: { critical: 'critique', high: 'élevée', medium: 'moyenne', low: 'faible', info: 'info' },
|
|
25
|
+
severityCounts: (n, severity) => `${n} ${{ critical: n > 1 ? 'critiques' : 'critique', high: n > 1 ? 'élevées' : 'élevée', medium: n > 1 ? 'moyennes' : 'moyenne', low: n > 1 ? 'faibles' : 'faible', info: 'info' }[severity]}`,
|
|
25
26
|
severityTitles: { critical: 'Critique', high: 'Élevée', medium: 'Moyenne', low: 'Faible', info: 'Information' },
|
|
26
27
|
categories: {
|
|
27
28
|
transport: 'HTTPS et certificat',
|
|
@@ -319,7 +320,52 @@ export default {
|
|
|
319
320
|
filter: 'Afficher',
|
|
320
321
|
scoreOf: (n) => `${n}/100`,
|
|
321
322
|
},
|
|
323
|
+
app: {
|
|
324
|
+
intro: 'Vérifiez en quelques secondes si un site web est bien protégé.',
|
|
325
|
+
askUrl: 'Adresse du site à vérifier',
|
|
326
|
+
askUrlHint: 'exemple : monsite.fr · Entrée sans rien pour quitter · L = English',
|
|
327
|
+
invalidUrl: (value) => `« ${value} » n'est pas une adresse de site valide.`,
|
|
328
|
+
askOwner: "Ce site vous appartient-il, ou avez-vous l'autorisation de le tester ?",
|
|
329
|
+
yesNo: '[o/N]',
|
|
330
|
+
yes: ['o', 'oui', 'y', 'yes'],
|
|
331
|
+
ownerHint: [
|
|
332
|
+
'Oui : vigie cherche aussi les fichiers sensibles oubliés en ligne (.env, sauvegardes, .git…).',
|
|
333
|
+
"Non : vigie lit seulement la page d'accueil, comme un navigateur.",
|
|
334
|
+
],
|
|
335
|
+
scanning: (url) => `Analyse de ${url}`,
|
|
336
|
+
steps: {
|
|
337
|
+
connect: 'Connexion au site',
|
|
338
|
+
transport: 'Cadenas et certificat',
|
|
339
|
+
headers: 'En-têtes de sécurité et cookies',
|
|
340
|
+
content: 'Contenu de la page',
|
|
341
|
+
exposure: 'Fichiers sensibles oubliés en ligne',
|
|
342
|
+
},
|
|
343
|
+
skipped: 'non vérifié',
|
|
344
|
+
unreachableTitle: 'Le site ne répond pas',
|
|
345
|
+
unreachable: (url, error) => `Impossible de joindre ${url} (${error}). Vérifiez l'adresse et votre connexion Internet.`,
|
|
346
|
+
grade: 'Note',
|
|
347
|
+
groups: { urgent: 'À corriger en priorité', improve: 'À améliorer', info: 'Pour information' },
|
|
348
|
+
noFindings: 'Aucun problème trouvé. Bravo !',
|
|
349
|
+
menu: {
|
|
350
|
+
detail: (n) => (n > 1 ? `1 à ${n} voir un problème en détail` : '1 voir le problème en détail'),
|
|
351
|
+
report: 'R ouvrir le rapport complet',
|
|
352
|
+
again: 'N vérifier un autre site',
|
|
353
|
+
quit: 'Q quitter',
|
|
354
|
+
},
|
|
355
|
+
keys: { report: 'r', again: 'n', quit: 'q', lang: 'l' },
|
|
356
|
+
choice: 'Votre choix',
|
|
357
|
+
labels: { what: 'En clair', risk: 'Le risque', seen: "Ce qu'on a vu", fix: 'Comment corriger' },
|
|
358
|
+
share: 'Envoyez ce détail, ou le rapport complet, à la personne qui gère votre site.',
|
|
359
|
+
back: 'Entrée pour revenir à la liste',
|
|
360
|
+
reportSaved: (path) => `Rapport enregistré : ${path}`,
|
|
361
|
+
reportOpened: "Il s'ouvre dans votre navigateur.",
|
|
362
|
+
reportFailed: (error) => `Impossible d'enregistrer le rapport (${error}).`,
|
|
363
|
+
skippedNote: "Fichiers sensibles non vérifiés : vous avez indiqué que le site ne vous appartient pas.",
|
|
364
|
+
bye: 'À bientôt !',
|
|
365
|
+
pressEnter: 'Entrée pour continuer',
|
|
366
|
+
},
|
|
322
367
|
help: (c) => ` ${c.bold('Utilisation')}
|
|
368
|
+
vigie mode interactif (aussi en double-cliquant sur vigie.exe)
|
|
323
369
|
vigie ${c.gray('<url> [url…]')} vérifier un ou plusieurs sites
|
|
324
370
|
|
|
325
371
|
${c.bold('Options')}
|
package/src/i18n/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import en from './en.js';
|
|
2
2
|
import fr from './fr.js';
|
|
3
|
+
import { PLAIN } from './plain.js';
|
|
3
4
|
|
|
4
5
|
export const LANGS = { en, fr };
|
|
5
6
|
export const LANG_CODES = Object.keys(LANGS);
|
|
@@ -27,3 +28,5 @@ export const message = (lang, finding) => {
|
|
|
27
28
|
const fn = dict(lang).messages[finding.rule] ?? en.messages[finding.rule];
|
|
28
29
|
return fn ? fn(finding.params) : finding.rule;
|
|
29
30
|
};
|
|
31
|
+
|
|
32
|
+
export const plainText = (lang, rule) => PLAIN[lang]?.[rule] ?? PLAIN.en[rule];
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export const PLAIN = {
|
|
2
|
+
fr: {
|
|
3
|
+
'no-https': { what: "Votre site n'a pas de cadenas : les échanges avec les visiteurs ne sont pas chiffrés.", risk: 'Sur un Wi-Fi public, quelqu\'un peut lire les mots de passe et les messages envoyés sur votre site.' },
|
|
4
|
+
'tls-invalid-cert': { what: "Le certificat de votre site n'est pas reconnu : les navigateurs affichent une grosse alerte rouge.", risk: 'Les visiteurs fuient, et ceux qui continuent peuvent se faire espionner.' },
|
|
5
|
+
'tls-old-protocol': { what: 'Votre serveur accepte encore de vieilles méthodes de chiffrement abandonnées depuis 2020.', risk: 'Un attaquant peut forcer une connexion plus facile à casser.' },
|
|
6
|
+
'tls-expiring': { what: 'Le certificat de votre site arrive bientôt à expiration.', risk: "Le jour J, le site affichera une alerte de sécurité à tous les visiteurs." },
|
|
7
|
+
'http-no-redirect': { what: "Quand on tape l'adresse sans « https », le site s'ouvre sans cadenas.", risk: 'Une partie de vos visiteurs navigue sans protection sans le savoir.' },
|
|
8
|
+
'insecure-redirect': { what: 'Une redirection fait repasser le visiteur sur une page sans cadenas.', risk: 'La protection HTTPS est perdue en cours de route.' },
|
|
9
|
+
'hsts-missing': { what: "Votre site ne demande pas au navigateur de toujours utiliser le cadenas.", risk: "Sur un réseau piégé, la première visite peut être interceptée." },
|
|
10
|
+
'hsts-weak': { what: "La règle « toujours utiliser le cadenas » est oubliée trop vite par les navigateurs.", risk: 'La protection disparaît au bout de quelques jours.' },
|
|
11
|
+
'csp-missing': { what: "Votre site ne dit pas au navigateur quels scripts ont le droit de s'exécuter.", risk: "Si un pirate arrive à injecter du code, rien ne l'empêche de tourner chez vos visiteurs." },
|
|
12
|
+
'csp-unsafe': { what: 'Votre liste de scripts autorisés est trop permissive.', risk: 'Un script injecté par un pirate passerait quand même.' },
|
|
13
|
+
clickjacking: { what: "N'importe quel site peut afficher votre site en cachette dans le sien.", risk: 'Vos visiteurs peuvent être piégés pour cliquer sur vos boutons sans le savoir.' },
|
|
14
|
+
'cors-reflected-origin': { what: "Votre site accepte de partager les données des visiteurs connectés avec n'importe quel autre site.", risk: 'Un site piégé peut lire les informations privées de vos utilisateurs.' },
|
|
15
|
+
'cors-wildcard-credentials': { what: "Les règles de partage de données avec d'autres sites sont mal réglées.", risk: "Selon le reste de la configuration, des données privées peuvent fuiter." },
|
|
16
|
+
'nosniff-missing': { what: "Le navigateur peut deviner tout seul le type d'un fichier au lieu de vous faire confiance.", risk: 'Un fichier envoyé par un utilisateur pourrait être exécuté comme un programme.' },
|
|
17
|
+
'referrer-policy': { what: "Quand un visiteur clique sur un lien externe, l'adresse complète de votre page est transmise.", risk: 'Des informations privées présentes dans vos adresses peuvent partir chez d\'autres sites.' },
|
|
18
|
+
'permissions-policy-missing': { what: "Votre site n'interdit pas l'accès à la caméra, au micro ou à la position.", risk: 'Un code injecté pourrait demander ces accès à vos visiteurs.' },
|
|
19
|
+
'cookie-not-secure': { what: 'Certains cookies peuvent être envoyés sans chiffrement.', risk: 'Un pirate sur le même Wi-Fi peut voler la session d\'un visiteur et se faire passer pour lui.' },
|
|
20
|
+
'cookie-no-httponly': { what: 'Le cookie de connexion est lisible par les scripts de la page.', risk: 'Au moindre script piégé, la session du visiteur peut être volée.' },
|
|
21
|
+
'cookie-no-samesite': { what: "Des cookies sont envoyés même quand la demande vient d'un autre site.", risk: "Un site piégé peut déclencher des actions en se servant de la session d'un visiteur." },
|
|
22
|
+
'exposed-git': { what: "Tout le code source de votre site peut être téléchargé par n'importe qui.", risk: 'Mots de passe, clés et failles du code deviennent publics.' },
|
|
23
|
+
'exposed-env': { what: "Le fichier qui contient les mots de passe de votre site est téléchargeable par n'importe qui.", risk: "Un pirate peut accéder à votre base de données, vos clés d'API et vos comptes." },
|
|
24
|
+
'exposed-backup': { what: "Une sauvegarde de votre site ou de votre base de données est téléchargeable par n'importe qui.", risk: 'Les données de vos utilisateurs, mots de passe compris, peuvent être récupérées.' },
|
|
25
|
+
'exposed-config': { what: 'Un fichier de configuration avec des identifiants est accessible publiquement.', risk: 'Un pirate peut se connecter à votre serveur ou à vos comptes.' },
|
|
26
|
+
'exposed-htpasswd': { what: 'Le fichier des mots de passe de votre zone protégée est téléchargeable.', risk: 'Les mots de passe peuvent être retrouvés en quelques heures.' },
|
|
27
|
+
'exposed-phpinfo': { what: 'Une page de diagnostic affiche tous les détails techniques de votre serveur.', risk: 'Un pirate sait exactement quelles failles essayer.' },
|
|
28
|
+
'exposed-server-status': { what: "La page d'état du serveur est visible par tout le monde.", risk: 'Elle montre en direct les visiteurs et des adresses internes.' },
|
|
29
|
+
'directory-listing': { what: "Le contenu de certains dossiers s'affiche comme dans un explorateur de fichiers.", risk: "N'importe qui peut fouiller et télécharger des fichiers que vous n'avez jamais partagés." },
|
|
30
|
+
'exposed-ds-store': { what: 'Un fichier caché créé par un Mac révèle la liste des fichiers d\'un dossier.', risk: 'Il aide un pirate à trouver des fichiers sensibles.' },
|
|
31
|
+
'security-txt-missing': { what: "Il n'y a aucune page indiquant comment vous signaler une faille.", risk: "Quelqu'un qui découvre un problème ne sait pas comment vous prévenir." },
|
|
32
|
+
'insecure-form': { what: "Un formulaire de connexion envoie le mot de passe sans chiffrement.", risk: 'Le mot de passe peut être lu par quelqu\'un sur le même réseau.' },
|
|
33
|
+
'mixed-content': { what: 'Votre page sécurisée charge des éléments sans cadenas.', risk: 'Certains éléments peuvent être bloqués ou remplacés par un pirate.' },
|
|
34
|
+
'outdated-library': { what: 'Votre site utilise une vieille version d\'un outil JavaScript qui a des failles connues.', risk: 'Les pirates connaissent ces failles et savent les exploiter.' },
|
|
35
|
+
'sri-missing': { what: "Des scripts viennent d'un autre site sans vérification de leur contenu.", risk: "Si cet autre site est piraté, votre site l'est aussi." },
|
|
36
|
+
'version-disclosure': { what: 'Votre serveur affiche les versions exactes des logiciels qu\'il utilise.', risk: 'Un pirate peut chercher directement les failles de ces versions.' },
|
|
37
|
+
},
|
|
38
|
+
en: {
|
|
39
|
+
'no-https': { what: 'Your site has no padlock: traffic with visitors is not encrypted.', risk: 'On public Wi-Fi, someone can read passwords and messages sent to your site.' },
|
|
40
|
+
'tls-invalid-cert': { what: 'Your certificate is not recognised: browsers show a big red warning.', risk: 'Visitors leave, and those who stay can be spied on.' },
|
|
41
|
+
'tls-old-protocol': { what: 'Your server still accepts old encryption methods retired in 2020.', risk: 'An attacker can force a connection that is easier to break.' },
|
|
42
|
+
'tls-expiring': { what: 'Your certificate expires soon.', risk: 'On that day, every visitor will get a security warning.' },
|
|
43
|
+
'http-no-redirect': { what: 'Typing the address without "https" opens the site without a padlock.', risk: 'Some visitors browse unprotected without knowing it.' },
|
|
44
|
+
'insecure-redirect': { what: 'A redirect sends visitors back to a page without a padlock.', risk: 'The HTTPS protection is lost along the way.' },
|
|
45
|
+
'hsts-missing': { what: 'Your site does not ask browsers to always use the padlock.', risk: 'On a rigged network, the first visit can be intercepted.' },
|
|
46
|
+
'hsts-weak': { what: 'Browsers forget the "always use the padlock" rule too quickly.', risk: 'The protection disappears after a few days.' },
|
|
47
|
+
'csp-missing': { what: 'Your site does not tell browsers which scripts are allowed to run.', risk: 'If an attacker injects code, nothing stops it from running for your visitors.' },
|
|
48
|
+
'csp-unsafe': { what: 'Your list of allowed scripts is too permissive.', risk: 'A script injected by an attacker would still run.' },
|
|
49
|
+
clickjacking: { what: 'Any website can secretly display your site inside its own.', risk: 'Visitors can be tricked into clicking your buttons without knowing.' },
|
|
50
|
+
'cors-reflected-origin': { what: 'Your site agrees to share logged-in visitors\' data with any other website.', risk: 'A malicious site can read your users\' private information.' },
|
|
51
|
+
'cors-wildcard-credentials': { what: 'The rules for sharing data with other sites are misconfigured.', risk: 'Depending on the rest of the setup, private data may leak.' },
|
|
52
|
+
'nosniff-missing': { what: 'Browsers may guess a file\'s type on their own instead of trusting you.', risk: 'A file uploaded by a user could be run as a program.' },
|
|
53
|
+
'referrer-policy': { what: 'When a visitor clicks an external link, the full address of your page is sent along.', risk: 'Private information in your addresses can leak to other sites.' },
|
|
54
|
+
'permissions-policy-missing': { what: 'Your site does not block access to the camera, microphone or location.', risk: 'Injected code could ask your visitors for those permissions.' },
|
|
55
|
+
'cookie-not-secure': { what: 'Some cookies can be sent without encryption.', risk: 'An attacker on the same Wi-Fi can steal a visitor\'s session and impersonate them.' },
|
|
56
|
+
'cookie-no-httponly': { what: 'The login cookie can be read by scripts on the page.', risk: 'Any malicious script can steal the visitor\'s session.' },
|
|
57
|
+
'cookie-no-samesite': { what: 'Cookies are sent even when the request comes from another site.', risk: 'A malicious site can trigger actions using a visitor\'s session.' },
|
|
58
|
+
'exposed-git': { what: 'Your site\'s entire source code can be downloaded by anyone.', risk: 'Passwords, keys and code flaws become public.' },
|
|
59
|
+
'exposed-env': { what: 'The file holding your site\'s passwords can be downloaded by anyone.', risk: 'An attacker can access your database, API keys and accounts.' },
|
|
60
|
+
'exposed-backup': { what: 'A backup of your site or database can be downloaded by anyone.', risk: 'Your users\' data, passwords included, can be taken.' },
|
|
61
|
+
'exposed-config': { what: 'A configuration file with credentials is publicly readable.', risk: 'An attacker can log into your server or accounts.' },
|
|
62
|
+
'exposed-htpasswd': { what: 'The password file of your protected area can be downloaded.', risk: 'The passwords can be cracked within hours.' },
|
|
63
|
+
'exposed-phpinfo': { what: 'A diagnostic page shows every technical detail of your server.', risk: 'An attacker knows exactly which flaws to try.' },
|
|
64
|
+
'exposed-server-status': { what: 'The server status page is visible to everyone.', risk: 'It shows live visitors and internal addresses.' },
|
|
65
|
+
'directory-listing': { what: 'Some folders show their content like a file explorer.', risk: 'Anyone can browse and download files you never shared.' },
|
|
66
|
+
'exposed-ds-store': { what: 'A hidden file created by a Mac reveals the files in a folder.', risk: 'It helps attackers find sensitive files.' },
|
|
67
|
+
'security-txt-missing': { what: 'There is no page explaining how to report a vulnerability to you.', risk: 'Someone who finds a problem does not know how to warn you.' },
|
|
68
|
+
'insecure-form': { what: 'A login form sends the password without encryption.', risk: 'Someone on the same network can read the password.' },
|
|
69
|
+
'mixed-content': { what: 'Your secure page loads some elements without a padlock.', risk: 'Some elements can be blocked or swapped by an attacker.' },
|
|
70
|
+
'outdated-library': { what: 'Your site uses an old version of a JavaScript tool with known flaws.', risk: 'Attackers know these flaws and how to exploit them.' },
|
|
71
|
+
'sri-missing': { what: 'Scripts are loaded from another site without checking their content.', risk: 'If that other site is hacked, so is yours.' },
|
|
72
|
+
'version-disclosure': { what: 'Your server shows the exact versions of the software it runs.', risk: 'An attacker can look up the flaws of those versions directly.' },
|
|
73
|
+
},
|
|
74
|
+
};
|
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { mkdirSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { createInterface } from 'node:readline';
|
|
6
|
+
import { renderBanner } from './banner.js';
|
|
7
|
+
import { SNIPPETS } from './catalog.js';
|
|
8
|
+
import { toHtml } from './html.js';
|
|
9
|
+
import { dict, message, plainText } from './i18n/index.js';
|
|
10
|
+
import { normalizeTarget } from './net.js';
|
|
11
|
+
import { pkg, scanTarget } from './scan.js';
|
|
12
|
+
import { BADGES, TONES, c } from './ui.js';
|
|
13
|
+
|
|
14
|
+
const STEPS = ['connect', 'transport', 'headers', 'content', 'exposure'];
|
|
15
|
+
const LEGACY_CONSOLE = process.platform === 'win32' && !process.env.WT_SESSION && process.env.TERM_PROGRAM !== 'vscode';
|
|
16
|
+
const SPINNER = LEGACY_CONSOLE ? ['|', '/', '-', '\\'] : ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
17
|
+
const OK = LEGACY_CONSOLE ? '√' : '✔';
|
|
18
|
+
const FAIL = LEGACY_CONSOLE ? '×' : '✖';
|
|
19
|
+
const GROUPS = [
|
|
20
|
+
['urgent', ['critical', 'high']],
|
|
21
|
+
['improve', ['medium', 'low']],
|
|
22
|
+
['info', ['info']],
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
const GLYPHS = {
|
|
26
|
+
A: ['▄▀▀▄', '█▄▄█', '█ █'],
|
|
27
|
+
B: ['█▀▀▄', '█▀▀▄', '█▄▄▀'],
|
|
28
|
+
C: ['▄▀▀▀', '█ ', '▀▄▄▄'],
|
|
29
|
+
D: ['█▀▀▄', '█ █', '█▄▄▀'],
|
|
30
|
+
F: ['█▀▀▀', '█▀▀ ', '█ '],
|
|
31
|
+
'+': [' ', '▄█▄ ', ' ▀ '],
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const subject = (finding) => (finding.rule === 'outdated-library' ? ` (${finding.params.name} ${finding.params.version})` : '');
|
|
35
|
+
|
|
36
|
+
const GRADE_TONE = { 'A+': c.green, A: c.green, B: c.green, C: c.yellow, D: TONES.high, F: c.red };
|
|
37
|
+
|
|
38
|
+
const width = () => Math.max(60, Math.min(process.stdout.columns || 100, 104));
|
|
39
|
+
const strip = (text) => String(text).replace(/\x1b\[[0-9;]*m/g, '');
|
|
40
|
+
|
|
41
|
+
function wrap(text, indent, firstWidth = 0) {
|
|
42
|
+
const room = width() - indent;
|
|
43
|
+
const words = String(text).split(/\s+/).filter(Boolean);
|
|
44
|
+
const lines = [];
|
|
45
|
+
let line = '';
|
|
46
|
+
let limit = room - firstWidth;
|
|
47
|
+
for (const word of words) {
|
|
48
|
+
if (line && line.length + 1 + word.length > limit) {
|
|
49
|
+
lines.push(line);
|
|
50
|
+
line = word;
|
|
51
|
+
limit = room - firstWidth;
|
|
52
|
+
} else line = line ? `${line} ${word}` : word;
|
|
53
|
+
}
|
|
54
|
+
if (line) lines.push(line);
|
|
55
|
+
return lines;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function block(label, text, labelWidth, tone = (s) => s) {
|
|
59
|
+
const pad = ' ';
|
|
60
|
+
const rows = wrap(text, pad.length + labelWidth + 2);
|
|
61
|
+
return rows.map((row, index) => `${pad}${index === 0 ? c.gray(label.padEnd(labelWidth)) : ' '.repeat(labelWidth)} ${tone(row)}`).join('\n');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
class Prompt {
|
|
65
|
+
constructor() {
|
|
66
|
+
this.queue = [];
|
|
67
|
+
this.waiting = null;
|
|
68
|
+
this.closed = false;
|
|
69
|
+
this.rl = createInterface({ input: process.stdin, output: process.stdout, terminal: Boolean(process.stdin.isTTY) });
|
|
70
|
+
this.rl.on('line', (line) => {
|
|
71
|
+
if (this.waiting) {
|
|
72
|
+
const resolve = this.waiting;
|
|
73
|
+
this.waiting = null;
|
|
74
|
+
resolve(line);
|
|
75
|
+
} else this.queue.push(line);
|
|
76
|
+
});
|
|
77
|
+
this.rl.on('close', () => {
|
|
78
|
+
this.closed = true;
|
|
79
|
+
if (this.waiting) {
|
|
80
|
+
const resolve = this.waiting;
|
|
81
|
+
this.waiting = null;
|
|
82
|
+
resolve(null);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
this.rl.on('SIGINT', () => {
|
|
86
|
+
this.rl.close();
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
ask(label) {
|
|
91
|
+
process.stdout.write(label);
|
|
92
|
+
const echo = (line) => {
|
|
93
|
+
if (line !== null && !process.stdin.isTTY) process.stdout.write(`${line}\n`);
|
|
94
|
+
return line;
|
|
95
|
+
};
|
|
96
|
+
if (this.queue.length) return Promise.resolve(echo(this.queue.shift()));
|
|
97
|
+
if (this.closed) return Promise.resolve(null);
|
|
98
|
+
return new Promise((resolve) => {
|
|
99
|
+
this.waiting = (line) => resolve(echo(line));
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
close() {
|
|
104
|
+
this.rl.close();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export class App {
|
|
109
|
+
constructor({ lang, timeout = 10000, ca, httpPort, reportDir } = {}) {
|
|
110
|
+
this.lang = lang;
|
|
111
|
+
this.timeout = timeout;
|
|
112
|
+
this.ca = ca;
|
|
113
|
+
this.httpPort = httpPort;
|
|
114
|
+
this.reportDir = reportDir ?? join(homedir(), 'Documents', 'vigie');
|
|
115
|
+
this.tty = Boolean(process.stdout.isTTY);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
get d() {
|
|
119
|
+
return dict(this.lang);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
clear() {
|
|
123
|
+
if (this.tty) process.stdout.write('\x1b[2J\x1b[3J\x1b[H');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
header() {
|
|
127
|
+
this.clear();
|
|
128
|
+
console.log(renderBanner('vigie', this.d.ui.tagline(pkg.version)));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async run() {
|
|
132
|
+
if (this.tty) process.stdout.write('\x1b]0;vigie · FreshDev\x07');
|
|
133
|
+
this.prompt = new Prompt();
|
|
134
|
+
try {
|
|
135
|
+
while (true) {
|
|
136
|
+
const target = await this.askTarget();
|
|
137
|
+
if (!target) break;
|
|
138
|
+
const probe = await this.askOwner(target);
|
|
139
|
+
if (probe === null) break;
|
|
140
|
+
const result = await this.scan(target, probe);
|
|
141
|
+
const next = await this.results(result, probe);
|
|
142
|
+
if (next !== 'again') break;
|
|
143
|
+
}
|
|
144
|
+
} finally {
|
|
145
|
+
console.log(`\n ${c.gray(this.d.app.bye)}\n`);
|
|
146
|
+
this.prompt.close();
|
|
147
|
+
}
|
|
148
|
+
return 0;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
async askTarget() {
|
|
152
|
+
let error = null;
|
|
153
|
+
while (true) {
|
|
154
|
+
const a = this.d.app;
|
|
155
|
+
this.header();
|
|
156
|
+
console.log(` ${a.intro}\n`);
|
|
157
|
+
if (error) console.log(` ${c.red(FAIL)} ${error}\n`);
|
|
158
|
+
console.log(` ${c.gray(a.askUrlHint)}`);
|
|
159
|
+
const answer = await this.prompt.ask(` ${c.cyan('›')} ${c.bold(a.askUrl)} : `);
|
|
160
|
+
if (answer === null) return null;
|
|
161
|
+
const value = answer.trim();
|
|
162
|
+
if (!value) return null;
|
|
163
|
+
if (value.toLowerCase() === a.keys.lang) {
|
|
164
|
+
this.lang = this.lang === 'fr' ? 'en' : 'fr';
|
|
165
|
+
error = null;
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
try {
|
|
169
|
+
return normalizeTarget(value);
|
|
170
|
+
} catch {
|
|
171
|
+
error = a.invalidUrl(value);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
async askOwner(target) {
|
|
177
|
+
const a = this.d.app;
|
|
178
|
+
console.log('');
|
|
179
|
+
console.log(` ${c.bold(target.host)}`);
|
|
180
|
+
for (const line of a.ownerHint) console.log(` ${c.gray(line)}`);
|
|
181
|
+
const answer = await this.prompt.ask(` ${c.cyan('›')} ${c.bold(a.askOwner)} ${c.gray(a.yesNo)} `);
|
|
182
|
+
if (answer === null) return null;
|
|
183
|
+
return a.yes.includes(answer.trim().toLowerCase());
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
async scan(target, probe) {
|
|
187
|
+
const a = this.d.app;
|
|
188
|
+
this.header();
|
|
189
|
+
console.log(` ${c.bold(a.scanning(target.href))}\n`);
|
|
190
|
+
const states = Object.fromEntries(STEPS.map((step) => [step, 'todo']));
|
|
191
|
+
if (!probe) states.exposure = 'skip';
|
|
192
|
+
let frame = 0;
|
|
193
|
+
let drawn = false;
|
|
194
|
+
const render = () => {
|
|
195
|
+
const lines = STEPS.map((step) => {
|
|
196
|
+
const state = states[step];
|
|
197
|
+
const label = a.steps[step];
|
|
198
|
+
if (state === 'done') return ` ${c.green(OK)} ${label}`;
|
|
199
|
+
if (state === 'active') return ` ${c.cyan(SPINNER[frame % SPINNER.length])} ${c.bold(label)}`;
|
|
200
|
+
if (state === 'skip') return ` ${c.gray('–')} ${c.gray(`${label} · ${a.skipped}`)}`;
|
|
201
|
+
if (state === 'fail') return ` ${c.red(FAIL)} ${label}`;
|
|
202
|
+
return ` ${c.gray('·')} ${c.gray(label)}`;
|
|
203
|
+
});
|
|
204
|
+
if (this.tty) {
|
|
205
|
+
if (drawn) process.stdout.write(`\x1b[${lines.length}A`);
|
|
206
|
+
process.stdout.write(lines.map((line) => `\x1b[2K${line}`).join('\n') + '\n');
|
|
207
|
+
drawn = true;
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
const timer = this.tty ? setInterval(() => { frame++; render(); }, 90) : null;
|
|
211
|
+
let current = null;
|
|
212
|
+
const onStep = (step) => {
|
|
213
|
+
if (current && states[current] === 'active') states[current] = 'done';
|
|
214
|
+
if (step === 'done') {
|
|
215
|
+
current = null;
|
|
216
|
+
} else if (states[step] !== undefined && states[step] !== 'skip') {
|
|
217
|
+
states[step] = 'active';
|
|
218
|
+
current = step;
|
|
219
|
+
if (!this.tty) console.log(` … ${a.steps[step]}`);
|
|
220
|
+
}
|
|
221
|
+
render();
|
|
222
|
+
};
|
|
223
|
+
render();
|
|
224
|
+
let result;
|
|
225
|
+
try {
|
|
226
|
+
result = await scanTarget(target.href, { timeout: this.timeout, probe, ca: this.ca, httpPort: this.httpPort, onStep });
|
|
227
|
+
} finally {
|
|
228
|
+
if (timer) clearInterval(timer);
|
|
229
|
+
}
|
|
230
|
+
if (!result.reachable) {
|
|
231
|
+
for (const step of STEPS) if (states[step] !== 'done' && states[step] !== 'skip') states[step] = step === 'connect' || states[step] === 'active' ? 'fail' : 'todo';
|
|
232
|
+
}
|
|
233
|
+
render();
|
|
234
|
+
return result;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
bigGrade(grade) {
|
|
238
|
+
const letters = grade.split('');
|
|
239
|
+
const tone = GRADE_TONE[grade];
|
|
240
|
+
return [0, 1, 2].map((row) => tone(letters.map((letter) => GLYPHS[letter][row]).join(' ')));
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
list(result) {
|
|
244
|
+
const items = [];
|
|
245
|
+
for (const [, severities] of GROUPS) {
|
|
246
|
+
for (const finding of result.findings) if (severities.includes(finding.severity)) items.push(finding);
|
|
247
|
+
}
|
|
248
|
+
return items;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
renderResults(result, probe) {
|
|
252
|
+
const d = this.d;
|
|
253
|
+
const a = d.app;
|
|
254
|
+
this.header();
|
|
255
|
+
console.log(` ${c.bold(result.finalUrl ?? result.url)}\n`);
|
|
256
|
+
|
|
257
|
+
if (!result.reachable) {
|
|
258
|
+
console.log(` ${c.red(FAIL)} ${c.bold(a.unreachableTitle)}`);
|
|
259
|
+
for (const line of wrap(a.unreachable(result.url, result.error), 4)) console.log(` ${line}`);
|
|
260
|
+
console.log('');
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const big = this.bigGrade(result.grade);
|
|
264
|
+
const counts = ['critical', 'high', 'medium', 'low', 'info'].filter((severity) => result.counts[severity]).map((severity) => TONES[severity](d.severityCounts(result.counts[severity], severity)));
|
|
265
|
+
const side = [
|
|
266
|
+
`${c.gray(a.grade)} ${c.bold(`${result.score}`)}${c.gray('/100')}`,
|
|
267
|
+
d.verdicts[result.grade],
|
|
268
|
+
counts.join(c.gray(' · ')),
|
|
269
|
+
];
|
|
270
|
+
big.forEach((row, index) => console.log(` ${row} ${side[index] ?? ''}`));
|
|
271
|
+
console.log('');
|
|
272
|
+
if (!probe && result.reachable) console.log(` ${c.gray(a.skippedNote)}\n`);
|
|
273
|
+
|
|
274
|
+
const items = this.list(result);
|
|
275
|
+
if (!items.length && result.reachable) console.log(` ${c.green(OK)} ${a.noFindings}\n`);
|
|
276
|
+
let index = 0;
|
|
277
|
+
for (const [group, severities] of GROUPS) {
|
|
278
|
+
const inGroup = items.filter((finding) => severities.includes(finding.severity));
|
|
279
|
+
if (!inGroup.length) continue;
|
|
280
|
+
console.log(` ${c.bold(a.groups[group].toUpperCase())}`);
|
|
281
|
+
for (const finding of inGroup) {
|
|
282
|
+
index++;
|
|
283
|
+
const number = String(index).padStart(2);
|
|
284
|
+
const badge = TONES[finding.severity]('●');
|
|
285
|
+
console.log(` ${c.cyan(number)} ${badge} ${c.bold(`${d.rules[finding.rule].title}${subject(finding)}`)} ${c.gray(`· ${d.severityTitles[finding.severity]}`)}`);
|
|
286
|
+
for (const line of wrap(plainText(this.lang, finding.rule).what, 8)) console.log(` ${c.gray(line)}`);
|
|
287
|
+
}
|
|
288
|
+
console.log('');
|
|
289
|
+
}
|
|
290
|
+
return items;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
async results(result, probe) {
|
|
294
|
+
let notice = null;
|
|
295
|
+
while (true) {
|
|
296
|
+
const a = this.d.app;
|
|
297
|
+
const items = this.renderResults(result, probe);
|
|
298
|
+
const menu = [items.length ? a.menu.detail(items.length) : null, result.reachable ? a.menu.report : null, a.menu.again, a.menu.quit].filter(Boolean);
|
|
299
|
+
const counts = ['critical', 'high', 'medium', 'low', 'info'].filter((severity) => result.counts[severity]).map((severity) => TONES[severity](this.d.severityCounts(result.counts[severity], severity)));
|
|
300
|
+
console.log(` ${c.gray('─'.repeat(Math.min(width() - 4, 70)))}`);
|
|
301
|
+
console.log(` ${GRADE_TONE[result.grade](c.bold(`${a.grade} ${result.grade}`))} ${c.gray('·')} ${result.score}${c.gray('/100')}${counts.length ? ` ${c.gray('·')} ${counts.join(c.gray(' · '))}` : ''}`);
|
|
302
|
+
console.log(` ${c.gray('─'.repeat(Math.min(width() - 4, 70)))}`);
|
|
303
|
+
const rows = menu.map((entry) => entry.split(' '));
|
|
304
|
+
const keyWidth = Math.max(...rows.map(([key]) => key.length));
|
|
305
|
+
for (const [key, ...rest] of rows) console.log(` ${c.cyan(key.padEnd(keyWidth))} ${rest.join(' ')}`);
|
|
306
|
+
if (notice) console.log(`\n ${notice}`);
|
|
307
|
+
notice = null;
|
|
308
|
+
const answer = await this.prompt.ask(`\n ${c.cyan('›')} ${c.bold(a.choice)} : `);
|
|
309
|
+
if (answer === null) return 'quit';
|
|
310
|
+
const value = answer.trim().toLowerCase();
|
|
311
|
+
if (value === a.keys.quit || value === 'q') return 'quit';
|
|
312
|
+
if (value === a.keys.again || value === 'n') return 'again';
|
|
313
|
+
if (value === a.keys.lang) {
|
|
314
|
+
this.lang = this.lang === 'fr' ? 'en' : 'fr';
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
if ((value === a.keys.report || value === 'r') && result.reachable) {
|
|
318
|
+
notice = this.saveReport(result);
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
const number = Number(value);
|
|
322
|
+
if (Number.isInteger(number) && number >= 1 && number <= items.length) {
|
|
323
|
+
const back = await this.detail(items[number - 1], number, result);
|
|
324
|
+
if (back === null) return 'quit';
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
async detail(finding, number, result) {
|
|
330
|
+
const d = this.d;
|
|
331
|
+
const a = d.app;
|
|
332
|
+
const rule = d.rules[finding.rule];
|
|
333
|
+
const plain = plainText(this.lang, finding.rule);
|
|
334
|
+
this.header();
|
|
335
|
+
const tone = TONES[finding.severity];
|
|
336
|
+
const tags = [d.severityTitles[finding.severity].toUpperCase(), d.categories[finding.category], finding.cwe ? `CWE-${finding.cwe}` : null].filter(Boolean);
|
|
337
|
+
console.log(` ${c.gray(`#${number}`)} ${BADGES[finding.severity](` ${tags[0]} `)} ${c.gray(tags.slice(1).join(' · '))}`);
|
|
338
|
+
console.log(` ${c.bold(`${rule.title}${subject(finding)}`)}\n`);
|
|
339
|
+
const labelWidth = Math.max(...Object.values(a.labels).map((label) => label.length));
|
|
340
|
+
console.log(block(a.labels.what, plain.what, labelWidth, c.bold));
|
|
341
|
+
console.log('');
|
|
342
|
+
console.log(block(a.labels.risk, plain.risk, labelWidth, tone));
|
|
343
|
+
console.log('');
|
|
344
|
+
console.log(block(a.labels.seen, message(this.lang, finding), labelWidth));
|
|
345
|
+
for (const line of finding.evidence.slice(0, 6)) {
|
|
346
|
+
const text = line.length > width() - labelWidth - 10 ? `${line.slice(0, width() - labelWidth - 13)}…` : line;
|
|
347
|
+
console.log(` ${' '.repeat(labelWidth)} ${c.gray('│')} ${c.dim(text)}`);
|
|
348
|
+
}
|
|
349
|
+
console.log('');
|
|
350
|
+
console.log(block(a.labels.fix, rule.fix, labelWidth, c.green));
|
|
351
|
+
const snippet = SNIPPETS[finding.rule];
|
|
352
|
+
if (snippet) {
|
|
353
|
+
for (const [server, code] of Object.entries(snippet)) {
|
|
354
|
+
const name = server === 'file' ? 'security.txt' : server;
|
|
355
|
+
console.log('');
|
|
356
|
+
code.split('\n').forEach((row, index) => console.log(` ${' '.repeat(labelWidth)} ${c.gray((index === 0 ? name : '').padEnd(12))}${c.cyan(row)}`));
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
console.log('');
|
|
360
|
+
for (const line of wrap(rule.description, 4)) console.log(` ${c.gray(line)}`);
|
|
361
|
+
console.log(`\n ${c.yellow(LEGACY_CONSOLE ? '→' : '➜')} ${a.share}`);
|
|
362
|
+
const answer = await this.prompt.ask(`\n ${c.gray(a.back)} `);
|
|
363
|
+
return answer;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
saveReport(result) {
|
|
367
|
+
const a = this.d.app;
|
|
368
|
+
try {
|
|
369
|
+
mkdirSync(this.reportDir, { recursive: true });
|
|
370
|
+
const stamp = new Date().toISOString().slice(0, 16).replace(/[-:T]/g, '').replace(/^(\d{8})(\d{4})$/, '$1-$2');
|
|
371
|
+
const host = new URL(result.finalUrl ?? result.url).hostname.replace(/[^a-z0-9.-]/gi, '_');
|
|
372
|
+
const file = join(this.reportDir, `vigie-${host}-${stamp}.html`);
|
|
373
|
+
writeFileSync(file, toHtml([result], this.lang));
|
|
374
|
+
const opened = openFile(file);
|
|
375
|
+
return `${c.green(OK)} ${a.reportSaved(file)}${opened ? `\n ${c.gray(a.reportOpened)}` : ''}`;
|
|
376
|
+
} catch (err) {
|
|
377
|
+
return `${c.red(FAIL)} ${a.reportFailed(err.code || err.message)}`;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
export function openFile(file) {
|
|
383
|
+
if (process.env.VIGIE_NO_OPEN) return false;
|
|
384
|
+
try {
|
|
385
|
+
const [command, args] = process.platform === 'win32' ? ['cmd', ['/c', 'start', '""', `"${file}"`]] : process.platform === 'darwin' ? ['open', [file]] : ['xdg-open', [file]];
|
|
386
|
+
const child = spawn(command, args, { detached: true, stdio: 'ignore', windowsVerbatimArguments: process.platform === 'win32', shell: false });
|
|
387
|
+
child.on('error', () => {});
|
|
388
|
+
child.unref();
|
|
389
|
+
return true;
|
|
390
|
+
} catch {
|
|
391
|
+
return false;
|
|
392
|
+
}
|
|
393
|
+
}
|
package/src/report.js
CHANGED
|
@@ -73,7 +73,7 @@ export function printTarget(result, { lang, quiet, probe }) {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
const counts = ORDER.filter((severity) => result.counts[severity]).map((severity) => TONES[severity](
|
|
76
|
+
const counts = ORDER.filter((severity) => result.counts[severity]).map((severity) => TONES[severity](d.severityCounts(result.counts[severity], severity)));
|
|
77
77
|
const letter = result.grade;
|
|
78
78
|
console.log(` ${GRADE_TONE[letter](c.bold(`[ ${letter.padEnd(2)} ]`))} ${gauge(result.score)} ${c.bold(String(result.score))}${c.gray('/100')}`);
|
|
79
79
|
console.log(` ${d.verdicts[letter]}`);
|
package/src/scan.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { readFileSync } from 'node:fs';
|
|
2
1
|
import { CATEGORIES, RULES, SEVERITIES, score, severityRank } from './catalog.js';
|
|
3
2
|
import { Client, normalizeTarget } from './net.js';
|
|
4
3
|
import { transportChecks } from './checks/transport.js';
|
|
@@ -6,7 +5,9 @@ import { cookieChecks, headerChecks } from './checks/headers.js';
|
|
|
6
5
|
import { exposureChecks } from './checks/exposure.js';
|
|
7
6
|
import { contentChecks, disclosureChecks } from './checks/content.js';
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
import { VERSION } from './version.js';
|
|
9
|
+
|
|
10
|
+
export const pkg = { version: VERSION };
|
|
10
11
|
|
|
11
12
|
const SHOWN_HEADERS = [
|
|
12
13
|
'server', 'content-type', 'strict-transport-security', 'content-security-policy', 'x-frame-options', 'x-content-type-options',
|
|
@@ -45,6 +46,8 @@ export async function scanTarget(input, options = {}) {
|
|
|
45
46
|
const secureUrl = variant(target, 'https:', String(securePort));
|
|
46
47
|
const plainUrl = plainPort === null ? null : variant(target, 'http:', String(plainPort));
|
|
47
48
|
|
|
49
|
+
const step = (name) => options.onStep?.(name);
|
|
50
|
+
step('connect');
|
|
48
51
|
const https = await client.follow(secureUrl.href);
|
|
49
52
|
const http = plainUrl ? await client.follow(plainUrl.href) : [];
|
|
50
53
|
|
|
@@ -62,14 +65,19 @@ export async function scanTarget(input, options = {}) {
|
|
|
62
65
|
|
|
63
66
|
const ctx = { add, client, target, https, http, main: reachable ? main : null, html, origin: reachable ? new URL(main.url).origin : null };
|
|
64
67
|
|
|
68
|
+
step('transport');
|
|
65
69
|
await transportChecks(ctx);
|
|
66
70
|
if (reachable) {
|
|
71
|
+
step('headers');
|
|
67
72
|
await headerChecks(ctx);
|
|
68
73
|
cookieChecks(ctx);
|
|
74
|
+
step('content');
|
|
69
75
|
contentChecks(ctx);
|
|
70
76
|
disclosureChecks(ctx);
|
|
77
|
+
step('exposure');
|
|
71
78
|
await exposureChecks(ctx, { probe: options.probe !== false });
|
|
72
79
|
}
|
|
80
|
+
step('done');
|
|
73
81
|
|
|
74
82
|
const order = (a, b) => severityRank(b.severity) - severityRank(a.severity) || CATEGORIES.indexOf(a.category) - CATEGORIES.indexOf(b.category);
|
|
75
83
|
findings.sort(order);
|
package/src/version.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const VERSION = '1.1.0';
|