evanlucas / remote-file-size Goto Github PK
View Code? Open in Web Editor NEWGet the size of a remote file
License: MIT License
Get the size of a remote file
License: MIT License
if a url has https then the module throws errors.
{ Error: unable to verify the first certificate
at TLSSocket.onConnectSecure (_tls_wrap.js:1177:34)
at TLSSocket.emit (events.js:197:13)
at TLSSocket._finishInit (_tls_wrap.js:668:8) code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' }
This library is cool. Can we optionally Promisify this package?
I searched duckduckgo for remote file size cli
and this popped up. Exactly what I was looking for. Thanks for writing it!
if a url has https then the module throws errors.
{ Error: unable to verify the first certificate
at TLSSocket.onConnectSecure (_tls_wrap.js:1177:34)
at TLSSocket.emit (events.js:197:13)
at TLSSocket._finishInit (_tls_wrap.js:668:8) code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' }
Using https://github.com/adamisntdead/poke an error is thrown that seems to be from this library
Error: Unable to determine file size
at Request._callback (/home/lewis/.nvm/versions/node/v8.9.4/lib/node_modules/poke-site/node_modules/remote-file-size/index.js:26:17)
at Request.self.callback (/home/lewis/.nvm/versions/node/v8.9.4/lib/node_modules/poke-site/node_modules/request/request.js:188:22)
at emitTwo (events.js:126:13)
at Request.emit (events.js:214:7)
at Request.<anonymous> (/home/lewis/.nvm/versions/node/v8.9.4/lib/node_modules/poke-site/node_modules/request/request.js:1171:10)
at emitOne (events.js:116:13)
at Request.emit (events.js:211:7)
at IncomingMessage.<anonymous> (/home/lewis/.nvm/versions/node/v8.9.4/lib/node_modules/poke-site/node_modules/request/request.js:1091:12)
at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1055:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
Example URL: https://www.stormykromer.com/giftcertificates.php
No idea why but it's across BigCommerce software, so maybe no content-length
header in response?
Are you aware of any way to handle other than throwing an error?
it seems like tests depend on some external resource which is not available?
Version:
commit 1028b533bb1730311ef4ec1257f6f8f25725a998 (HEAD -> master, origin/master, origin/HEAD)
Author: ca333 <[email protected]>
Date: Tue Aug 28 16:59:41 2018 +0200
update travis
removed old node versions that lead to failed build
todo: add/test new/LTS node versons to CI scope
$ node --version
v12.9.1
$ uname -a
Darwin C02T81ZHH03Q 19.6.0 Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT 2020; root:xnu-6153.141.2~1/RELEASE_X86_64 x86_64
Reproduce:
$ npm install
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: this library is no longer supported
npm notice created a lockfile as package-lock.json. You should commit this file.
added 300 packages from 179 contributors and audited 300 packages in 8.791s
found 12 vulnerabilities (5 low, 1 moderate, 5 high, 1 critical)
run `npm audit fix` to fix them, or `npm audit` for details
$ npm test
> [email protected] test /Users/harrinm/work/remote-file-size
> tap test.js --cov
test.js .............................................. 6/12 3m
should return null, size on success
not ok err should not exist
found:
name: Error
stack: |-
Error: connect ETIMEDOUT 104.16.20.35:80
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1056:14)
message: 'connect ETIMEDOUT 104.16.20.35:80'
errno: ETIMEDOUT
code: ETIMEDOUT
syscall: connect
address: 104.16.20.35
port: 80
at:
line: 26
column: 7
file: test.js
stack: |
test.js:26:7
Request._callback (index.js:1:4096)
self.callback (node_modules/request/request.js:185:22)
Request.onRequestError (node_modules/request/request.js:877:8)
source: |
t.ifError(err, 'err should not exist')
should return null, size on success
not ok out should exist
at:
line: 27
column: 7
file: test.js
stack: |
test.js:27:7
Request._callback (index.js:1:4096)
self.callback (node_modules/request/request.js:185:22)
Request.onRequestError (node_modules/request/request.js:877:8)
source: |
t.ok(out, 'out should exist')
should return null, size on success
not ok should be equal
--- wanted
+++ found
-1548
+[null]
compare: '==='
at:
line: 28
column: 7
file: test.js
stack: |
test.js:28:7
Request._callback (index.js:1:4096)
self.callback (node_modules/request/request.js:185:22)
Request.onRequestError (node_modules/request/request.js:877:8)
source: |
t.equal(out, 1548)
should work passing an object
not ok err should not exist
found:
name: Error
stack: |-
Error: connect ETIMEDOUT 104.16.20.35:80
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1056:14)
message: 'connect ETIMEDOUT 104.16.20.35:80'
errno: ETIMEDOUT
code: ETIMEDOUT
syscall: connect
address: 104.16.20.35
port: 80
at:
line: 39
column: 7
file: test.js
stack: |
test.js:39:7
Request._callback (index.js:1:4096)
self.callback (node_modules/request/request.js:185:22)
Request.onRequestError (node_modules/request/request.js:877:8)
source: |
t.ifError(err, 'err should not exist')
should work passing an object
not ok out should exist
at:
line: 40
column: 7
file: test.js
stack: |
test.js:40:7
Request._callback (index.js:1:4096)
self.callback (node_modules/request/request.js:185:22)
Request.onRequestError (node_modules/request/request.js:877:8)
source: |
t.ok(out, 'out should exist')
should work passing an object
not ok should be equal
--- wanted
+++ found
-1548
+[null]
compare: '==='
at:
line: 41
column: 7
file: test.js
stack: |
test.js:41:7
Request._callback (index.js:1:4096)
self.callback (node_modules/request/request.js:185:22)
Request.onRequestError (node_modules/request/request.js:877:8)
source: |
t.equal(out, 1548)
total ................................................ 6/12
6 passing (3m)
6 failing
----------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files | 80.95 | 66.67 | 100 | 80 | |
index.js | 80.95 | 66.67 | 100 | 80 | 28,29,30,33 |
----------|----------|----------|----------|----------|-------------------|
npm ERR! Test failed. See above for more details.
found 12 vulnerabilities (5 low, 1 moderate, 5 high, 1 critical) in 300 scanned packages
12 vulnerabilities require semver-major dependency updates.
it looks like all vulns are related to tap
There are a few security warnings, if you use "remote-file-size" because of the dependencies:
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Moderate │ Prototype pollution │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ hoek │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ > 4.2.0 < 5.0.0 || >= 5.0.3 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ remote-file-size │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ remote-file-size > request > hawk > boom > hoek │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://nodesecurity.io/advisories/566 │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Moderate │ Prototype pollution │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ hoek │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ > 4.2.0 < 5.0.0 || >= 5.0.3 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ remote-file-size │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ remote-file-size > request > hawk > cryptiles > boom > hoek │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://nodesecurity.io/advisories/566 │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Moderate │ Prototype pollution │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ hoek │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ > 4.2.0 < 5.0.0 || >= 5.0.3 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ remote-file-size │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ remote-file-size > request > hawk > hoek │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://nodesecurity.io/advisories/566 │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Moderate │ Prototype pollution │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ hoek │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ > 4.2.0 < 5.0.0 || >= 5.0.3 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ remote-file-size │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ remote-file-size > request > hawk > sntp > hoek │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://nodesecurity.io/advisories/566 │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Moderate │ Out-of-bounds Read │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ stringstream │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ remote-file-size │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ remote-file-size > request > stringstream │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://nodesecurity.io/advisories/664 │
└───────────────┴──────────────────────────────────────────────────────────────┘
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.