vigie-cli 0.0.0-stage → 1.0.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 +14 -0
- package/LICENSE +21 -0
- package/README.fr.md +165 -0
- package/README.md +164 -2
- package/bin/vigie.js +18 -0
- package/package.json +43 -4
- package/src/args.js +33 -0
- package/src/banner.js +62 -0
- package/src/catalog.js +139 -0
- package/src/checks/content.js +100 -0
- package/src/checks/exposure.js +83 -0
- package/src/checks/headers.js +118 -0
- package/src/checks/transport.js +79 -0
- package/src/cli.js +82 -0
- package/src/errors.js +7 -0
- package/src/html.js +424 -0
- package/src/i18n/en.js +351 -0
- package/src/i18n/fr.js +352 -0
- package/src/i18n/index.js +29 -0
- package/src/net.js +159 -0
- package/src/report.js +125 -0
- package/src/scan.js +103 -0
- package/src/ui.js +36 -0
package/src/catalog.js
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
export const SEVERITIES = ['info', 'low', 'medium', 'high', 'critical'];
|
|
2
|
+
|
|
3
|
+
export const severityRank = (severity) => SEVERITIES.indexOf(severity);
|
|
4
|
+
|
|
5
|
+
export const CATEGORIES = ['transport', 'headers', 'cookies', 'exposure', 'content', 'disclosure'];
|
|
6
|
+
|
|
7
|
+
export const RULES = {
|
|
8
|
+
'no-https': { severity: 'critical', category: 'transport', cwe: 319 },
|
|
9
|
+
'tls-invalid-cert': { severity: 'critical', category: 'transport', cwe: 295 },
|
|
10
|
+
'tls-old-protocol': { severity: 'high', category: 'transport', cwe: 326 },
|
|
11
|
+
'tls-expiring': { severity: 'medium', category: 'transport', cwe: 298 },
|
|
12
|
+
'http-no-redirect': { severity: 'high', category: 'transport', cwe: 319 },
|
|
13
|
+
'insecure-redirect': { severity: 'medium', category: 'transport', cwe: 319 },
|
|
14
|
+
'hsts-missing': { severity: 'medium', category: 'transport', cwe: 523 },
|
|
15
|
+
'hsts-weak': { severity: 'low', category: 'transport', cwe: 523 },
|
|
16
|
+
'csp-missing': { severity: 'medium', category: 'headers', cwe: 693 },
|
|
17
|
+
'csp-unsafe': { severity: 'medium', category: 'headers', cwe: 693 },
|
|
18
|
+
clickjacking: { severity: 'medium', category: 'headers', cwe: 1021 },
|
|
19
|
+
'cors-reflected-origin': { severity: 'high', category: 'headers', cwe: 942 },
|
|
20
|
+
'cors-wildcard-credentials': { severity: 'medium', category: 'headers', cwe: 942 },
|
|
21
|
+
'nosniff-missing': { severity: 'low', category: 'headers', cwe: 693 },
|
|
22
|
+
'referrer-policy': { severity: 'low', category: 'headers', cwe: 200 },
|
|
23
|
+
'permissions-policy-missing': { severity: 'info', category: 'headers', cwe: 693 },
|
|
24
|
+
'cookie-not-secure': { severity: 'medium', category: 'cookies', cwe: 614 },
|
|
25
|
+
'cookie-no-httponly': { severity: 'medium', category: 'cookies', cwe: 1004 },
|
|
26
|
+
'cookie-no-samesite': { severity: 'low', category: 'cookies', cwe: 1275 },
|
|
27
|
+
'exposed-git': { severity: 'critical', category: 'exposure', cwe: 538 },
|
|
28
|
+
'exposed-env': { severity: 'critical', category: 'exposure', cwe: 538 },
|
|
29
|
+
'exposed-backup': { severity: 'critical', category: 'exposure', cwe: 530 },
|
|
30
|
+
'exposed-config': { severity: 'critical', category: 'exposure', cwe: 538 },
|
|
31
|
+
'exposed-htpasswd': { severity: 'critical', category: 'exposure', cwe: 522 },
|
|
32
|
+
'exposed-phpinfo': { severity: 'high', category: 'exposure', cwe: 200 },
|
|
33
|
+
'exposed-server-status': { severity: 'medium', category: 'exposure', cwe: 200 },
|
|
34
|
+
'directory-listing': { severity: 'medium', category: 'exposure', cwe: 548 },
|
|
35
|
+
'exposed-ds-store': { severity: 'low', category: 'exposure', cwe: 538 },
|
|
36
|
+
'security-txt-missing': { severity: 'info', category: 'exposure', cwe: null },
|
|
37
|
+
'insecure-form': { severity: 'high', category: 'content', cwe: 319 },
|
|
38
|
+
'mixed-content': { severity: 'medium', category: 'content', cwe: 319 },
|
|
39
|
+
'outdated-library': { severity: 'medium', category: 'content', cwe: 1104 },
|
|
40
|
+
'sri-missing': { severity: 'low', category: 'content', cwe: 353 },
|
|
41
|
+
'version-disclosure': { severity: 'low', category: 'disclosure', cwe: 200 },
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const PENALTY = { critical: 40, high: 20, medium: 10, low: 5, info: 0 };
|
|
45
|
+
|
|
46
|
+
export function score(findings) {
|
|
47
|
+
const value = Math.max(0, 100 - findings.reduce((sum, finding) => sum + PENALTY[finding.severity], 0));
|
|
48
|
+
let grade;
|
|
49
|
+
if (findings.some((finding) => finding.severity === 'critical')) grade = 'F';
|
|
50
|
+
else if (!findings.some((finding) => finding.severity !== 'info')) grade = 'A+';
|
|
51
|
+
else if (value >= 90) grade = 'A';
|
|
52
|
+
else if (value >= 75) grade = 'B';
|
|
53
|
+
else if (value >= 60) grade = 'C';
|
|
54
|
+
else if (value >= 40) grade = 'D';
|
|
55
|
+
else grade = 'F';
|
|
56
|
+
return { value, grade };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const SNIPPETS = {
|
|
60
|
+
'http-no-redirect': {
|
|
61
|
+
nginx: 'server {\n listen 80;\n server_name example.com;\n return 301 https://$host$request_uri;\n}',
|
|
62
|
+
apache: 'RewriteEngine On\nRewriteCond %{HTTPS} off\nRewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]',
|
|
63
|
+
},
|
|
64
|
+
'tls-old-protocol': {
|
|
65
|
+
nginx: 'ssl_protocols TLSv1.2 TLSv1.3;',
|
|
66
|
+
apache: 'SSLProtocol -all +TLSv1.2 +TLSv1.3',
|
|
67
|
+
},
|
|
68
|
+
'hsts-missing': {
|
|
69
|
+
nginx: 'add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" always;',
|
|
70
|
+
apache: 'Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains"',
|
|
71
|
+
},
|
|
72
|
+
'hsts-weak': {
|
|
73
|
+
nginx: 'add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" always;',
|
|
74
|
+
apache: 'Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains"',
|
|
75
|
+
},
|
|
76
|
+
'csp-missing': {
|
|
77
|
+
nginx: "add_header Content-Security-Policy \"default-src 'self'; object-src 'none'; frame-ancestors 'self'; base-uri 'self'\" always;",
|
|
78
|
+
apache: "Header always set Content-Security-Policy \"default-src 'self'; object-src 'none'; frame-ancestors 'self'; base-uri 'self'\"",
|
|
79
|
+
},
|
|
80
|
+
clickjacking: {
|
|
81
|
+
nginx: 'add_header X-Frame-Options "SAMEORIGIN" always;',
|
|
82
|
+
apache: 'Header always set X-Frame-Options "SAMEORIGIN"',
|
|
83
|
+
},
|
|
84
|
+
'nosniff-missing': {
|
|
85
|
+
nginx: 'add_header X-Content-Type-Options "nosniff" always;',
|
|
86
|
+
apache: 'Header always set X-Content-Type-Options "nosniff"',
|
|
87
|
+
},
|
|
88
|
+
'referrer-policy': {
|
|
89
|
+
nginx: 'add_header Referrer-Policy "strict-origin-when-cross-origin" always;',
|
|
90
|
+
apache: 'Header always set Referrer-Policy "strict-origin-when-cross-origin"',
|
|
91
|
+
},
|
|
92
|
+
'permissions-policy-missing': {
|
|
93
|
+
nginx: 'add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;',
|
|
94
|
+
apache: 'Header always set Permissions-Policy "camera=(), microphone=(), geolocation=()"',
|
|
95
|
+
},
|
|
96
|
+
'exposed-git': {
|
|
97
|
+
nginx: 'location ~ /\\.(?!well-known/) {\n deny all;\n}',
|
|
98
|
+
apache: 'RedirectMatch 404 /\\.(?!well-known/)',
|
|
99
|
+
},
|
|
100
|
+
'exposed-env': {
|
|
101
|
+
nginx: 'location ~ /\\.(?!well-known/) {\n deny all;\n}',
|
|
102
|
+
apache: 'RedirectMatch 404 /\\.(?!well-known/)',
|
|
103
|
+
},
|
|
104
|
+
'exposed-htpasswd': {
|
|
105
|
+
nginx: 'location ~ /\\.ht {\n deny all;\n}',
|
|
106
|
+
apache: '<Files ".ht*">\n Require all denied\n</Files>',
|
|
107
|
+
},
|
|
108
|
+
'exposed-backup': {
|
|
109
|
+
nginx: 'location ~* \\.(sql|zip|tar|gz|bak|old|swp)$|~$ {\n deny all;\n}',
|
|
110
|
+
apache: '<FilesMatch "\\.(sql|zip|tar|gz|bak|old|swp)$|~$">\n Require all denied\n</FilesMatch>',
|
|
111
|
+
},
|
|
112
|
+
'exposed-server-status': {
|
|
113
|
+
nginx: 'location = /nginx_status {\n allow 127.0.0.1;\n deny all;\n}',
|
|
114
|
+
apache: '<Location "/server-status">\n Require local\n</Location>',
|
|
115
|
+
},
|
|
116
|
+
'directory-listing': {
|
|
117
|
+
nginx: 'autoindex off;',
|
|
118
|
+
apache: 'Options -Indexes',
|
|
119
|
+
},
|
|
120
|
+
'version-disclosure': {
|
|
121
|
+
nginx: 'server_tokens off;',
|
|
122
|
+
apache: 'ServerTokens Prod\nServerSignature Off\nHeader always unset X-Powered-By',
|
|
123
|
+
},
|
|
124
|
+
'cookie-not-secure': {
|
|
125
|
+
nginx: 'proxy_cookie_flags ~ secure httponly samesite=lax;',
|
|
126
|
+
apache: 'Header always edit Set-Cookie ^(.*)$ "$1; Secure; HttpOnly; SameSite=Lax"',
|
|
127
|
+
},
|
|
128
|
+
'cookie-no-httponly': {
|
|
129
|
+
nginx: 'proxy_cookie_flags ~ secure httponly samesite=lax;',
|
|
130
|
+
apache: 'Header always edit Set-Cookie ^(.*)$ "$1; Secure; HttpOnly; SameSite=Lax"',
|
|
131
|
+
},
|
|
132
|
+
'cookie-no-samesite': {
|
|
133
|
+
nginx: 'proxy_cookie_flags ~ samesite=lax;',
|
|
134
|
+
apache: 'Header always edit Set-Cookie ^(.*)$ "$1; SameSite=Lax"',
|
|
135
|
+
},
|
|
136
|
+
'security-txt-missing': {
|
|
137
|
+
file: 'Contact: mailto:security@example.com\nExpires: 2027-12-31T23:59:59.000Z\nPreferred-Languages: fr, en',
|
|
138
|
+
},
|
|
139
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
const ATTR = (name) => new RegExp(`\\b${name}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, 'i');
|
|
2
|
+
|
|
3
|
+
const attr = (tag, name) => {
|
|
4
|
+
const match = ATTR(name).exec(tag);
|
|
5
|
+
return match ? (match[1] ?? match[2] ?? match[3]) : null;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export function tags(html, name) {
|
|
9
|
+
const re = new RegExp(`<${name}\\b[^>]*>`, 'gi');
|
|
10
|
+
return html.match(re) || [];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const cmp = (a, b) => {
|
|
14
|
+
const pa = a.split('.').map(Number);
|
|
15
|
+
const pb = b.split('.').map(Number);
|
|
16
|
+
for (let i = 0; i < 3; i++) {
|
|
17
|
+
if ((pa[i] || 0) !== (pb[i] || 0)) return (pa[i] || 0) - (pb[i] || 0);
|
|
18
|
+
}
|
|
19
|
+
return 0;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const LIBRARIES = [
|
|
23
|
+
{ name: 'jQuery', re: /jquery(?:[.-]|\/|@)(\d+\.\d+\.\d+)(?:[./-]|$)/i, vulnerable: (v) => cmp(v, '3.5.0') < 0, advisory: 'CVE-2020-11022', fixed: '3.5.0' },
|
|
24
|
+
{ name: 'Bootstrap', re: /bootstrap(?:[.-]|\/|@)(\d+\.\d+\.\d+)(?:[./-]|$)/i, vulnerable: (v) => cmp(v, '3.4.1') < 0 || (v.startsWith('4.') && cmp(v, '4.3.1') < 0), advisory: 'CVE-2019-8331', fixed: '4.3.1' },
|
|
25
|
+
{ name: 'AngularJS', re: /angular(?:js)?(?:[.-]|\/|@)(1\.\d+\.\d+)(?:[./-]|$)/i, vulnerable: () => true, advisory: 'EOL 2022', fixed: 'Angular' },
|
|
26
|
+
{ name: 'Lodash', re: /lodash(?:[.-]|\/|@)(\d+\.\d+\.\d+)(?:[./-]|$)/i, vulnerable: (v) => cmp(v, '4.17.21') < 0, advisory: 'CVE-2021-23337', fixed: '4.17.21' },
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
export function contentChecks(ctx) {
|
|
30
|
+
const { add, main } = ctx;
|
|
31
|
+
const html = ctx.html;
|
|
32
|
+
if (!main || !html) return;
|
|
33
|
+
const page = new URL(main.url);
|
|
34
|
+
const secure = page.protocol === 'https:';
|
|
35
|
+
|
|
36
|
+
const scripts = tags(html, 'script').map((tag) => ({ tag, src: attr(tag, 'src') })).filter((item) => item.src);
|
|
37
|
+
const styles = tags(html, 'link').filter((tag) => /\brel\s*=\s*["']?[^"'>]*stylesheet/i.test(tag)).map((tag) => ({ tag, src: attr(tag, 'href') })).filter((item) => item.src);
|
|
38
|
+
const frames = tags(html, 'iframe').map((tag) => ({ tag, src: attr(tag, 'src') })).filter((item) => item.src);
|
|
39
|
+
const images = tags(html, 'img').map((tag) => ({ tag, src: attr(tag, 'src') })).filter((item) => item.src);
|
|
40
|
+
|
|
41
|
+
if (secure) {
|
|
42
|
+
const active = [...scripts, ...styles, ...frames].map((item) => item.src).filter((src) => /^http:\/\//i.test(src));
|
|
43
|
+
const passive = images.map((item) => item.src).filter((src) => /^http:\/\//i.test(src));
|
|
44
|
+
if (active.length || passive.length) {
|
|
45
|
+
add('mixed-content', { active: active.length, passive: passive.length }, [...active, ...passive].slice(0, 8), active.length ? undefined : 'low');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const forms = html.match(/<form\b[^>]*>[\s\S]*?<\/form>/gi) || [];
|
|
50
|
+
const unsafeForms = [];
|
|
51
|
+
for (const form of forms) {
|
|
52
|
+
const open = form.match(/<form\b[^>]*>/i)[0];
|
|
53
|
+
const action = attr(open, 'action');
|
|
54
|
+
const target = action ? new URL(action, page).href : page.href;
|
|
55
|
+
const password = /<input\b[^>]*type\s*=\s*["']?password/i.test(form);
|
|
56
|
+
if (password && target.startsWith('http:')) unsafeForms.push(target);
|
|
57
|
+
}
|
|
58
|
+
if (unsafeForms.length) add('insecure-form', { actions: unsafeForms }, unsafeForms.map((target) => `<form action="${target}"> + <input type="password">`));
|
|
59
|
+
|
|
60
|
+
const external = scripts.filter((item) => {
|
|
61
|
+
try {
|
|
62
|
+
const url = new URL(item.src, page);
|
|
63
|
+
return url.origin !== page.origin && /^https?:/.test(url.protocol);
|
|
64
|
+
} catch {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
const unsigned = external.filter((item) => !attr(item.tag, 'integrity'));
|
|
69
|
+
if (unsigned.length) add('sri-missing', { count: unsigned.length, hosts: [...new Set(unsigned.map((item) => new URL(item.src, page).host))] }, unsigned.slice(0, 6).map((item) => `<script src="${item.src}">`));
|
|
70
|
+
|
|
71
|
+
const outdated = [];
|
|
72
|
+
for (const { src } of [...scripts, ...styles]) {
|
|
73
|
+
for (const lib of LIBRARIES) {
|
|
74
|
+
const match = lib.re.exec(src);
|
|
75
|
+
if (match && lib.vulnerable(match[1]) && !outdated.some((item) => item.name === lib.name)) {
|
|
76
|
+
outdated.push({ name: lib.name, version: match[1], advisory: lib.advisory, fixed: lib.fixed, src });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
for (const lib of outdated) {
|
|
81
|
+
add('outdated-library', { name: lib.name, version: lib.version, advisory: lib.advisory, fixed: lib.fixed }, [lib.src]);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function disclosureChecks(ctx) {
|
|
86
|
+
const { add, main } = ctx;
|
|
87
|
+
if (!main?.headers) return;
|
|
88
|
+
const h = main.headers;
|
|
89
|
+
const leaks = [];
|
|
90
|
+
if (h.server && /\d/.test(h.server)) leaks.push(`Server: ${h.server}`);
|
|
91
|
+
for (const name of ['x-powered-by', 'x-aspnet-version', 'x-aspnetmvc-version', 'x-generator', 'x-drupal-cache', 'x-runtime']) {
|
|
92
|
+
if (h[name] && (name !== 'x-runtime' || !/^\d/.test(h[name]))) leaks.push(`${name.replace(/(^|-)([a-z])/g, (m) => m.toUpperCase())}: ${h[name]}`);
|
|
93
|
+
}
|
|
94
|
+
const generator = /<meta\b[^>]*name\s*=\s*["']generator["'][^>]*>/i.exec(ctx.html || '');
|
|
95
|
+
if (generator) {
|
|
96
|
+
const content = /content\s*=\s*["']([^"']*)/i.exec(generator[0]);
|
|
97
|
+
if (content && /\d/.test(content[1])) leaks.push(`<meta name="generator" content="${content[1]}">`);
|
|
98
|
+
}
|
|
99
|
+
if (leaks.length) add('version-disclosure', { items: leaks }, leaks);
|
|
100
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
2
|
+
|
|
3
|
+
const isHtml = (res) => /text\/html/i.test(String(res.headers?.['content-type'] || '')) || /^\s*<(!doctype|html|head|body)/i.test(res.text.slice(0, 200));
|
|
4
|
+
|
|
5
|
+
const envKeys = (text) => {
|
|
6
|
+
const keys = [];
|
|
7
|
+
for (const line of text.split(/\r?\n/)) {
|
|
8
|
+
const match = /^(?:export\s+)?([A-Z][A-Z0-9_]{1,63})\s*=/.exec(line);
|
|
9
|
+
if (match) keys.push(match[1]);
|
|
10
|
+
}
|
|
11
|
+
return keys;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const PROBES = [
|
|
15
|
+
{ path: '/.git/HEAD', rule: 'exposed-git', test: (res) => !isHtml(res) && /^(ref: refs\/|[0-9a-f]{40}\s*$)/.test(res.text) },
|
|
16
|
+
{ path: '/.git/config', rule: 'exposed-git', test: (res) => !isHtml(res) && /^\s*\[core\]/m.test(res.text) },
|
|
17
|
+
{ path: '/.env', rule: 'exposed-env', test: (res) => !isHtml(res) && envKeys(res.text).length >= 2, evidence: (res) => envKeys(res.text).slice(0, 6).map((key) => `${key}=••••••`) },
|
|
18
|
+
{ path: '/.env.local', rule: 'exposed-env', test: (res) => !isHtml(res) && envKeys(res.text).length >= 2, evidence: (res) => envKeys(res.text).slice(0, 6).map((key) => `${key}=••••••`) },
|
|
19
|
+
{ path: '/.env.production', rule: 'exposed-env', test: (res) => !isHtml(res) && envKeys(res.text).length >= 2, evidence: (res) => envKeys(res.text).slice(0, 6).map((key) => `${key}=••••••`) },
|
|
20
|
+
{ path: '/.htpasswd', rule: 'exposed-htpasswd', test: (res) => !isHtml(res) && /^[^:\s<]{1,64}:(\$apr1\$|\$2[aby]\$|\{SHA\}|[./0-9A-Za-z]{13})/m.test(res.text), evidence: (res) => [`${res.text.split(':')[0]}:••••••`] },
|
|
21
|
+
{ path: '/backup.sql', rule: 'exposed-backup', test: (res) => !isHtml(res) && /(CREATE TABLE|INSERT INTO|-- MySQL dump|PostgreSQL database dump)/i.test(res.text) },
|
|
22
|
+
{ path: '/dump.sql', rule: 'exposed-backup', test: (res) => !isHtml(res) && /(CREATE TABLE|INSERT INTO|-- MySQL dump|PostgreSQL database dump)/i.test(res.text) },
|
|
23
|
+
{ path: '/database.sql', rule: 'exposed-backup', test: (res) => !isHtml(res) && /(CREATE TABLE|INSERT INTO|-- MySQL dump|PostgreSQL database dump)/i.test(res.text) },
|
|
24
|
+
{ path: '/backup.zip', rule: 'exposed-backup', test: (res) => res.body.subarray(0, 4).equals(Buffer.from([0x50, 0x4b, 0x03, 0x04])) },
|
|
25
|
+
{ path: '/site.zip', rule: 'exposed-backup', test: (res) => res.body.subarray(0, 4).equals(Buffer.from([0x50, 0x4b, 0x03, 0x04])) },
|
|
26
|
+
{ path: '/wp-config.php.bak', rule: 'exposed-backup', test: (res) => /DB_PASSWORD|DB_USER/.test(res.text) },
|
|
27
|
+
{ path: '/wp-config.php~', rule: 'exposed-backup', test: (res) => /DB_PASSWORD|DB_USER/.test(res.text) },
|
|
28
|
+
{ path: '/config.php.bak', rule: 'exposed-backup', test: (res) => /<\?php/.test(res.text) && /pass|pwd|secret|key/i.test(res.text) },
|
|
29
|
+
{ path: '/.vscode/sftp.json', rule: 'exposed-config', test: (res) => !isHtml(res) && /"host"\s*:/.test(res.text) && /"(password|privateKeyPath|username)"\s*:/.test(res.text) },
|
|
30
|
+
{ path: '/.npmrc', rule: 'exposed-config', test: (res) => !isHtml(res) && /_authToken\s*=|_auth\s*=/.test(res.text) },
|
|
31
|
+
{ path: '/docker-compose.yml', rule: 'exposed-config', test: (res) => !isHtml(res) && /^services\s*:/m.test(res.text) && /(PASSWORD|SECRET|TOKEN)\w*\s*[:=]/i.test(res.text) },
|
|
32
|
+
{ path: '/phpinfo.php', rule: 'exposed-phpinfo', test: (res) => /<title>phpinfo\(\)<\/title>|>PHP Version [0-9]/i.test(res.text) },
|
|
33
|
+
{ path: '/info.php', rule: 'exposed-phpinfo', test: (res) => /<title>phpinfo\(\)<\/title>|>PHP Version [0-9]/i.test(res.text) },
|
|
34
|
+
{ path: '/server-status', rule: 'exposed-server-status', test: (res) => /Apache Server Status for/i.test(res.text) },
|
|
35
|
+
{ path: '/.DS_Store', rule: 'exposed-ds-store', test: (res) => res.body.subarray(0, 8).equals(Buffer.from([0, 0, 0, 1, 0x42, 0x75, 0x64, 0x31])) },
|
|
36
|
+
{ path: '/uploads/', rule: 'directory-listing', test: (res) => isListing(res.text) },
|
|
37
|
+
{ path: '/backup/', rule: 'directory-listing', test: (res) => isListing(res.text) },
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
export const isListing = (text) => /<title>\s*Index of \//i.test(text) || /<h1>\s*Index of \//i.test(text) || /<title>Directory listing for \//i.test(text);
|
|
41
|
+
|
|
42
|
+
export async function exposureChecks(ctx, { probe = true, concurrency = 4 } = {}) {
|
|
43
|
+
const { add, main, client, origin } = ctx;
|
|
44
|
+
|
|
45
|
+
if (main?.text && isListing(main.text)) add('directory-listing', { path: new URL(main.url).pathname }, [`GET ${main.url} → Index of /`]);
|
|
46
|
+
|
|
47
|
+
if (!probe) return;
|
|
48
|
+
|
|
49
|
+
const baseline = await client.request(`${origin}/vigie-${randomBytes(6).toString('hex')}-not-found`, { limit: 64 * 1024 });
|
|
50
|
+
const sameAsBaseline = (res) => baseline.status === 200 && res.status === 200 && baseline.text === res.text;
|
|
51
|
+
|
|
52
|
+
const found = new Map();
|
|
53
|
+
const queue = [...PROBES];
|
|
54
|
+
const worker = async () => {
|
|
55
|
+
while (queue.length) {
|
|
56
|
+
const probeSpec = queue.shift();
|
|
57
|
+
const res = await client.request(`${origin}${probeSpec.path}`, { limit: 64 * 1024 });
|
|
58
|
+
if (res.error || res.status !== 200 || !res.body?.length || sameAsBaseline(res)) continue;
|
|
59
|
+
let hit = false;
|
|
60
|
+
try {
|
|
61
|
+
hit = probeSpec.test(res);
|
|
62
|
+
} catch {}
|
|
63
|
+
if (!hit) continue;
|
|
64
|
+
const paths = found.get(probeSpec.rule) ?? [];
|
|
65
|
+
paths.push({ path: probeSpec.path, evidence: probeSpec.evidence ? probeSpec.evidence(res) : [] , size: res.body.length });
|
|
66
|
+
found.set(probeSpec.rule, paths);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
await Promise.all(Array.from({ length: concurrency }, worker));
|
|
70
|
+
|
|
71
|
+
const order = PROBES.map((spec) => spec.rule).filter((rule, index, all) => all.indexOf(rule) === index);
|
|
72
|
+
for (const rule of order) {
|
|
73
|
+
const hits = found.get(rule);
|
|
74
|
+
if (!hits) continue;
|
|
75
|
+
hits.sort((a, b) => PROBES.findIndex((spec) => spec.path === a.path) - PROBES.findIndex((spec) => spec.path === b.path));
|
|
76
|
+
add(rule, { paths: hits.map((hit) => hit.path) }, hits.flatMap((hit) => [`GET ${origin}${hit.path} → 200 (${hit.size} B)`, ...hit.evidence.map((line) => ` ${line}`)]));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const securityTxt = await client.request(`${origin}/.well-known/security.txt`, { limit: 16 * 1024 });
|
|
80
|
+
if (securityTxt.error || securityTxt.status !== 200 || !/^contact\s*:/im.test(securityTxt.text) || isHtml(securityTxt)) {
|
|
81
|
+
add('security-txt-missing', {}, [`GET ${origin}/.well-known/security.txt → ${securityTxt.status ?? securityTxt.error}`]);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
const EVIL_ORIGIN = 'https://vigie-origin-check.invalid';
|
|
2
|
+
|
|
3
|
+
export function parseCsp(value) {
|
|
4
|
+
const directives = {};
|
|
5
|
+
for (const part of String(value).split(';')) {
|
|
6
|
+
const tokens = part.trim().split(/\s+/).filter(Boolean);
|
|
7
|
+
if (!tokens.length) continue;
|
|
8
|
+
const name = tokens[0].toLowerCase();
|
|
9
|
+
if (!(name in directives)) directives[name] = tokens.slice(1);
|
|
10
|
+
}
|
|
11
|
+
return directives;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function cspWeaknesses(value) {
|
|
15
|
+
const directives = parseCsp(value);
|
|
16
|
+
const script = directives['script-src'] ?? directives['default-src'];
|
|
17
|
+
if (!script) return ['no-script-src'];
|
|
18
|
+
const lower = script.map((source) => source.toLowerCase());
|
|
19
|
+
const nonceOrHash = lower.some((source) => source.startsWith("'nonce-") || /^'sha(256|384|512)-/.test(source));
|
|
20
|
+
const strictDynamic = lower.includes("'strict-dynamic'");
|
|
21
|
+
const reasons = [];
|
|
22
|
+
if (lower.includes("'unsafe-inline'") && !nonceOrHash) reasons.push('unsafe-inline');
|
|
23
|
+
if (lower.includes("'unsafe-eval'")) reasons.push('unsafe-eval');
|
|
24
|
+
if (!(strictDynamic && nonceOrHash) && lower.some((source) => ['*', 'http:', 'https:', 'data:'].includes(source))) reasons.push('wildcard');
|
|
25
|
+
return reasons;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function metaContent(html, attribute, name) {
|
|
29
|
+
const re = new RegExp(`<meta\\b[^>]*${attribute}\\s*=\\s*["']?${name}["']?[^>]*>`, 'i');
|
|
30
|
+
const tag = re.exec(html);
|
|
31
|
+
if (!tag) return null;
|
|
32
|
+
const content = /content\s*=\s*"([^"]*)"|content\s*=\s*'([^']*)'/i.exec(tag[0]);
|
|
33
|
+
return content ? content[1] ?? content[2] : null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export async function headerChecks(ctx) {
|
|
37
|
+
const { add, main, client } = ctx;
|
|
38
|
+
if (!main || !main.headers) return;
|
|
39
|
+
const h = main.headers;
|
|
40
|
+
const html = ctx.html;
|
|
41
|
+
|
|
42
|
+
const cspHeader = [].concat(h['content-security-policy'] || []).join('; ');
|
|
43
|
+
const cspMeta = metaContent(html, 'http-equiv', 'Content-Security-Policy');
|
|
44
|
+
const csp = cspHeader || cspMeta;
|
|
45
|
+
if (!csp) {
|
|
46
|
+
const reportOnly = h['content-security-policy-report-only'];
|
|
47
|
+
add('csp-missing', { reportOnly: Boolean(reportOnly) }, [reportOnly ? `Content-Security-Policy-Report-Only: ${String(reportOnly).slice(0, 160)}` : 'Content-Security-Policy: —']);
|
|
48
|
+
} else {
|
|
49
|
+
const reasons = cspWeaknesses(csp);
|
|
50
|
+
if (reasons.length) add('csp-unsafe', { reasons }, [`Content-Security-Policy: ${csp.slice(0, 200)}`]);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const xfo = String(h['x-frame-options'] || '').toUpperCase();
|
|
54
|
+
const frameAncestors = cspHeader ? parseCsp(cspHeader)['frame-ancestors'] : null;
|
|
55
|
+
if (!['DENY', 'SAMEORIGIN'].includes(xfo.trim()) && !frameAncestors) {
|
|
56
|
+
add('clickjacking', {}, [`X-Frame-Options: ${h['x-frame-options'] ?? '—'}`, `frame-ancestors: ${frameAncestors ? frameAncestors.join(' ') : '—'}`]);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (String(h['x-content-type-options'] || '').toLowerCase().trim() !== 'nosniff') {
|
|
60
|
+
add('nosniff-missing', {}, [`X-Content-Type-Options: ${h['x-content-type-options'] ?? '—'}`]);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const referrer = h['referrer-policy'] ?? metaContent(html, 'name', 'referrer');
|
|
64
|
+
const lastPolicy = referrer ? String(referrer).split(',').map((value) => value.trim().toLowerCase()).filter(Boolean).pop() : null;
|
|
65
|
+
if (!lastPolicy) add('referrer-policy', { value: null }, ['Referrer-Policy: —']);
|
|
66
|
+
else if (['unsafe-url', 'no-referrer-when-downgrade'].includes(lastPolicy)) add('referrer-policy', { value: lastPolicy }, [`Referrer-Policy: ${referrer}`]);
|
|
67
|
+
|
|
68
|
+
if (!h['permissions-policy']) add('permissions-policy-missing', {}, ['Permissions-Policy: —']);
|
|
69
|
+
|
|
70
|
+
const acao = h['access-control-allow-origin'];
|
|
71
|
+
const acac = String(h['access-control-allow-credentials'] || '').toLowerCase() === 'true';
|
|
72
|
+
if (acao === '*' && acac) {
|
|
73
|
+
add('cors-wildcard-credentials', {}, [`Access-Control-Allow-Origin: *`, 'Access-Control-Allow-Credentials: true']);
|
|
74
|
+
}
|
|
75
|
+
const probe = await client.request(main.url, { headers: { origin: EVIL_ORIGIN }, limit: 1024 });
|
|
76
|
+
if (!probe.error && probe.headers) {
|
|
77
|
+
const reflected = probe.headers['access-control-allow-origin'] === EVIL_ORIGIN;
|
|
78
|
+
const credentials = String(probe.headers['access-control-allow-credentials'] || '').toLowerCase() === 'true';
|
|
79
|
+
if (reflected && credentials) {
|
|
80
|
+
add('cors-reflected-origin', { origin: EVIL_ORIGIN }, [`Origin: ${EVIL_ORIGIN}`, `Access-Control-Allow-Origin: ${EVIL_ORIGIN}`, 'Access-Control-Allow-Credentials: true']);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const SESSION = /sess|^sid$|_sid$|token|auth|jwt|login|remember|connect\.sid|phpsessid|jsessionid|aspxauth|laravel|identity|refresh/i;
|
|
86
|
+
const READABLE = /xsrf|csrf/i;
|
|
87
|
+
|
|
88
|
+
export function parseCookie(raw) {
|
|
89
|
+
const [pair, ...attributes] = String(raw).split(';');
|
|
90
|
+
const name = pair.split('=')[0].trim();
|
|
91
|
+
const flags = {};
|
|
92
|
+
for (const attribute of attributes) {
|
|
93
|
+
const [key, ...rest] = attribute.split('=');
|
|
94
|
+
flags[key.trim().toLowerCase()] = rest.join('=').trim() || true;
|
|
95
|
+
}
|
|
96
|
+
return { name, secure: 'secure' in flags, httpOnly: 'httponly' in flags, sameSite: typeof flags.samesite === 'string' ? flags.samesite.toLowerCase() : null };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function cookieChecks(ctx) {
|
|
100
|
+
const { add } = ctx;
|
|
101
|
+
const seen = new Map();
|
|
102
|
+
for (const hop of ctx.https) {
|
|
103
|
+
for (const raw of hop.setCookies || []) {
|
|
104
|
+
const cookie = parseCookie(raw);
|
|
105
|
+
if (cookie.name && !seen.has(cookie.name)) seen.set(cookie.name, { ...cookie, secureSite: hop.url.startsWith('https:') });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const cookies = [...seen.values()];
|
|
109
|
+
const insecure = cookies.filter((cookie) => cookie.secureSite && !cookie.secure);
|
|
110
|
+
if (insecure.length) {
|
|
111
|
+
const session = insecure.some((cookie) => SESSION.test(cookie.name));
|
|
112
|
+
add('cookie-not-secure', { names: insecure.map((cookie) => cookie.name) }, insecure.map((cookie) => `Set-Cookie: ${cookie.name}=…`), session ? 'high' : undefined);
|
|
113
|
+
}
|
|
114
|
+
const scriptable = cookies.filter((cookie) => SESSION.test(cookie.name) && !READABLE.test(cookie.name) && !cookie.httpOnly);
|
|
115
|
+
if (scriptable.length) add('cookie-no-httponly', { names: scriptable.map((cookie) => cookie.name) }, scriptable.map((cookie) => `Set-Cookie: ${cookie.name}=…`));
|
|
116
|
+
const loose = cookies.filter((cookie) => !cookie.sameSite);
|
|
117
|
+
if (loose.length) add('cookie-no-samesite', { names: loose.map((cookie) => cookie.name) }, loose.map((cookie) => `Set-Cookie: ${cookie.name}=…`));
|
|
118
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { isIP } from 'node:net';
|
|
2
|
+
import tls from 'node:tls';
|
|
3
|
+
|
|
4
|
+
const DAY = 24 * 60 * 60 * 1000;
|
|
5
|
+
const HSTS_MIN = 15552000;
|
|
6
|
+
|
|
7
|
+
export function legacyTlsAccepted(host, port, servername, timeout) {
|
|
8
|
+
return new Promise((resolve) => {
|
|
9
|
+
const socket = tls.connect({
|
|
10
|
+
host,
|
|
11
|
+
port,
|
|
12
|
+
servername,
|
|
13
|
+
rejectUnauthorized: false,
|
|
14
|
+
minVersion: 'TLSv1',
|
|
15
|
+
maxVersion: 'TLSv1.1',
|
|
16
|
+
ciphers: 'DEFAULT:@SECLEVEL=0',
|
|
17
|
+
timeout,
|
|
18
|
+
});
|
|
19
|
+
const end = (value) => {
|
|
20
|
+
socket.destroy();
|
|
21
|
+
resolve(value);
|
|
22
|
+
};
|
|
23
|
+
socket.once('secureConnect', () => end(socket.getProtocol()));
|
|
24
|
+
socket.once('error', () => end(null));
|
|
25
|
+
socket.once('timeout', () => end(null));
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export async function transportChecks(ctx) {
|
|
30
|
+
const { add, https: secureChain, http: plainChain, target, client } = ctx;
|
|
31
|
+
const first = secureChain[0];
|
|
32
|
+
|
|
33
|
+
if (!first || first.error) {
|
|
34
|
+
add('no-https', { host: target.host, error: first?.error ?? 'ERROR' }, [`GET https://${target.host}/ → ${first?.error ?? 'ERROR'}`]);
|
|
35
|
+
} else {
|
|
36
|
+
const info = first.tls;
|
|
37
|
+
if (info && !info.authorized) {
|
|
38
|
+
add('tls-invalid-cert', { reason: info.error || 'UNKNOWN' }, [
|
|
39
|
+
`${info.error || 'UNKNOWN'}`,
|
|
40
|
+
`subject: ${info.subject ?? '?'} · issuer: ${info.issuer ?? '?'}`,
|
|
41
|
+
info.validTo ? `valid until: ${info.validTo.slice(0, 10)}` : null,
|
|
42
|
+
].filter(Boolean));
|
|
43
|
+
}
|
|
44
|
+
if (info?.validTo) {
|
|
45
|
+
const days = Math.floor((new Date(info.validTo).getTime() - Date.now()) / DAY);
|
|
46
|
+
if (days >= 0 && days <= 30) {
|
|
47
|
+
add('tls-expiring', { days, date: info.validTo.slice(0, 10) }, [`notAfter: ${info.validTo}`], days <= 14 ? 'medium' : 'low');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const legacy = await legacyTlsAccepted(target.hostname.replace(/^\[|\]$/g, ''), Number(target.port) || 443, isIP(target.hostname) ? undefined : target.hostname, client.timeout);
|
|
51
|
+
if (legacy) add('tls-old-protocol', { protocol: legacy }, [`${legacy} handshake accepted`]);
|
|
52
|
+
|
|
53
|
+
for (let i = 1; i < secureChain.length; i++) {
|
|
54
|
+
if (secureChain[i].url.startsWith('http:')) {
|
|
55
|
+
add('insecure-redirect', { from: secureChain[i - 1].url, to: secureChain[i].url }, secureChain.slice(0, i + 1).map((hop) => `${hop.status ?? hop.error} ${hop.url}`));
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const page = ctx.main;
|
|
61
|
+
if (page && page.url.startsWith('https:') && page.headers) {
|
|
62
|
+
const raw = page.headers['strict-transport-security'];
|
|
63
|
+
if (!raw) add('hsts-missing', {}, ['Strict-Transport-Security: —']);
|
|
64
|
+
else {
|
|
65
|
+
const maxAge = Number((/max-age\s*=\s*"?(\d+)/i.exec(raw) || [])[1] ?? 0);
|
|
66
|
+
if (maxAge < HSTS_MIN) add('hsts-weak', { maxAge, days: Math.floor(maxAge / 86400) }, [`Strict-Transport-Security: ${raw}`]);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const plainFirst = plainChain[0];
|
|
72
|
+
if (plainFirst && !plainFirst.error) {
|
|
73
|
+
const last = plainChain[plainChain.length - 1];
|
|
74
|
+
const upgraded = plainChain.some((hop) => hop.url.startsWith('https:'));
|
|
75
|
+
if (!upgraded && last.status && last.status < 400) {
|
|
76
|
+
add('http-no-redirect', { status: last.status }, plainChain.map((hop) => `${hop.status ?? hop.error} ${hop.url}`));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
package/src/cli.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { parseArgs } from './args.js';
|
|
4
|
+
import { FxError } from './errors.js';
|
|
5
|
+
import { toHtml } from './html.js';
|
|
6
|
+
import { detectLang, dict, normalizeLang } from './i18n/index.js';
|
|
7
|
+
import { normalizeTarget } from './net.js';
|
|
8
|
+
import { printBanner, printResults, toJson } from './report.js';
|
|
9
|
+
import { pkg, scanAll } from './scan.js';
|
|
10
|
+
import { c } from './ui.js';
|
|
11
|
+
|
|
12
|
+
const GRADES = ['A+', 'A', 'B', 'C', 'D', 'F'];
|
|
13
|
+
|
|
14
|
+
export async function run(argv) {
|
|
15
|
+
const { positional, flags } = parseArgs(argv);
|
|
16
|
+
let lang = detectLang();
|
|
17
|
+
if (flags.lang !== undefined) {
|
|
18
|
+
const code = normalizeLang(flags.lang === true ? '' : flags.lang);
|
|
19
|
+
if (!code) throw new FxError(dict(lang).errors.invalidLang(flags.lang), 'en, fr');
|
|
20
|
+
lang = code;
|
|
21
|
+
}
|
|
22
|
+
const d = dict(lang);
|
|
23
|
+
const e = d.errors;
|
|
24
|
+
|
|
25
|
+
if (flags.version || flags.v) {
|
|
26
|
+
console.log(pkg.version);
|
|
27
|
+
return 0;
|
|
28
|
+
}
|
|
29
|
+
const wantsHelp = flags.help || flags.h || positional[0] === 'help';
|
|
30
|
+
const optionsOnly = Object.keys(flags).some((key) => !['lang', 'no-banner', 'no-color'].includes(key));
|
|
31
|
+
if (!wantsHelp && positional.length === 0 && optionsOnly) throw new FxError(e.noTarget, e.noTargetHint);
|
|
32
|
+
if (wantsHelp || positional.length === 0) {
|
|
33
|
+
if (!flags['no-banner']) printBanner(lang);
|
|
34
|
+
console.log(d.help(c));
|
|
35
|
+
return 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
for (const value of positional) {
|
|
39
|
+
try {
|
|
40
|
+
normalizeTarget(value);
|
|
41
|
+
} catch {
|
|
42
|
+
throw new FxError(e.invalidUrl(value));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
let failUnder = null;
|
|
47
|
+
if (flags['fail-under'] !== undefined) {
|
|
48
|
+
const grade = String(flags['fail-under']).toUpperCase();
|
|
49
|
+
if (!GRADES.slice(0, 5).includes(grade)) throw new FxError(e.invalidGrade(flags['fail-under']), e.gradeHint);
|
|
50
|
+
failUnder = grade;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let timeout = 10000;
|
|
54
|
+
if (flags.timeout !== undefined) {
|
|
55
|
+
const seconds = Number(flags.timeout);
|
|
56
|
+
if (!Number.isFinite(seconds) || seconds <= 0 || seconds > 120) throw new FxError(e.invalidTimeout(flags.timeout));
|
|
57
|
+
timeout = Math.round(seconds * 1000);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (flags.html === true) throw new FxError(e.needsFile('html'));
|
|
61
|
+
const htmlPath = typeof flags.html === 'string' ? resolve(flags.html) : null;
|
|
62
|
+
|
|
63
|
+
const ca = process.env.VIGIE_EXTRA_CA ? readFileSync(process.env.VIGIE_EXTRA_CA, 'utf8') : undefined;
|
|
64
|
+
const httpPort = process.env.VIGIE_HTTP_PORT ? Number(process.env.VIGIE_HTTP_PORT) : undefined;
|
|
65
|
+
const probe = !flags['no-probe'];
|
|
66
|
+
|
|
67
|
+
const results = await scanAll(positional, { timeout, probe, ca, httpPort });
|
|
68
|
+
|
|
69
|
+
if (htmlPath) writeFileSync(htmlPath, toHtml(results, lang));
|
|
70
|
+
|
|
71
|
+
if (flags.json) console.log(toJson(results, lang));
|
|
72
|
+
else {
|
|
73
|
+
printResults(results, { lang, quiet: flags.quiet || flags.q, banner: !flags['no-banner'], probe });
|
|
74
|
+
if (htmlPath) console.log(` ${c.green('✔')} ${d.ui.written.html} → ${htmlPath}\n`);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (failUnder) {
|
|
78
|
+
const limit = GRADES.indexOf(failUnder);
|
|
79
|
+
return results.some((result) => GRADES.indexOf(result.grade) > limit) ? 1 : 0;
|
|
80
|
+
}
|
|
81
|
+
return 0;
|
|
82
|
+
}
|