mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
05cb16dc1a
Always use `process.config.variables.asan`. This removes the need for a special ASAN env var. PR-URL: https://github.com/nodejs/node/pull/52430 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
62 lines
1.7 KiB
JavaScript
62 lines
1.7 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const { spawn, spawnSync } = require('node:child_process');
|
|
const { createInterface } = require('node:readline');
|
|
const assert = require('node:assert');
|
|
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
if (!common.isLinux)
|
|
common.skip('linux only');
|
|
if (common.isASan)
|
|
common.skip('strace does not work well with address sanitizer builds');
|
|
if (spawnSync('strace').error !== undefined) {
|
|
common.skip('missing strace');
|
|
}
|
|
|
|
{
|
|
const allowedOpenCalls = new Set([
|
|
'/etc/ssl/openssl.cnf',
|
|
]);
|
|
const strace = spawn('strace', [
|
|
'-f', '-ff',
|
|
'-e', 'trace=open,openat',
|
|
'-s', '512',
|
|
'-D', process.execPath, '-e', 'require("crypto")',
|
|
]);
|
|
|
|
// stderr is the default for strace
|
|
const rl = createInterface({ input: strace.stderr });
|
|
rl.on('line', (line) => {
|
|
if (!line.startsWith('open')) {
|
|
return;
|
|
}
|
|
|
|
const file = line.match(/"(.*?)"/)[1];
|
|
// skip .so reading attempt
|
|
if (file.match(/.+\.so(\.?)/) !== null) {
|
|
return;
|
|
}
|
|
// skip /proc/*
|
|
if (file.match(/\/proc\/.+/) !== null) {
|
|
return;
|
|
}
|
|
|
|
assert(allowedOpenCalls.delete(file), `${file} is not in the list of allowed openat calls`);
|
|
});
|
|
const debugOutput = [];
|
|
strace.stderr.setEncoding('utf8');
|
|
strace.stderr.on('data', (chunk) => {
|
|
debugOutput.push(chunk.toString());
|
|
});
|
|
strace.on('error', common.mustNotCall());
|
|
strace.on('exit', common.mustCall((code) => {
|
|
assert.strictEqual(code, 0, debugOutput);
|
|
const missingKeys = Array.from(allowedOpenCalls.keys());
|
|
if (missingKeys.length) {
|
|
assert.fail(`The following openat call are missing: ${missingKeys.join(',')}`);
|
|
}
|
|
}));
|
|
}
|