| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -45,6 +45,7 @@ jobs: | |||
| 45 | 45 | CXX: clang++ | |
| 46 | 46 | LINK: clang++ | |
| 47 | 47 | CONFIG_FLAGS: --enable-asan | |
| 48 | + ASAN: true | ||
| 48 | 49 | steps: | |
| 49 | 50 | - uses: actions/checkout@v3 | |
| 50 | 51 | with: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -120,6 +120,7 @@ const isFreeBSD = process.platform === 'freebsd'; | |||
| 120 | 120 | const isOpenBSD = process.platform === 'openbsd'; | |
| 121 | 121 | const isLinux = process.platform === 'linux'; | |
| 122 | 122 | const isOSX = process.platform === 'darwin'; | |
| 123 | + const isAsan = process.env.ASAN !== undefined; | ||
| 123 | 124 | const isPi = (() => { | |
| 124 | 125 | try { | |
| 125 | 126 | // Normal Raspberry Pi detection is to find the `Raspberry Pi` string in | |
@@ -900,6 +901,7 @@ const common = { | |||
| 900 | 901 | invalidArgTypeHelper, | |
| 901 | 902 | isAIX, | |
| 902 | 903 | isAlive, | |
| 904 | + isAsan, | ||
| 903 | 905 | isDumbTerminal, | |
| 904 | 906 | isFreeBSD, | |
| 905 | 907 | isLinux, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,61 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const { spawn, spawnSync } = require('node:child_process'); | ||
| 5 | + const { createInterface } = require('node:readline'); | ||
| 6 | + const assert = require('node:assert'); | ||
| 7 | + | ||
| 8 | + if (!common.hasCrypto) | ||
| 9 | + common.skip('missing crypto'); | ||
| 10 | + if (!common.isLinux) | ||
| 11 | + common.skip('linux only'); | ||
| 12 | + if (common.isAsan) | ||
| 13 | + common.skip('strace does not work well with address sanitizer builds'); | ||
| 14 | + if (spawnSync('strace').error !== undefined) { | ||
| 15 | + common.skip('missing strace'); | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + { | ||
| 19 | + const allowedOpenCalls = new Set([ | ||
| 20 | + '/etc/ssl/openssl.cnf', | ||
| 21 | + ]); | ||
| 22 | + const strace = spawn('strace', [ | ||
| 23 | + '-f', '-ff', | ||
| 24 | + '-e', 'trace=open,openat', | ||
| 25 | + '-s', '512', | ||
| 26 | + '-D', process.execPath, '-e', 'require("crypto")', | ||
| 27 | + ]); | ||
| 28 | + | ||
| 29 | + // stderr is the default for strace | ||
| 30 | + const rl = createInterface({ input: strace.stderr }); | ||
| 31 | + rl.on('line', (line) => { | ||
| 32 | + if (!line.startsWith('open')) { | ||
| 33 | + return; | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + const file = line.match(/"(.*?)"/)[1]; | ||
| 37 | + // skip .so reading attempt | ||
| 38 | + if (file.match(/.+\.so(\.?)/) !== null) { | ||
| 39 | + return; | ||
| 40 | + } | ||
| 41 | + // skip /proc/* | ||
| 42 | + if (file.match(/\/proc\/.+/) !== null) { | ||
| 43 | + return; | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + assert(allowedOpenCalls.delete(file), `${file} is not in the list of allowed openat calls`); | ||
| 47 | + }); | ||
| 48 | + const debugOutput = []; | ||
| 49 | + strace.stderr.setEncoding('utf8'); | ||
| 50 | + strace.stderr.on('data', (chunk) => { | ||
| 51 | + debugOutput.push(chunk.toString()); | ||
| 52 | + }); | ||
| 53 | + strace.on('error', common.mustNotCall()); | ||
| 54 | + strace.on('exit', common.mustCall((code) => { | ||
| 55 | + assert.strictEqual(code, 0, debugOutput); | ||
| 56 | + const missingKeys = Array.from(allowedOpenCalls.keys()); | ||
| 57 | + if (missingKeys.length) { | ||
| 58 | + assert.fail(`The following openat call are missing: ${missingKeys.join(',')}`); | ||
| 59 | + } | ||
| 60 | + })); | ||
| 61 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments