@applitools/execution-grid-tunnel
Advanced tools
Comparing version 1.0.4 to 1.0.5-beta.0
{ | ||
"name": "@applitools/execution-grid-tunnel", | ||
"version": "1.0.4", | ||
"version": "1.0.5-beta.0", | ||
"description": "", | ||
@@ -12,4 +12,3 @@ "main": "scripts/run-execution-grid-tunnel.js", | ||
"scripts", | ||
"examples", | ||
"bin" | ||
"examples" | ||
], | ||
@@ -16,0 +15,0 @@ "bin": { |
'use strict' | ||
const os = require('os') | ||
const path = require('path') | ||
const {promises: fs} = require('fs') | ||
const crypto = require('crypto'); | ||
const {promises: fs, existsSync, statSync} = require('fs') | ||
const nodeCleanup = require('node-cleanup') | ||
const {getCacheDirectoryPath} = require('../src/utils') | ||
const createApp = require('../src/execution-grid-tunnel') | ||
@@ -15,3 +17,4 @@ const { | ||
initSocks5ProxyServer, | ||
} = require('../src/utils') | ||
} = require('../src/utils'); | ||
const { getExpectedHash, downloadFrpc, getBinHash, getManualFrpcInstallingErrorMessage } = require('./frpc'); | ||
@@ -59,2 +62,4 @@ // TODO: Client Should need other logging system | ||
sendTunnelHeartBeatAlways = false, // Set it to true only in tests. By default, you shouldn't send heartbeat if there is no tunnel | ||
shouldInstallFrpc = true, | ||
cacheDirectoryPath = process.env.APPLITOOLS_EG_FRPC_CACHE_DIRECTORY || path.join(getCacheDirectoryPath(os.platform()), 'eg-applitools'), | ||
mode = process.env.APPLITOOLS_EG_TUNNEL_MODE_ENV, // Set it to 'development' only in tests | ||
@@ -76,22 +81,24 @@ } = {}) { | ||
}) | ||
const platform = os.platform() | ||
const arch = os.arch() | ||
await createDirectoryIfDoesntExist(cacheDirectoryPath) | ||
const frpcBinFilePath = frpcBinMap.get(`${os.platform()}_${os.arch()}`) | ||
const fileSuffix = platform === 'win32' ? '.exe' : '' | ||
const frpcPath = path.resolve(cacheDirectoryPath, `frpc${fileSuffix}`) | ||
if (!frpcBinFilePath) { | ||
throw `execution-grid-tunnel doesn't support ${os.platform()} with ${os.arch} architecture yet` | ||
const expectedHash = getExpectedHash({platform, arch}) | ||
if (!expectedHash) { | ||
throw `execution-grid-tunnel doesn't support ${platform} with ${arch} architecture yet` | ||
} | ||
const buffer = await fs.readFile(frpcBinFilePath) | ||
const binPath = path.resolve( | ||
FILES_ROOT_DIRECTORY, | ||
`frpc${os.platform() === 'win32' ? '.exe' : ''}`, | ||
) | ||
let isFrpcExist = existsSync(frpcPath) | ||
let isExpectedFrpc = existsSync(frpcPath) && (await getBinHash(frpcPath)) === expectedHash | ||
// Create frpc file in tmp dir with rwe permissions | ||
await fs.writeFile(binPath, buffer) | ||
await fs.chmod(binPath, 0o777) | ||
if (!isExpectedFrpc && !shouldInstallFrpc) throw new Error(getManualFrpcInstallingErrorMessage({platform, arch, cacheDirectoryPath, frpcPath, shouldUpdate: isFrpcExist})) | ||
// if (!egTunnelManagerUrl) { | ||
// throw 'You should define APPLITOOLS_EG_TUNNEL_MANAGER_URL first' | ||
// } | ||
if (!isExpectedFrpc) { | ||
await downloadFrpc({platform, arch, cacheDirectoryPath, frpcPath ,expectedHash}) | ||
} | ||
@@ -120,3 +127,3 @@ createDirectoryIfDoesntExist(serviceLoggerDirectory) | ||
logFileDirectory: tunnelLogFileDirectory, | ||
runTunnelBinPath: binPath, | ||
runTunnelBinPath: frpcPath, | ||
socks5Proxies: [socks5ProxyServer], | ||
@@ -219,2 +226,3 @@ portRange, | ||
module.exports = main |
@@ -10,2 +10,3 @@ const createDirectoryIfDoesntExist = require('./create-directory-if-doesnt-exist') | ||
const initSocks5ProxyServer = require('./init-socks5-proxy-server') | ||
const {getCacheDirectoryPath} = require("./get-cache-directory-path") | ||
@@ -34,2 +35,3 @@ function generatePromise() { | ||
initSocks5ProxyServer, | ||
getCacheDirectoryPath | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 4 instances in 1 package
1291
7
46266
30
2
23