dsh-moli 1.1.2 → 1.1.3
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/index.js +1 -0
- package/lib/moli.js +47 -3
- package/package.json +1 -1
package/index.js
CHANGED
package/lib/moli.js
CHANGED
|
@@ -314,7 +314,45 @@ export function runFetch(options) {
|
|
|
314
314
|
const bytes = outcome.stdout.length;
|
|
315
315
|
const stderr = outcome.spawnError === undefined ? outcome.stderr : `${outcome.spawnError} | ${outcome.stderr}`;
|
|
316
316
|
|
|
317
|
-
|
|
317
|
+
// Empty stdout on a zero exit is not a failure: a page can legitimately have
|
|
318
|
+
// no content in the requested format, which is exactly what a client-rendered
|
|
319
|
+
// page yields under `noJs` with a text dump. moli is right to print nothing
|
|
320
|
+
// for it, and the old code answered with "moli exited with status 0 and no
|
|
321
|
+
// output" plus a hint to re-check the install, sending the caller after a host
|
|
322
|
+
// that was never broken.
|
|
323
|
+
//
|
|
324
|
+
// Both decisions live in this one branch on purpose. Splitting them -- empty
|
|
325
|
+
// stdout treated as success here and stderr checked further down -- lets the
|
|
326
|
+
// case below (silent stdout, a complaint on stderr, exit 0) fall through to
|
|
327
|
+
// the normal success path with the complaint silently dropped.
|
|
328
|
+
if (outcome.status === 0 && bytes === 0) {
|
|
329
|
+
if (stderr !== '') {
|
|
330
|
+
return {
|
|
331
|
+
ok: false,
|
|
332
|
+
url: args.url,
|
|
333
|
+
error: stderr,
|
|
334
|
+
sandboxTlsBlock: isSandboxTlsFailure(stderr),
|
|
335
|
+
unreachable: false,
|
|
336
|
+
possiblyUnreachable: false,
|
|
337
|
+
hint: 'The engine exited cleanly but produced no output and explained why on stderr; the text above is its own message.',
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
return {
|
|
341
|
+
ok: true,
|
|
342
|
+
url: args.url,
|
|
343
|
+
kind: 'text',
|
|
344
|
+
dump: args.dump ?? 'html',
|
|
345
|
+
content: '',
|
|
346
|
+
chars: 0,
|
|
347
|
+
bytes: 0,
|
|
348
|
+
empty: true,
|
|
349
|
+
note: 'moli succeeded and produced no output, so the page had no content in this format. '
|
|
350
|
+
+ 'A page whose content is built by JavaScript yields nothing when noJs is set; '
|
|
351
|
+
+ 'the same URL renders normally without it.',
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
if (outcome.status !== 0) {
|
|
318
356
|
const sandboxTls = isSandboxTlsFailure(stderr);
|
|
319
357
|
// A blocked host fails at connect time ("Failed to connect" / RST) or, when
|
|
320
358
|
// the socket never opens, as a readiness timeout with nothing to show. A
|
|
@@ -459,7 +497,11 @@ export function probe(exe, probeUrl, insecureTls = false) {
|
|
|
459
497
|
if (insecureTls) probeArgs.push('--insecure-disable-tls-host-verification');
|
|
460
498
|
const outcome = fetchOnce({ exe, args: probeArgs, timeoutMs: 20000 });
|
|
461
499
|
const stderr = outcome.spawnError === undefined ? outcome.stderr : `${outcome.spawnError} | ${outcome.stderr}`;
|
|
462
|
-
|
|
500
|
+
// A zero exit means moli reached the host and fetched it. Requiring non-empty
|
|
501
|
+
// stdout as well would report httpsOk:false for a page that simply has no
|
|
502
|
+
// text — a probe URL is not guaranteed to carry content, and the field is
|
|
503
|
+
// documented as "can reach HTTPS", which is what the exit status proves.
|
|
504
|
+
const ok = outcome.status === 0;
|
|
463
505
|
const revocation = /CRYPT_E_REVOCATION_OFFLINE|revocation/iu.test(stderr);
|
|
464
506
|
return {
|
|
465
507
|
exe,
|
|
@@ -467,7 +509,9 @@ export function probe(exe, probeUrl, insecureTls = false) {
|
|
|
467
509
|
httpsOk: ok,
|
|
468
510
|
probeUrl,
|
|
469
511
|
detail: ok
|
|
470
|
-
?
|
|
512
|
+
? (outcome.stdout.length > 0
|
|
513
|
+
? 'HTTPS fetch succeeded from the DSH host process.'
|
|
514
|
+
: 'HTTPS fetch succeeded from the DSH host process (the probe URL returned no text).')
|
|
471
515
|
: revocation && !insecureTls
|
|
472
516
|
? `${stderr} | This is a certificate-revocation check failing (offline CRL/OCSP responder); retrying with the no-verify flag normally clears it.`
|
|
473
517
|
: stderr,
|
package/package.json
CHANGED