Adds support for downloading and checking files

pull/3/head v1.0.2
Nemo 1 year ago
parent b9cfaca8dd
commit 45b1e6ffd5
  1. 4
      CHANGELOG.md
  2. 8
      README.md
  3. 216
      package-lock.json
  4. 7
      package.json
  5. 27
      src/archive.js
  6. 172
      src/index.js

@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## 1.0.2
### Added
- Now supports checking URLs directly.
## 1.0.1
- Support ARM64 builds for Mac/Windows/Linux

@ -21,6 +21,12 @@ v7.1.10 is currently not supported
$ which-electron Appium-linux-1.21.0.AppImage
Fingerprint: v7.2.4-v7.3.3
v7.3.3 is currently not supported
$ which-electron https://github.com/stoplightio/studio/releases/download/v2.3.0-stable.5931.git-67616e9/stoplight-studio-mac.dmg
Downloaded https://github.com/stoplightio/studio/releases/download/v2.3.0-stable.5931.git-67616e9/stoplight-studio-mac.dmg
/tmp/which-electronaN3QGg/stoplight-studio-mac.dmg
Fingerprint: v11.0.5-v11.1.1
v11.1.1 is currently not supported
```
## How does it work?
@ -40,7 +46,7 @@ Note that this can be run against untrusted binaries as it does not _try to run
It is known to not work against:
1. Windows setup files (ones with `-setup` in their name)
2. Breaks with newer AppImage and deb files
2. On systems without 7-zip installed, it falls back to an older version of 7zip via the 7z-bin package on NPM. Unfortunately, the older version can't extract AppImage files correctly.
## License

216
package-lock.json generated

@ -1,22 +1,25 @@
{
"name": "which-electron",
"version": "1.0.0",
"version": "1.0.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"version": "1.0.0",
"version": "1.0.1",
"license": "MIT",
"dependencies": {
"7zip-bin": "^5.1.1",
"electron-fingerprints": "^1.0.0",
"hasha": "^5.2.2",
"is-valid-http-url": "^1.0.3",
"node-7z": "^3.0.0",
"nodejs-file-downloader": "^4.7.1",
"rimraf": "^3.0.2",
"semver-sort": "^0.0.4"
"semver-sort": "^0.0.4",
"which": "^2.0.2"
},
"bin": {
"which-electron": "index.js"
"which-electron": "src/index.js"
},
"devDependencies": {
"kuta": "*"
@ -27,6 +30,17 @@
"resolved": "https://registry.npmjs.org/7zip-bin/-/7zip-bin-5.1.1.tgz",
"integrity": "sha512-sAP4LldeWNz0lNzmTird3uWfFDWWTeg6V/MsmyyLR9X1idwKBWIgt/ZvinqQldJm3LecKEs1emkbquO6PCiLVQ=="
},
"node_modules/agent-base": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
"integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==",
"dependencies": {
"debug": "4"
},
"engines": {
"node": ">= 6.0.0"
}
},
"node_modules/balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
@ -100,6 +114,25 @@
"resolved": "https://registry.npmjs.org/electron-fingerprints/-/electron-fingerprints-1.1.0.tgz",
"integrity": "sha512-b9eLRfbqQJ+eVGa/tizGKkDlRIwoN83TwByvmr9pLCkpbN48X/2pZDgaHrl7PdrlJqUvut6pOfC8d8Bc7b8tAA=="
},
"node_modules/follow-redirects": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.1.tgz",
"integrity": "sha512-HWqDgT7ZEkqRzBvc2s64vSZ/hfOceEol3ac/7tKwzuvEyWx3/4UegXh5oBOIotkGsObyk3xznnSRVADBgWSQVg==",
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/RubenVerborgh"
}
],
"engines": {
"node": ">=4.0"
},
"peerDependenciesMeta": {
"debug": {
"optional": true
}
}
},
"node_modules/fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
@ -139,6 +172,18 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/https-proxy-agent": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz",
"integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==",
"dependencies": {
"agent-base": "6",
"debug": "4"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
@ -161,6 +206,19 @@
"node": ">=8"
}
},
"node_modules/is-valid-http-url": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/is-valid-http-url/-/is-valid-http-url-1.0.3.tgz",
"integrity": "sha512-lrPp25k/Ft3HdusDBdXqne9lNKDtN0HWIHNuC9cfzuFBLlay/gyQeBJukUR1smjyp+zw+gJ5E9wHonpcE9kiCQ==",
"engines": {
"node": ">=6"
}
},
"node_modules/isexe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
"integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA="
},
"node_modules/kuta": {
"version": "2.0.0-beta.6",
"resolved": "https://registry.npmjs.org/kuta/-/kuta-2.0.0-beta.6.tgz",
@ -203,6 +261,25 @@
"resolved": "https://registry.npmjs.org/lodash.negate/-/lodash.negate-3.0.2.tgz",
"integrity": "sha1-nIl7C/YQAZ4LQ7j/Pwr+89e2bzQ="
},
"node_modules/mime-db": {
"version": "1.48.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.48.0.tgz",
"integrity": "sha512-FM3QwxV+TnZYQ2aRqhlKBMHxk10lTbMt3bBkMAp54ddrNeVSfcQYOOKuGuy3Ddrm38I04If834fOUSq1yzslJQ==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.31",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.31.tgz",
"integrity": "sha512-XGZnNzm3QvgKxa8dpzyhFTHmpP3l5YNusmne07VUOXxou9CqUqYa/HBy124RqtVh/O2pECas/MOcsDgpilPOPg==",
"dependencies": {
"mime-db": "1.48.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mimic-fn": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz",
@ -251,6 +328,17 @@
"node": ">=10"
}
},
"node_modules/nodejs-file-downloader": {
"version": "4.7.1",
"resolved": "https://registry.npmjs.org/nodejs-file-downloader/-/nodejs-file-downloader-4.7.1.tgz",
"integrity": "sha512-ZeL+yD1+iOW4gn126uQTZzDJ7q50os8MrzBpMuygtweSX9QTZbiGaqGOaEuKjl+ChrkUa6t00zf460jvmyLZBw==",
"dependencies": {
"follow-redirects": "^1.13.0",
"https-proxy-agent": "^5.0.0",
"mime-types": "^2.1.27",
"sanitize-filename": "^1.6.3"
}
},
"node_modules/normalize-path": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
@ -323,6 +411,14 @@
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/sanitize-filename": {
"version": "1.6.3",
"resolved": "https://registry.npmjs.org/sanitize-filename/-/sanitize-filename-1.6.3.tgz",
"integrity": "sha512-y/52Mcy7aw3gRm7IrcGDFx/bCk4AhRh2eI9luHOQM86nZsqwiRkkq2GekHXBBD+SmPidc8i2PqtYZl+pWJ8Oeg==",
"dependencies": {
"truncate-utf8-bytes": "^1.0.0"
}
},
"node_modules/semver": {
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
@ -357,6 +453,14 @@
"integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==",
"dev": true
},
"node_modules/truncate-utf8-bytes": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/truncate-utf8-bytes/-/truncate-utf8-bytes-1.0.2.tgz",
"integrity": "sha1-QFkjkJWS1W94pYGENLC3hInKXys=",
"dependencies": {
"utf8-byte-length": "^1.0.1"
}
},
"node_modules/type-fest": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz",
@ -365,6 +469,25 @@
"node": ">=8"
}
},
"node_modules/utf8-byte-length": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/utf8-byte-length/-/utf8-byte-length-1.0.4.tgz",
"integrity": "sha1-9F8VDExm7uloGGUFq5P8u4rWv2E="
},
"node_modules/which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"dependencies": {
"isexe": "^2.0.0"
},
"bin": {
"node-which": "bin/node-which"
},
"engines": {
"node": ">= 8"
}
},
"node_modules/wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
@ -377,6 +500,14 @@
"resolved": "https://registry.npmjs.org/7zip-bin/-/7zip-bin-5.1.1.tgz",
"integrity": "sha512-sAP4LldeWNz0lNzmTird3uWfFDWWTeg6V/MsmyyLR9X1idwKBWIgt/ZvinqQldJm3LecKEs1emkbquO6PCiLVQ=="
},
"agent-base": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
"integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==",
"requires": {
"debug": "4"
}
},
"balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
@ -430,6 +561,11 @@
"resolved": "https://registry.npmjs.org/electron-fingerprints/-/electron-fingerprints-1.1.0.tgz",
"integrity": "sha512-b9eLRfbqQJ+eVGa/tizGKkDlRIwoN83TwByvmr9pLCkpbN48X/2pZDgaHrl7PdrlJqUvut6pOfC8d8Bc7b8tAA=="
},
"follow-redirects": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.1.tgz",
"integrity": "sha512-HWqDgT7ZEkqRzBvc2s64vSZ/hfOceEol3ac/7tKwzuvEyWx3/4UegXh5oBOIotkGsObyk3xznnSRVADBgWSQVg=="
},
"fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
@ -457,6 +593,15 @@
"type-fest": "^0.8.0"
}
},
"https-proxy-agent": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz",
"integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==",
"requires": {
"agent-base": "6",
"debug": "4"
}
},
"inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
@ -476,6 +621,16 @@
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.0.tgz",
"integrity": "sha512-XCoy+WlUr7d1+Z8GgSuXmpuUFC9fOhRXglJMx+dwLKTkL44Cjd4W1Z5P+BQZpr+cR93aGP4S/s7Ftw6Nd/kiEw=="
},
"is-valid-http-url": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/is-valid-http-url/-/is-valid-http-url-1.0.3.tgz",
"integrity": "sha512-lrPp25k/Ft3HdusDBdXqne9lNKDtN0HWIHNuC9cfzuFBLlay/gyQeBJukUR1smjyp+zw+gJ5E9wHonpcE9kiCQ=="
},
"isexe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
"integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA="
},
"kuta": {
"version": "2.0.0-beta.6",
"resolved": "https://registry.npmjs.org/kuta/-/kuta-2.0.0-beta.6.tgz",
@ -515,6 +670,19 @@
"resolved": "https://registry.npmjs.org/lodash.negate/-/lodash.negate-3.0.2.tgz",
"integrity": "sha1-nIl7C/YQAZ4LQ7j/Pwr+89e2bzQ="
},
"mime-db": {
"version": "1.48.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.48.0.tgz",
"integrity": "sha512-FM3QwxV+TnZYQ2aRqhlKBMHxk10lTbMt3bBkMAp54ddrNeVSfcQYOOKuGuy3Ddrm38I04If834fOUSq1yzslJQ=="
},
"mime-types": {
"version": "2.1.31",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.31.tgz",
"integrity": "sha512-XGZnNzm3QvgKxa8dpzyhFTHmpP3l5YNusmne07VUOXxou9CqUqYa/HBy124RqtVh/O2pECas/MOcsDgpilPOPg==",
"requires": {
"mime-db": "1.48.0"
}
},
"mimic-fn": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz",
@ -554,6 +722,17 @@
"normalize-path": "^3.0.0"
}
},
"nodejs-file-downloader": {
"version": "4.7.1",
"resolved": "https://registry.npmjs.org/nodejs-file-downloader/-/nodejs-file-downloader-4.7.1.tgz",
"integrity": "sha512-ZeL+yD1+iOW4gn126uQTZzDJ7q50os8MrzBpMuygtweSX9QTZbiGaqGOaEuKjl+ChrkUa6t00zf460jvmyLZBw==",
"requires": {
"follow-redirects": "^1.13.0",
"https-proxy-agent": "^5.0.0",
"mime-types": "^2.1.27",
"sanitize-filename": "^1.6.3"
}
},
"normalize-path": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
@ -605,6 +784,14 @@
"glob": "^7.1.3"
}
},
"sanitize-filename": {
"version": "1.6.3",
"resolved": "https://registry.npmjs.org/sanitize-filename/-/sanitize-filename-1.6.3.tgz",
"integrity": "sha512-y/52Mcy7aw3gRm7IrcGDFx/bCk4AhRh2eI9luHOQM86nZsqwiRkkq2GekHXBBD+SmPidc8i2PqtYZl+pWJ8Oeg==",
"requires": {
"truncate-utf8-bytes": "^1.0.0"
}
},
"semver": {
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
@ -630,11 +817,32 @@
"integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==",
"dev": true
},
"truncate-utf8-bytes": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/truncate-utf8-bytes/-/truncate-utf8-bytes-1.0.2.tgz",
"integrity": "sha1-QFkjkJWS1W94pYGENLC3hInKXys=",
"requires": {
"utf8-byte-length": "^1.0.1"
}
},
"type-fest": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz",
"integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA=="
},
"utf8-byte-length": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/utf8-byte-length/-/utf8-byte-length-1.0.4.tgz",
"integrity": "sha1-9F8VDExm7uloGGUFq5P8u4rWv2E="
},
"which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"requires": {
"isexe": "^2.0.0"
}
},
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",

@ -1,6 +1,6 @@
{
"name": "which-electron",
"version": "1.0.1",
"version": "1.0.2",
"description": "Guess which electron version is bundled in an application",
"main": "src/index.js",
"bin": {
@ -30,9 +30,12 @@
"7zip-bin": "^5.1.1",
"electron-fingerprints": "^1.0.0",
"hasha": "^5.2.2",
"is-valid-http-url": "^1.0.3",
"node-7z": "^3.0.0",
"nodejs-file-downloader": "^4.7.1",
"rimraf": "^3.0.2",
"semver-sort": "^0.0.4"
"semver-sort": "^0.0.4",
"which": "^2.0.2"
},
"devDependencies": {
"kuta": "*"

@ -1,34 +1,43 @@
const Seven = require("node-7z");
const sevenBin = require('7zip-bin').path7za;
const which = require('which');
const path = require("path");
const fs = require("fs");
let sevenBin = null;
try {
sevenBin = which.sync('7z')
} catch(e) {
sevenBin = require('7zip-bin').path7za
console.error("Couldn't find 7-zip installed. Using the 7zip-bin package, which uses an older version of 7-zip. Not all files may work properly.")
}
module.exports = {
readFileContents: function(archive, filepath, cb) {
// TODO: Create a new temp directory
let stream = Seven.extract(archive, "/tmp", {
readFileContents: function(archive, filepath, dir, cb) {
let stream = Seven.extract(archive, dir, {
recursive: true,
$cherryPick: filepath,
$bin: sevenBin
});
let fn = path.basename(filepath);
stream.on("end", ()=>{
cb(fs.readFileSync(`/tmp/${fn}`, {encoding: 'utf8'}))
cb(fs.readFileSync(`${dir}/${fn}`, {encoding: 'utf8'}))
});
},
extractSomeFiles: function(archive, list, cb) {
let dir = fs.mkdtempSync('/tmp/which-electron')
extractSomeFiles: function(archive, list, dir, cb) {
let stream = Seven.extract(archive, dir, {
$cherryPick: list,
$bin: sevenBin
})
stream.on('end', ()=>{
cb(dir)
cb()
})
},
listFileContents: function(archive, cb) {
let zip = Seven.list(archive, {
$bin: sevenBin
$bin: sevenBin,
alternateStreamExtract: true,
alternateStreamReplace: true,
});
let entries = [];
zip.on("data", (data) => {

@ -1,15 +1,59 @@
const path = require("path");
const osguess = require("./os");
const finder = require("./finder");
const zip = require("./zip");
const archive = require("./archive");
const fp = require("./fingerprint");
const cleanup = require("rimraf");
const V = require("./version");
const isUrl = require("is-valid-http-url");
const cleanup = require("rimraf");
const dl = require('nodejs-file-downloader')
const path = require("path");
const fs = require('fs');
const os = require('os');
const process = require('process');
const TMPDIR = path.join(os.tmpdir(), 'which-electron')
// Input file comes from process.argv[2]
const FILENAME = process.argv[2];
let FILENAME = process.argv[2];
if (!FILENAME) {
console.error("Please pass a valid URL or file as the first argument");
process.exit(1)
}
console.log(FILENAME);
if(isUrl(FILENAME)) {
let url = FILENAME;
// Download to temporary directory
let tmpdir = fs.mkdtempSync(TMPDIR);
let fn = `${tmpdir}/${path.basename(url)}`;
const downloader = new dl({
url: url,
directory: tmpdir,//This folder will be created, if it doesn't exist.
})
downloader.download().then(()=> {
console.log(`Downloaded ${url}`)
validateFile(fn)
}).catch((e)=> {
console.error(`Error while downloading ${url}`)
console.error(e)
process.exit(1)
})
} else {
validateFile(FILENAME)
}
function validateFile(fn) {
fs.access(fn, fs.constants.R_OK, (err) => {
if (err) {
console.error(`${fn} not readable`)
process.exit(1);
} else {
console.log(fn);
whichElectron(fn)
}
});
}
function logSupport(version) {
if (V.isSupported(version)) {
@ -19,67 +63,71 @@ function logSupport(version) {
}
}
zip.listFileContents(FILENAME, (entries) => {
let osguess1 = osguess.guessFromFilename(FILENAME);
let osguess2 = osguess.guessFromContents(entries);
let whichElectron = function(filename) {
archive.listFileContents(filename, (entries) => {
let osguess1 = osguess.guessFromFilename(filename);
let osguess2 = osguess.guessFromContents(entries);
if (osguess1 !== osguess2 && osguess1 && osguess2) {
console.log(`Unsure about operating system. Going with ${osguess2}. Other option was ${osguess1}`);
}
if (osguess1 && !osguess2) {
osguess2 = osguess1
}
let arch = osguess.guessArch(FILENAME, entries);
let asar = finder.asar(entries);
let binary = finder.binary(entries);
let versionFiles = finder.version(entries);
let enm = finder.findElectronPackageInsideNodeModules(entries);
if (osguess1 !== osguess2 && osguess1 && osguess2) {
console.log(`Unsure about operating system. Going with ${osguess2}. Other option was ${osguess1}`);
}
if (osguess1 && !osguess2) {
osguess2 = osguess1
}
let arch = osguess.guessArch(filename, entries);
let asar = finder.asar(entries);
let binary = finder.binary(entries);
let versionFiles = finder.version(entries);
let enm = finder.findElectronPackageInsideNodeModules(entries);
let filesToHash = finder.fingerprintable(entries);
let filesToHash = finder.fingerprintable(entries);
zip.extractSomeFiles(FILENAME, filesToHash, (dir) => {
hashes = fp.getHashes(dir);
guesses = fp.guessFromHashes(osguess2, arch, hashes);
if (guesses.length == 1) {
console.log("Fingerprint: " + guesses[0]);
logSupport(guesses[0])
} else if (guesses.length > 1) {
console.log("Fingerprint: " + V.asText(guesses));
logSupport(V.max(guesses))
}
archive.extractSomeFiles(filename, filesToHash, TMPDIR, () => {
hashes = fp.getHashes(TMPDIR);
guesses = fp.guessFromHashes(osguess2, arch, hashes);
if (guesses.length == 1) {
console.log("Fingerprint: " + guesses[0]);
logSupport(guesses[0])
} else if (guesses.length > 1) {
console.log("Fingerprint: " + V.asText(guesses));
logSupport(V.max(guesses))
}
cleanup.sync(dir);
});
cleanup.sync(TMPDIR);
});
// if (binary) {
// console.log(`${process.argv[2]}:${binary}`);
// }
if (versionFiles.length > 0) {
versionFiles.map((f) => {
zip.readFileContents(FILENAME, f, (c) => {
console.log("Found Version file: " + c);
logSupport(`${c}`)
// if (binary) {
// console.log(`${process.argv[2]}:${binary}`);
// }
if (versionFiles.length > 0) {
versionFiles.map((f) => {
archive.readFileContents(filename, f, TMPDIR, (c) => {
console.log("Found Version file: " + c);
logSupport(`${c}`)
});
});
});
}
if (asar.length > 0) {
asar.forEach((a) => {
console.log("Version Constraint (Unsupported): <v7.0.0");
});
}
if (enm) {
enm.forEach((a) => {
zip.readFileContents(FILENAME, a, (c) => {
try {
let packageData = JSON.parse(c);
console.log(
"Found version in package.json file: " + packageData["version"]
);
logSupport(`v${packageData["version"]}`)
} catch (e) {
// TODO: Do something
}
}
if (asar.length > 0) {
asar.forEach((a) => {
console.log("Version Constraint (Unsupported): <v7.0.0");
});
});
}
});
}
if (enm) {
enm.forEach((a) => {
archive.readFileContents(filename, a, (c) => {
try {
let packageData = JSON.parse(c);
console.log(
"Found version in package.json file: " + packageData["version"]
);
logSupport(`v${packageData["version"]}`)
} catch (e) {
// TODO: Do something
}
});
});
}
});
}

Loading…
Cancel
Save