Socket
Socket
Sign inDemoInstall

@prisma/get-platform

Package Overview
Dependencies
Maintainers
4
Versions
7640
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prisma/get-platform - npm Package Compare versions

Comparing version 0.1.9 to 0.1.10

10

dist/getPlatform.d.ts

@@ -7,14 +7,8 @@ /// <reference types="node" />

distro?: {
dist: string;
codename: string;
release: string;
base: 'rhel' | 'debian';
};
};
export declare function getos(): Promise<GetOSResult>;
export declare function resolveUbuntu(): Promise<null | {
dist: string;
release: string;
codename: string;
}>;
export declare function resolveDistro(): Promise<undefined | GetOSResult['distro']>;
export declare function getLibSslVersion(): Promise<string | undefined>;
export declare function getPlatform(): Promise<Platform>;

80

dist/getPlatform.js

@@ -24,30 +24,42 @@ "use strict";

libssl: await getLibSslVersion(),
distro: await resolveUbuntu(),
distro: await resolveDistro(),
};
}
exports.getos = getos;
async function resolveUbuntu() {
if (await exists('/etc/lsb-release')) {
const idRegex = /distrib_id=(.*)/i;
const releaseRegex = /distrib_release=(.*)/i;
const codenameRegex = /distrib_codename=(.*)/i;
const file = await readFile('/etc/lsb-release', 'utf-8');
const idMatch = file.match(idRegex);
const id = (idMatch && idMatch[1]) || null;
const codenameMatch = file.match(codenameRegex);
const codename = (codenameMatch && codenameMatch[1]) || null;
const releaseMatch = file.match(releaseRegex);
const release = (releaseMatch && releaseMatch[1]) || null;
if (id && codename && release && id.toLowerCase() === 'ubuntu') {
return { dist: id, release, codename };
}
async function resolveDistro() {
const osReleaseFile = '/etc/os-release';
if (!await exists(osReleaseFile)) {
return;
}
return null;
const idRegex = /^ID=(.*)$/i;
const idLikeRegex = /^ID_LIKE=(.*)$/i;
const file = await readFile(osReleaseFile, 'utf-8');
const idMatch = file.match(idRegex);
const idPre = (idMatch && idMatch[1]) || null;
const id = idPre && idPre.toLowerCase();
const idLikeMatch = file.match(idLikeRegex);
const idLikePre = (idLikeMatch && idLikeMatch[1]) || null;
const idLike = idLikePre && idLikePre.toLowerCase();
if (idLike.includes('centos') ||
idLike.includes('fedora') ||
idLike.includes('rhel') ||
id.includes('fedora')) {
return { base: 'rhel' };
}
if (idLike.includes('debian') ||
idLike.includes('ubuntu') ||
id.includes('debian')) {
return { base: 'debian' };
}
return;
}
exports.resolveUbuntu = resolveUbuntu;
exports.resolveDistro = resolveDistro;
// getLibSslVersion returns the OpenSSL version excluding the patch version, e.g. "1.1.x"
async function getLibSslVersion() {
const [version, ls] = await Promise.all([
gracefulExec(`openssl version -v`),
gracefulExec(`ls -l /lib64 | grep ssl;
ls -l /usr/lib64 | grep ssl`),
gracefulExec(`
ls -l /lib64 | grep ssl;
ls -l /usr/lib64 | grep ssl;
`),
]);

@@ -57,11 +69,11 @@ debug({ version });

if (version) {
const match = /^OpenSSL\s(\d+\.\d+\.\d+)/.exec(version);
const match = /^OpenSSL\s(\d+\.\d+)\.\d+/.exec(version);
if (match) {
return match[1];
return match[1] + '.x';
}
}
if (ls) {
const match = /libssl\.so\.(\d+\.\d+\.\d+)/.exec(ls);
const match = /libssl\.so\.(\d+\.\d+)\.\d+/.exec(ls);
if (match) {
return match[1];
return match[1] + '.x';
}

@@ -94,16 +106,14 @@ }

}
if (platform === 'linux' && libssl) {
if (libssl === '1.0.2') {
if (distro && distro.codename === 'xenial') {
return 'linux-glibc-libssl1.0.2-ubuntu1604';
}
return 'linux-glibc-libssl1.0.2';
}
if (libssl === '1.0.1') {
return 'linux-glibc-libssl1.0.1';
}
// when the platform is linux
if (platform === 'linux' && distro && libssl) {
return (distro.base + '-openssl-' + libssl);
}
return 'linux-glibc-libssl1.1.0';
// if just OpenSSL is known, fallback to debian with a specific libssl version
if (libssl) {
return ('debian-openssl-' + libssl);
}
// use the debian build with OpenSSL 1.1 as a last resort
return 'debian-openssl-1.1.x';
}
exports.getPlatform = getPlatform;
//# sourceMappingURL=getPlatform.js.map

@@ -1,2 +0,2 @@

export declare type Platform = 'native' | 'darwin' | 'linux-glibc-libssl1.0.1' | 'linux-glibc-libssl1.0.2' | 'linux-glibc-libssl1.0.2-ubuntu1604' | 'linux-glibc-libssl1.1.0' | 'windows';
export declare type Platform = 'native' | 'darwin' | 'debian-openssl-1.0.x' | 'debian-openssl-1.1.x' | 'rhel-openssl-1.0.x' | 'rhel-openssl-1.1.x' | 'windows';
export declare function mayBeCompatible(platformA: Platform, platformB: Platform): boolean;
{
"name": "@prisma/get-platform",
"version": "0.1.9",
"version": "0.1.10",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "types": "dist/index.d.ts",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc