@hardkeel/benthic 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 +121 -0
- package/LICENSE +92 -0
- package/NOTICE +16 -0
- package/README.md +424 -2
- package/action.yml +54 -0
- package/dist/agility.js +80 -0
- package/dist/badge.js +62 -0
- package/dist/baseline.js +81 -0
- package/dist/cbom-diff.js +273 -0
- package/dist/cbom.js +418 -0
- package/dist/cli.js +834 -0
- package/dist/cloud-aws-services.js +375 -0
- package/dist/cloud-aws.js +354 -0
- package/dist/cloud-azure-services.js +73 -0
- package/dist/cloud-azure.js +144 -0
- package/dist/cloud-common.js +242 -0
- package/dist/cloud-gcp-services.js +90 -0
- package/dist/cloud-gcp.js +150 -0
- package/dist/comments.js +138 -0
- package/dist/community-rules.js +37 -0
- package/dist/community.js +30 -0
- package/dist/deps.js +406 -0
- package/dist/der.js +571 -0
- package/dist/evidence-cli.js +235 -0
- package/dist/evidence-live.js +109 -0
- package/dist/evidence.js +512 -0
- package/dist/ignore.js +90 -0
- package/dist/image.js +1224 -0
- package/dist/infra.js +635 -0
- package/dist/inventory.js +277 -0
- package/dist/map-activity.js +24 -0
- package/dist/map-areas.js +60 -0
- package/dist/map-cloud-keys.js +110 -0
- package/dist/map-cloud.js +34 -0
- package/dist/map-ct.js +107 -0
- package/dist/map-host.js +335 -0
- package/dist/map-network.js +520 -0
- package/dist/map-people.js +79 -0
- package/dist/map-rank.js +70 -0
- package/dist/map-report.js +304 -0
- package/dist/map-run.js +327 -0
- package/dist/map-sarif.js +61 -0
- package/dist/map-signin.js +247 -0
- package/dist/map-types.js +19 -0
- package/dist/map-web.js +666 -0
- package/dist/native.js +168 -0
- package/dist/policy.js +221 -0
- package/dist/pqc.js +46 -0
- package/dist/profile.js +65 -0
- package/dist/project.js +928 -0
- package/dist/prose.js +159 -0
- package/dist/protocols.js +207 -0
- package/dist/registry.js +326 -0
- package/dist/report.js +190 -0
- package/dist/rules.js +230 -0
- package/dist/sarif-common.js +30 -0
- package/dist/sarif.js +114 -0
- package/dist/scan.js +601 -0
- package/dist/score.js +124 -0
- package/dist/secrets.js +192 -0
- package/dist/share-config.js +129 -0
- package/dist/share-lists.js +19 -0
- package/dist/share.js +125 -0
- package/dist/sonar.js +83 -0
- package/dist/structure.js +218 -0
- package/dist/suites.js +402 -0
- package/dist/tls-check.js +122 -0
- package/dist/types.js +4 -0
- package/dist/walk.js +78 -0
- package/dist/yaml.js +173 -0
- package/package.json +73 -4
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
// SPDX-License-Identifier: PolyForm-Shield-1.0.0
|
|
2
|
+
// Copyright 2026 Hard Keel (https://hardkeel.com)
|
|
3
|
+
// benthic evidence: the folder scan, live TLS and SSH checks of the hosts the scope names, and a
|
|
4
|
+
// saved cloud check, written as one cryptographic inventory for a compliance review. Sends nothing to
|
|
5
|
+
// Hard Keel.
|
|
6
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
7
|
+
import { join, relative, resolve } from "node:path";
|
|
8
|
+
import { walkFolder } from "./walk.js";
|
|
9
|
+
import { scanFiles } from "./scan.js";
|
|
10
|
+
import { liveSsh, liveTarget, liveTls } from "./evidence-live.js";
|
|
11
|
+
import { buildEvidence, evidenceCsv, evidenceMarkdown, gitState, manifest, parseScope, RULES_UPDATED, rulesDigest, ScopeError, sha256 } from "./evidence.js";
|
|
12
|
+
import { MAX_TLS_TARGETS } from "./tls-check.js";
|
|
13
|
+
export const EVIDENCE_HELP = `Usage: benthic evidence [folder] [options]
|
|
14
|
+
|
|
15
|
+
Writes a cryptographic inventory for a compliance review (PCI DSS 12.3.3 and the like):
|
|
16
|
+
every protocol, cipher suite and algorithm in use, strong ones included, with purpose,
|
|
17
|
+
system, viability and its source, a review record, a plan for when an algorithm breaks
|
|
18
|
+
and the hashes to prove the files weren't changed. No grade. Sends nothing to Hard Keel.
|
|
19
|
+
|
|
20
|
+
Options:
|
|
21
|
+
--scope <file> Which folders, hosts and cloud targets belong to which system, and
|
|
22
|
+
whether each handles cardholder data (JSON or YAML). Never read from
|
|
23
|
+
the scanned folder by itself. Without it, everything counts as in scope
|
|
24
|
+
--cloud <file> A saved "benthic cloud --format json" result to include
|
|
25
|
+
--baseline <file> crypto-inventory.json from the last review, to list what changed
|
|
26
|
+
--out <folder> Where to write the pack (default: crypto-inventory)
|
|
27
|
+
--name <name> Title for the pack (default: the scope's name or the folder)
|
|
28
|
+
--no-live Skip the live TLS and SSH checks of the scope's hosts
|
|
29
|
+
--fail-on weak Exit with 1 when anything in scope is rated weak (default: none)
|
|
30
|
+
|
|
31
|
+
Scope file example (YAML):
|
|
32
|
+
name: Payments
|
|
33
|
+
systems:
|
|
34
|
+
- name: Checkout API
|
|
35
|
+
cardholderData: true
|
|
36
|
+
paths: [services/checkout/, infra/checkout/**]
|
|
37
|
+
hosts: [pay.example.com, ssh://bastion.example.com]
|
|
38
|
+
cloud: ["123456789012"]
|
|
39
|
+
- name: Marketing site
|
|
40
|
+
cardholderData: false
|
|
41
|
+
paths: [web/]
|
|
42
|
+
`;
|
|
43
|
+
const FLAGS = new Set(["help", "no-live", "offline", "quiet"]);
|
|
44
|
+
const VALUES = new Set(["scope", "cloud", "baseline", "out", "name", "fail-on"]);
|
|
45
|
+
export async function evidenceCommand(argv, version, deps = {}) {
|
|
46
|
+
const opts = {};
|
|
47
|
+
const rest = [];
|
|
48
|
+
for (let i = 0; i < argv.length; i++) {
|
|
49
|
+
const a = argv[i];
|
|
50
|
+
if (!a.startsWith("--")) {
|
|
51
|
+
rest.push(a);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const eq = a.indexOf("=");
|
|
55
|
+
const k = eq < 0 ? a.slice(2) : a.slice(2, eq);
|
|
56
|
+
if (FLAGS.has(k))
|
|
57
|
+
opts[k] = true;
|
|
58
|
+
else if (!VALUES.has(k)) {
|
|
59
|
+
console.error(`Unknown option --${k}. Run benthic evidence --help for the list.`);
|
|
60
|
+
return 2;
|
|
61
|
+
}
|
|
62
|
+
else if (eq >= 0)
|
|
63
|
+
opts[k] = a.slice(eq + 1);
|
|
64
|
+
else if (i + 1 < argv.length && !argv[i + 1].startsWith("--"))
|
|
65
|
+
opts[k] = argv[++i];
|
|
66
|
+
else {
|
|
67
|
+
console.error(`--${k} needs a value.`);
|
|
68
|
+
return 2;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (opts.help) {
|
|
72
|
+
process.stdout.write(EVIDENCE_HELP);
|
|
73
|
+
return 0;
|
|
74
|
+
}
|
|
75
|
+
if (rest.length > 1) {
|
|
76
|
+
console.error("Give one folder to scan.");
|
|
77
|
+
return 2;
|
|
78
|
+
}
|
|
79
|
+
const str = (k) => (typeof opts[k] === "string" ? opts[k] : undefined);
|
|
80
|
+
const failOn = str("fail-on") ?? "none";
|
|
81
|
+
if (failOn !== "weak" && failOn !== "none") {
|
|
82
|
+
console.error(`Unknown --fail-on "${failOn}". Use weak or none.`);
|
|
83
|
+
return 2;
|
|
84
|
+
}
|
|
85
|
+
const dir = rest[0] ?? ".";
|
|
86
|
+
if (!existsSync(dir)) {
|
|
87
|
+
console.error(`Can't find the folder ${dir}.`);
|
|
88
|
+
return 2;
|
|
89
|
+
}
|
|
90
|
+
const read = (file, what) => {
|
|
91
|
+
try {
|
|
92
|
+
return readFileSync(file, "utf8");
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
console.error(`Can't read the ${what} ${file}.`);
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
let scope = null;
|
|
100
|
+
let scopeText;
|
|
101
|
+
const scopePath = str("scope");
|
|
102
|
+
if (scopePath) {
|
|
103
|
+
const t = read(scopePath, "scope file");
|
|
104
|
+
if (t === null)
|
|
105
|
+
return 2;
|
|
106
|
+
try {
|
|
107
|
+
scope = parseScope(t, scopePath);
|
|
108
|
+
}
|
|
109
|
+
catch (e) {
|
|
110
|
+
console.error(e instanceof Error ? e.message : String(e));
|
|
111
|
+
return 2;
|
|
112
|
+
}
|
|
113
|
+
scopeText = t;
|
|
114
|
+
const inside = relative(resolve(dir), resolve(scopePath));
|
|
115
|
+
if (!inside.startsWith("..") && !inside.startsWith("/") && !/^[a-zA-Z]:/.test(inside)) {
|
|
116
|
+
console.error("Note: the scope file is inside the folder being scanned, so a change to that folder can change what counts as in scope. Keep it elsewhere, or protect it with code review.");
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
else
|
|
120
|
+
console.error("No --scope file: everything scanned counts as in scope, and no hosts are checked live.");
|
|
121
|
+
let cloud;
|
|
122
|
+
let cloudText;
|
|
123
|
+
if (str("cloud")) {
|
|
124
|
+
const t = read(str("cloud"), "cloud result");
|
|
125
|
+
if (t === null)
|
|
126
|
+
return 2;
|
|
127
|
+
try {
|
|
128
|
+
cloud = JSON.parse(t);
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
console.error(`${str("cloud")} isn't JSON. Save it with benthic cloud --format json --output <file>.`);
|
|
132
|
+
return 2;
|
|
133
|
+
}
|
|
134
|
+
cloudText = t;
|
|
135
|
+
}
|
|
136
|
+
let previous;
|
|
137
|
+
let baselineText;
|
|
138
|
+
if (str("baseline")) {
|
|
139
|
+
const t = read(str("baseline"), "baseline");
|
|
140
|
+
if (t === null)
|
|
141
|
+
return 2;
|
|
142
|
+
try {
|
|
143
|
+
previous = JSON.parse(t);
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
console.error(`${str("baseline")} isn't JSON. Use the crypto-inventory.json from the last review.`);
|
|
147
|
+
return 2;
|
|
148
|
+
}
|
|
149
|
+
baselineText = t;
|
|
150
|
+
}
|
|
151
|
+
// The scope decides what's in, so nothing in the scanned folder can quietly hide a finding:
|
|
152
|
+
// .benthic-ignore and .benthic.yml are not read here.
|
|
153
|
+
let files;
|
|
154
|
+
try {
|
|
155
|
+
files = walkFolder(dir).files;
|
|
156
|
+
}
|
|
157
|
+
catch (e) {
|
|
158
|
+
console.error(e instanceof Error ? e.message : String(e));
|
|
159
|
+
return 2;
|
|
160
|
+
}
|
|
161
|
+
const scanned = scanFiles(files);
|
|
162
|
+
const live = { uses: [], certs: [], errors: [] };
|
|
163
|
+
const liveHosts = [];
|
|
164
|
+
let handshakes = 0;
|
|
165
|
+
if (scope && opts["no-live"] !== true) {
|
|
166
|
+
const targets = scope.systems.flatMap((s) => s.hosts.map((h) => liveTarget(h, s.name)));
|
|
167
|
+
for (const t of targets)
|
|
168
|
+
if ("error" in t)
|
|
169
|
+
live.errors.push({ target: "scope file", message: t.error });
|
|
170
|
+
const ok = targets.filter((t) => !("error" in t));
|
|
171
|
+
if (ok.length > MAX_TLS_TARGETS) {
|
|
172
|
+
console.error(`The scope names ${ok.length} hosts; the live check takes at most ${MAX_TLS_TARGETS} at a time. Split the scope or use --no-live.`);
|
|
173
|
+
return 2;
|
|
174
|
+
}
|
|
175
|
+
for (const t of ok) {
|
|
176
|
+
process.stderr.write(`Checking ${t.ssh ? "SSH" : "TLS"} on ${t.host}:${t.port}, read-only...\n`);
|
|
177
|
+
const r = t.ssh ? await liveSsh(t, deps) : await liveTls(t, deps);
|
|
178
|
+
live.uses.push(...r.uses);
|
|
179
|
+
live.certs.push(...r.certs);
|
|
180
|
+
live.errors.push(...r.errors);
|
|
181
|
+
handshakes += r.handshakes;
|
|
182
|
+
liveHosts.push(`${t.host}:${t.port}`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
const git = gitState(dir);
|
|
186
|
+
const quote = (s) => (/^[A-Za-z0-9_./:=@,+-]+$/.test(s) ? s : `'${s.replace(/'/g, "'\\''")}'`);
|
|
187
|
+
const title = str("name") ?? scope?.name ?? (resolve(dir).split(/[\\/]/).pop() || dir);
|
|
188
|
+
let pack;
|
|
189
|
+
try {
|
|
190
|
+
pack = buildEvidence({
|
|
191
|
+
scanned,
|
|
192
|
+
findings: scanned.findings,
|
|
193
|
+
scope,
|
|
194
|
+
live,
|
|
195
|
+
cloud,
|
|
196
|
+
previous,
|
|
197
|
+
title,
|
|
198
|
+
provenance: {
|
|
199
|
+
tool: "Hard Keel Benthic",
|
|
200
|
+
version,
|
|
201
|
+
rulesUpdated: RULES_UPDATED,
|
|
202
|
+
rulesDigest: rulesDigest(),
|
|
203
|
+
folder: resolve(dir).split(/[\\/]/).pop() || dir,
|
|
204
|
+
...git,
|
|
205
|
+
...(scopePath ? { scopeFile: scopePath, scopeSha256: sha256(scopeText) } : {}),
|
|
206
|
+
...(str("cloud") ? { cloudFile: str("cloud"), cloudSha256: sha256(cloudText) } : {}),
|
|
207
|
+
...(str("baseline") ? { baselineFile: str("baseline"), baselineSha256: sha256(baselineText) } : {}),
|
|
208
|
+
liveHosts,
|
|
209
|
+
handshakes,
|
|
210
|
+
createdAt: new Date().toISOString(),
|
|
211
|
+
command: ["benthic", "evidence", ...argv].map(quote).join(" "),
|
|
212
|
+
},
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
catch (e) {
|
|
216
|
+
console.error(e instanceof ScopeError ? e.message : e instanceof Error ? e.message : String(e));
|
|
217
|
+
return 2;
|
|
218
|
+
}
|
|
219
|
+
const out = str("out") ?? "crypto-inventory";
|
|
220
|
+
mkdirSync(out, { recursive: true });
|
|
221
|
+
const docs = [
|
|
222
|
+
{ name: "crypto-inventory.md", body: evidenceMarkdown(pack) + "\n" },
|
|
223
|
+
{ name: "crypto-inventory.csv", body: evidenceCsv(pack) },
|
|
224
|
+
{ name: "crypto-inventory.json", body: JSON.stringify(pack, null, 2) + "\n" },
|
|
225
|
+
];
|
|
226
|
+
for (const d of docs)
|
|
227
|
+
writeFileSync(join(out, d.name), d.body);
|
|
228
|
+
writeFileSync(join(out, "manifest.sha256"), manifest(docs));
|
|
229
|
+
const inScope = pack.rows.filter((r) => r.inScope);
|
|
230
|
+
const weak = inScope.filter((r) => r.strength === "weak").length;
|
|
231
|
+
console.log(`${inScope.length} item${inScope.length === 1 ? "" : "s"} in scope (${weak} weak), ${pack.rows.length - inScope.length} outside it, ${pack.certificates.length} certificate${pack.certificates.length === 1 ? "" : "s"}. Wrote ${join(out, "crypto-inventory.md")}, .csv, .json and manifest.sha256.`);
|
|
232
|
+
for (const e of live.errors)
|
|
233
|
+
console.error(`Couldn't check ${e.target}: ${e.message}`);
|
|
234
|
+
return failOn === "weak" && weak > 0 ? 1 : 0;
|
|
235
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// SPDX-License-Identifier: PolyForm-Shield-1.0.0
|
|
2
|
+
// Copyright 2026 Hard Keel (https://hardkeel.com)
|
|
3
|
+
// Live checks for the evidence pack: every TLS version and cipher suite a server accepts, and every SSH
|
|
4
|
+
// algorithm it offers. Read-only handshakes, one at a time with a pause between them, on hosts the scope
|
|
5
|
+
// file names. Nothing is sent after the handshake.
|
|
6
|
+
import { GAP_MS, handshake, pickSuite, sshKexInit } from "./map-web.js";
|
|
7
|
+
import { protocolUse } from "./protocols.js";
|
|
8
|
+
import { SUITES } from "./suites.js";
|
|
9
|
+
const VERSIONS = [
|
|
10
|
+
["1.0", "TLSv1"],
|
|
11
|
+
["1.1", "TLSv1.1"],
|
|
12
|
+
["1.2", "TLSv1.2"],
|
|
13
|
+
["1.3", "TLSv1.3"],
|
|
14
|
+
];
|
|
15
|
+
const TLS13 = SUITES.filter((s) => s.min === "1.3");
|
|
16
|
+
const TLS12 = SUITES.filter((s) => s.min !== "1.3");
|
|
17
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
18
|
+
/** Parses "host", "host:port", "ssh://host:22". Port 22 or an ssh:// prefix means an SSH check. */
|
|
19
|
+
export function liveTarget(raw, system) {
|
|
20
|
+
const ssh = /^ssh:\/\//i.test(raw);
|
|
21
|
+
const s = raw.replace(/^(https?|ssh):\/\//i, "").replace(/\/.*$/, "");
|
|
22
|
+
const m = s.match(/^\[?([A-Za-z0-9.:-]+?)\]?(?::(\d{1,5}))?$/);
|
|
23
|
+
if (!m)
|
|
24
|
+
return { error: `"${raw}" is not a host name or host:port` };
|
|
25
|
+
const port = m[2] ? Number(m[2]) : ssh ? 22 : 443;
|
|
26
|
+
if (port < 1 || port > 65535)
|
|
27
|
+
return { error: `"${raw}" has a port out of range` };
|
|
28
|
+
return { host: m[1], port, system, ssh: ssh || port === 22 };
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* One TLS server: which versions complete a handshake, which TLS 1.2 suites it accepts (by offering
|
|
32
|
+
* every known suite and taking away the one it picks, until it picks none), which TLS 1.3 suites, and
|
|
33
|
+
* its certificate.
|
|
34
|
+
*/
|
|
35
|
+
export async function liveTls(t, deps = {}) {
|
|
36
|
+
const hs = deps.hs ?? handshake;
|
|
37
|
+
const pick = deps.pick ?? pickSuite;
|
|
38
|
+
const gap = deps.gap ?? GAP_MS;
|
|
39
|
+
const where = `${t.host}:${t.port}`;
|
|
40
|
+
const res = { uses: [], certs: [], errors: [], handshakes: 0 };
|
|
41
|
+
const at = (setting) => ({ file: where, line: 0, setting });
|
|
42
|
+
const live = (u) => u && res.uses.push({ ...u, seen: "live", host: where });
|
|
43
|
+
const versions = [];
|
|
44
|
+
for (const [v, name] of VERSIONS) {
|
|
45
|
+
// Old versions need the client's own floor lowered to be offered at all.
|
|
46
|
+
const h = await hs(t.host, t.port, { minVersion: name, maxVersion: name, ...(v < "1.2" ? { ciphers: "DEFAULT:@SECLEVEL=0" } : {}) });
|
|
47
|
+
res.handshakes++;
|
|
48
|
+
if (h.ok) {
|
|
49
|
+
versions.push(v);
|
|
50
|
+
live(protocolUse("tls-version", v, at(`accepted a TLS ${v} handshake`)));
|
|
51
|
+
if (h.cert && !res.certs.some((c) => c.host === where)) {
|
|
52
|
+
res.certs.push({ host: where, subject: h.cert.subject.replace(/\n/g, ", "), issuer: h.cert.issuer.replace(/\n/g, ", "), notAfter: new Date(h.cert.validTo).toISOString().slice(0, 10), key: keyOf(h.cert) });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else if (h.error && h.error !== "tls") {
|
|
56
|
+
res.errors.push({ target: where, message: h.message ?? h.error });
|
|
57
|
+
return res; // unreachable: no point trying the rest
|
|
58
|
+
}
|
|
59
|
+
await sleep(gap);
|
|
60
|
+
}
|
|
61
|
+
if (versions.some((v) => v !== "1.3")) {
|
|
62
|
+
let offer = TLS12.map((s) => s.code);
|
|
63
|
+
for (let i = 0; i < TLS12.length && offer.length; i++) {
|
|
64
|
+
const got = await pick(t.host, t.port, offer, t.host);
|
|
65
|
+
res.handshakes++;
|
|
66
|
+
if (got === null)
|
|
67
|
+
break;
|
|
68
|
+
const s = TLS12.find((x) => x.code === got);
|
|
69
|
+
if (s)
|
|
70
|
+
live(protocolUse("tls-suite", s.openssl, at("accepted in a TLS 1.2 handshake")));
|
|
71
|
+
offer = offer.filter((c) => c !== got);
|
|
72
|
+
await sleep(gap);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (versions.includes("1.3")) {
|
|
76
|
+
for (const s of TLS13) {
|
|
77
|
+
const h = await hs(t.host, t.port, { minVersion: "TLSv1.3", maxVersion: "TLSv1.3", ciphers: s.iana });
|
|
78
|
+
res.handshakes++;
|
|
79
|
+
if (h.ok)
|
|
80
|
+
live(protocolUse("tls-suite", s.iana, at("accepted in a TLS 1.3 handshake")));
|
|
81
|
+
await sleep(gap);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return res;
|
|
85
|
+
}
|
|
86
|
+
function keyOf(cert) {
|
|
87
|
+
const k = cert.publicKey;
|
|
88
|
+
if (!k?.asymmetricKeyType)
|
|
89
|
+
return "unknown";
|
|
90
|
+
const d = k.asymmetricKeyDetails ?? {};
|
|
91
|
+
return k.asymmetricKeyType === "rsa" ? `RSA-${d.modulusLength ?? "?"}` : k.asymmetricKeyType === "ec" ? `ECDSA ${d.namedCurve ?? ""}`.trim() : k.asymmetricKeyType.toUpperCase();
|
|
92
|
+
}
|
|
93
|
+
/** One SSH server: every key exchange, cipher, MAC and host key algorithm it offers. */
|
|
94
|
+
export async function liveSsh(t, deps = {}) {
|
|
95
|
+
const ssh = deps.ssh ?? sshKexInit;
|
|
96
|
+
const where = `${t.host}:${t.port}`;
|
|
97
|
+
const res = { uses: [], certs: [], errors: [], handshakes: 1 };
|
|
98
|
+
const k = await ssh(t.host, t.port);
|
|
99
|
+
if ("error" in k) {
|
|
100
|
+
res.errors.push({ target: where, message: k.message });
|
|
101
|
+
return res;
|
|
102
|
+
}
|
|
103
|
+
const at = { file: where, line: 0, setting: "offered in the SSH key exchange" };
|
|
104
|
+
const lists = [["kex", k.kex], ["cipher", k.ciphers], ["mac", k.macs], ["hostkey", k.hostKeys]];
|
|
105
|
+
for (const [list, names] of lists)
|
|
106
|
+
for (const n of names)
|
|
107
|
+
res.uses.push({ ...protocolUse(list, n, at), seen: "live", host: where });
|
|
108
|
+
return res;
|
|
109
|
+
}
|