93 lines
2.1 KiB
JavaScript
93 lines
2.1 KiB
JavaScript
// finds specific files from a list
|
|
import path from "path";
|
|
import { isDirectory } from "./utils.js";
|
|
|
|
// Finds the electron asar file, if we can
|
|
export function asar(entries) {
|
|
return entries
|
|
.filter((e) => {
|
|
return (
|
|
isDirectory(e.attributes) == false &&
|
|
path.basename(e.file) == "electron.asar"
|
|
);
|
|
})
|
|
.map((e) => e.file);
|
|
}
|
|
|
|
export function binaries(entries) {
|
|
entries = entries.sort((a, b) => b.size - a.size);
|
|
for (const entry of entries) {
|
|
if (isDirectory(entry.attributes)) {
|
|
continue;
|
|
}
|
|
let ext = path.extname(entry.file);
|
|
let size = entry.size;
|
|
// Return the first exe file
|
|
if (ext == ".exe") {
|
|
return [entry.file];
|
|
} else if (ext == "") {
|
|
// or the largest file with no extension
|
|
return [entry.file];
|
|
}
|
|
}
|
|
}
|
|
|
|
export function version(entries) {
|
|
return entries
|
|
.filter((e) => {
|
|
return (
|
|
isDirectory(e.attributes) == false && path.basename(e.file) == "version"
|
|
);
|
|
})
|
|
.map((e) => e.file);
|
|
}
|
|
|
|
export function findElectronPackageInsideNodeModules(entries) {
|
|
return entries
|
|
.filter((e) => {
|
|
return (
|
|
isDirectory(e.attributes) == false &&
|
|
e.file.match(/node_modules\/electron\/package\.json$/)
|
|
);
|
|
})
|
|
.map((e) => e.file);
|
|
}
|
|
|
|
// Return a list of files that might be worth fingerprinting
|
|
export function fingerprintable(entries) {
|
|
return entries
|
|
.filter((e) => {
|
|
if (isDirectory(e.attributes)) {
|
|
return false;
|
|
}
|
|
if (!e.file) {
|
|
return false;
|
|
}
|
|
let ext = path.extname(e.file);
|
|
if (
|
|
[".h", ".dll", ".bin", ".asar", ".dylib", ".so", ".exe"].indexOf(
|
|
ext
|
|
) !== -1
|
|
) {
|
|
return true;
|
|
}
|
|
let b = path.basename(e.file);
|
|
|
|
if (
|
|
[
|
|
"electron framework",
|
|
"squirrel",
|
|
"electron",
|
|
"electron helper",
|
|
"chrome_100_percent",
|
|
"chrome_200_percent",
|
|
].indexOf(b) !== -1
|
|
) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
})
|
|
.map((e) => e.file);
|
|
}
|