mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
[AAE-46514] - OTher fixes
This commit is contained in:
@@ -254,8 +254,9 @@ async function checkWithMeterian(dependencies) {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
// Run Meterian CLI check using the found path
|
// Run Meterian CLI check using the found path
|
||||||
|
// Use process.execPath to avoid PATH-based attacks
|
||||||
const cliScript = join(cliPath, 'src', 'cli.js');
|
const cliScript = join(cliPath, 'src', 'cli.js');
|
||||||
const result = spawnSync('node', [cliScript, 'check'], {
|
const result = spawnSync(process.execPath, [cliScript, 'check'], {
|
||||||
input: JSON.stringify(input),
|
input: JSON.stringify(input),
|
||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
timeout: 60000, // 60 second timeout
|
timeout: 60000, // 60 second timeout
|
||||||
@@ -490,7 +491,7 @@ function matchesVersionRange(version, range) {
|
|||||||
const conditions = range.split(',').map(c => c.trim());
|
const conditions = range.split(',').map(c => c.trim());
|
||||||
|
|
||||||
for (const condition of conditions) {
|
for (const condition of conditions) {
|
||||||
const match = condition.match(/^(>=|<=|>|<|=)?\s*(.+)$/);
|
const match = condition.match(/^(>=|<=|>|<|=)?\s*(\S+)$/);
|
||||||
if (!match) continue;
|
if (!match) continue;
|
||||||
|
|
||||||
const [, operator = '=', targetVersion] = match;
|
const [, operator = '=', targetVersion] = match;
|
||||||
|
|||||||
@@ -38,6 +38,13 @@ import { fileURLToPath } from 'url';
|
|||||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||||
const ROOT_DIR = join(__dirname, '..');
|
const ROOT_DIR = join(__dirname, '..');
|
||||||
|
|
||||||
|
// Use npm_execpath from environment (set by npm during lifecycle scripts)
|
||||||
|
// Falls back to 'npm' if not available (e.g., running script directly)
|
||||||
|
const NPM_PATH = process.env.npm_execpath || 'npm';
|
||||||
|
const NPX_CMD = NPM_PATH.endsWith('npm-cli.js')
|
||||||
|
? `"${process.execPath}" "${NPM_PATH.replace('npm-cli.js', 'npx-cli.js')}"`
|
||||||
|
: 'npx';
|
||||||
|
|
||||||
// Packages that are trusted to run postinstall/install scripts
|
// Packages that are trusted to run postinstall/install scripts
|
||||||
// These typically need to compile native bindings or setup tooling
|
// These typically need to compile native bindings or setup tooling
|
||||||
const TRUSTED_PACKAGES = [
|
const TRUSTED_PACKAGES = [
|
||||||
@@ -122,8 +129,8 @@ async function main() {
|
|||||||
console.log('Step 1/3: Running security check...\n');
|
console.log('Step 1/3: Running security check...\n');
|
||||||
const securityCheckPath = join(__dirname, 'check-security.mjs');
|
const securityCheckPath = join(__dirname, 'check-security.mjs');
|
||||||
|
|
||||||
// Run security check as subprocess (it calls process.exit)
|
// Run security check as subprocess using process.execPath to avoid PATH-based attacks
|
||||||
const securityPassed = run(`node "${securityCheckPath}"`);
|
const securityPassed = run(`"${process.execPath}" "${securityCheckPath}"`);
|
||||||
if (!securityPassed) {
|
if (!securityPassed) {
|
||||||
console.error('\n❌ Security check failed - installation aborted\n');
|
console.error('\n❌ Security check failed - installation aborted\n');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
@@ -138,7 +145,8 @@ async function main() {
|
|||||||
trustedInstalled.forEach(pkg => console.log(` ✓ ${pkg}`));
|
trustedInstalled.forEach(pkg => console.log(` ✓ ${pkg}`));
|
||||||
console.log('');
|
console.log('');
|
||||||
|
|
||||||
run(`npm rebuild --ignore-scripts=false ${trustedInstalled.join(' ')}`);
|
const npmCmd = NPM_PATH === 'npm' ? 'npm' : `"${process.execPath}" "${NPM_PATH}"`;
|
||||||
|
run(`${npmCmd} rebuild --ignore-scripts=false ${trustedInstalled.join(' ')}`);
|
||||||
} else {
|
} else {
|
||||||
console.log('No trusted packages require rebuilding.\n');
|
console.log('No trusted packages require rebuilding.\n');
|
||||||
}
|
}
|
||||||
@@ -147,7 +155,7 @@ async function main() {
|
|||||||
console.log('Step 3/3: Setting up husky...\n');
|
console.log('Step 3/3: Setting up husky...\n');
|
||||||
const huskyPath = join(ROOT_DIR, 'node_modules', 'husky');
|
const huskyPath = join(ROOT_DIR, 'node_modules', 'husky');
|
||||||
if (existsSync(huskyPath)) {
|
if (existsSync(huskyPath)) {
|
||||||
run('npx husky');
|
run(`${NPX_CMD} husky`);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('='.repeat(70));
|
console.log('='.repeat(70));
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ function parseVersionRange(range, version) {
|
|||||||
|
|
||||||
const parts = range.split(',').map(p => p.trim());
|
const parts = range.split(',').map(p => p.trim());
|
||||||
for (const part of parts) {
|
for (const part of parts) {
|
||||||
const match = part.match(/^([<>=]+)\s*(.+)$/);
|
const match = part.match(/^([<>=]+)\s*(\S+)$/);
|
||||||
if (!match) {
|
if (!match) {
|
||||||
if (part === version) return true;
|
if (part === version) return true;
|
||||||
continue;
|
continue;
|
||||||
@@ -179,7 +179,8 @@ function compareVersions(a, b) {
|
|||||||
function extractVersionNumber(versionSpec) {
|
function extractVersionNumber(versionSpec) {
|
||||||
if (!versionSpec) return null;
|
if (!versionSpec) return null;
|
||||||
// Remove ^, ~, >=, <=, >, <, = prefixes
|
// Remove ^, ~, >=, <=, >, <, = prefixes
|
||||||
const match = versionSpec.match(/[\d]+\.[\d]+\.[\d]+(?:-[\w.]+)?/);
|
// Use atomic pattern to prevent backtracking: match version then optional prerelease
|
||||||
|
const match = versionSpec.match(/(\d+)\.(\d+)\.(\d+)(?:-([a-zA-Z0-9]+(?:\.[a-zA-Z0-9]+)*))?/);
|
||||||
return match ? match[0] : null;
|
return match ? match[0] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user