timaschew / link-checker

🚀Superfast link checker for HTML pages
MIT License
18 stars 11 forks source link

"WTF, this should not happen" #16

Open Pomax opened 4 years ago

Pomax commented 4 years ago

Usually a good idea to clean up any "wtf" and replace them with information that lets people track down exactly what went wrong, while looking at which line in whatever is being parsed =)

> bezierinfo@3.0.0 link:links C:\Users\Mike\Documents\Git\released\bezierinfo-2
> link-checker docs/index.html --allow-hash-href

WTF, this should not happen
TypeError: Cannot read property 'url' of undefined
    at getOverrideFor (C:\Users\Mike\Documents\Git\released\bezierinfo-2\node_modules\link-checker\link-checker.js:59:59)
    at C:\Users\Mike\Documents\Git\released\bezierinfo-2\node_modules\link-checker\link-checker.js:359:45
    at Array.forEach (<anonymous>)
    at C:\Users\Mike\Documents\Git\released\bezierinfo-2\node_modules\link-checker\link-checker.js:358:14
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Walker.<anonymous> (C:\Users\Mike\Documents\Git\released\bezierinfo-2\node_modules\link-checker\link-checker.js:344:3)
page not found from index.html to ja-JP\index.html
page not found from index.html to zh-CN\index.html
page not found from index.html to legendre-gauss.html
could not fetch external page: Error: Moved Permanently (Code: 301) from index.html to https://pomax.github.io/bezierinfo
could not fetch external page: Error: Moved Permanently (Code: 301) from index.html to https://pomax.github.io/bezierjs

1 files were scanned in docs/index.html
48 local links and 0 parent links and 82 remote links were checked
5 errors and 0 warnings
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bezierinfo@3.0.0 link:links: `link-checker docs/index.html --allow-hash-href `
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bezierinfo@3.0.0 link:links script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Mike\AppData\Roaming\npm-cache\_logs\2020-09-11T21_43_37_055Z-debug.log
Pomax commented 4 years ago

Updating the code to figure out what's happening:

    [...]

    let fileCounter = 0
    debug('scanning directory', directory)

    function getOverrideFor(target) {

        let url;
        try{
            url = target instanceof Error && target.response ? target.response.request.url // superagent error
                : typeof target === "object" ? target.request.url // superagent response
                : typeof target === "string" ? target // plain URL
                : null
        } catch (e) {
            console.log(`target:\n`, target);
            throw e;
            process.exit(1);
        }

    [...]

shows a TLS error:

target:
 Error [ERR_TLS_CERT_ALTNAME_INVALID]: Hostname/IP does not match certificate's altnames:
   Host: www.cityinthesky.co.uk. is not in the cert's altnames:
    DNS:www.github.com,
    DNS:*.github.com,
    DNS:github.com,
    DNS:*.github.io,
    DNS:github.io,
    DNS:*.githubusercontent.com,
    DNS:githubusercontent.com

at Object.checkServerIdentity (tls.js:287:12)
 at TLSSocket.onConnectSecure (_tls_wrap.js:1507:27)
  at TLSSocket.emit (events.js:314:20)
   at TLSSocket._finishInit (_tls_wrap.js:932:8)
    at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:706:12)
{
  reason: "Host: www.cityinthesky.co.uk. is not in the cert's altnames: DNS:www.github.com, DNS:*.github.com, DNS:github.com, DNS:*.github.io, DNS:github.io, DNS:*.githubusercontent.com, DNS:githubusercontent.com",
  host: 'www.cityinthesky.co.uk',
  cert: {
    subject: [Object: null prototype] {
      C: 'US',
      ST: 'California',
      L: 'San Francisco',
      O: 'GitHub, Inc.',
      CN: 'www.github.com'
    },
    issuer: [Object: null prototype] {
      C: 'US',
      O: 'DigiCert Inc',
      OU: 'www.digicert.com',
      CN: 'DigiCert SHA2 High Assurance Server CA'
    },
    subjectaltname: 'DNS:www.github.com, DNS:*.github.com, DNS:github.com, DNS:*.github.io, DNS:github.io, DNS:*.githubusercontent.com, DNS:githubusercontent.com',
    infoAccess: [Object: null prototype] {
      'OCSP - URI': [Array],
      'CA Issuers - URI': [Array]
    },
    modulus: 'B23E3DEA327DF6F7845CEED677119067B89DB429C372366A41E0E2CBAD39ED2C178FDC835159EA870A3FC8823CFB2E89A64DE0EF92E93E960D8E23B0629FC992959BA4101DD455A5BD7268FDE652F93C2E2186FB2527361F73430CAB76555E5248A41D5CE90336AABB062B0E169DBF4D8C023196E82EE7F0451E5F2B12F49D3288382C299C7F24FFF51D5A9BD38088B10C62D8402C07B747D8128E3D8C578368A0F858C04FABA4F1D62296061C371D573F3B2BC8DF28D1031E009DFFC3092B7D6135BA7FF343E0EFDF3A8C1C7D6E53EF38A2D4AC34CB0FAE941AC4FF17BAB5A5612FE411D0C5CD91057688734DF39B3089DC0CB5C74623C8377D82F8F1B491CB',
    bits: 2048,
    exponent: '0x10001',
    pubkey: <Buffer 30 82 01 22 30 0d 06 09 2a 86 48 86 f7 0d 01 01 01 05 00 03 82 01 0f 00 30 82 01 0a 02 82 01 01 00 b2 3e 3d ea 32 7d f6 f7 84 5c ee d6 77 11 90 67 b8 ... 244 more bytes>,
    valid_from: 'May  6 00:00:00 2020 GMT',
    valid_to: 'Apr 14 12:00:00 2022 GMT',
    fingerprint: '70:94:DE:DD:E6:C4:69:48:3A:92:70:A1:48:56:78:2D:18:64:E0:B7',
    fingerprint256: '61:79:D2:FB:1F:F1:DA:04:E8:D2:8B:28:BA:9F:84:CB:24:B4:B8:BC:B8:C0:E2:5B:31:25:1D:67:87:80:D0:89',
    ext_key_usage: [ '1.3.6.1.5.5.7.3.1', '1.3.6.1.5.5.7.3.2' ],
    serialNumber: '02493E07FA9E375A2DBBC61D94430FCF',
    raw: <Buffer 30 82 07 30 30 82 06 18 a0 03 02 01 02 02 10 02 49 3e 07 fa 9e 37 5a 2d bb c6 1d 94 43 0f cf 30 0d 06 09 2a 86 48 86 f7 0d 01 01 0b 05 00 30 70 31 0b ... 1794 more bytes>,
    issuerCertificate: {
      subject: [Object: null prototype],
      issuer: [Object: null prototype],
      infoAccess: [Object: null prototype],
      modulus: 'B6E02FC22406C86D045FD7EF0A6406B27D22266516AE42409BCEDC9F9F76073EC330558719B94F940E5A941F5556B4C2022AAFD098EE0B40D7C4D03B72C8149EEF90B111A9AED2C8B8433AD90B0BD5D595F540AFC81DED4D9C5F57B786506899F58ADAD2C7051FA897C9DCA4B182842DC6ADA59CC71982A6850F5E44582A378FFD35F10B0827325AF5BB8B9EA4BD51D027E2DD3B4233A30528C4BB28CC9AAC2B230D78C67BE65E71B74A3E08FB81B71616A19D23124DE5D79208AC75A49CBACD17B21E4435657F532539D11C0A9A631B199274680A37C2C25248CB395AA2B6E15DC1DDA020B821A293266F144A2141C7ED6D9BF2482FF303F5A26892532F5EE3',
      bits: 2048,
      exponent: '0x10001',
      pubkey: <Buffer 30 82 01 22 30 0d 06 09 2a 86 48 86 f7 0d 01 01 01 05 00 03 82 01 0f 00 30 82 01 0a 02 82 01 01 00 b6 e0 2f c2 24 06 c8 6d 04 5f d7 ef 0a 64 06 b2 7d ... 244 more bytes>,
      valid_from: 'Oct 22 12:00:00 2013 GMT',
      valid_to: 'Oct 22 12:00:00 2028 GMT',
      fingerprint: 'A0:31:C4:67:82:E6:E6:C6:62:C2:C8:7C:76:DA:9A:A6:2C:CA:BD:8E',
      fingerprint256: '19:40:0B:E5:B7:A3:1F:B7:33:91:77:00:78:9D:2F:0A:24:71:C0:C9:D5:06:C0:E5:04:C0:6C:16:D7:CB:17:C0',
      ext_key_usage: [Array],
      serialNumber: '04E1E7A4DC5CF2F36DC02B42B85D159F',
      raw: <Buffer 30 82 04 b1 30 82 03 99 a0 03 02 01 02 02 10 04 e1 e7 a4 dc 5c f2 f3 6d c0 2b 42 b8 5d 15 9f 30 0d 06 09 2a 86 48 86 f7 0d 01 01 0b 05 00 30 6c 31 0b ... 1155 more bytes>,
      issuerCertificate: [Object]
    }
  },
  code: 'ERR_TLS_CERT_ALTNAME_INVALID',
  response: undefined
}
WTF, this should not happen
andrewholgate commented 4 years ago

@Pomax Agree, this is a much more useful error log message. Maybe you can create a PR so we can see if this gets accepted into the next release?

Pomax commented 4 years ago

maybe I'm still waiting for my other PR from early September to even be looked at, because there is no sign this repo hasn't been abandoned. But feel free to file your own PR based on this issue's findings.

andrewholgate commented 3 years ago

Hi @timaschew @pierot - can you confirm if this great little tool has been abandoned or not?

pierot commented 3 years ago

@andrewholgate it is not mine, this project merely adopted the name of an older tool I wrote. I have no other affiliation.

timaschew commented 3 years ago

Hey guys, sorry for the delay! I've misconfigured my developer email directory and did not receive the mails. @andrewholgate no the project is not abandoned!

I will take a look at the PR of @Pomax