diff --git a/lib/instrumentation-security/hooks/fs/nr-fs.js b/lib/instrumentation-security/hooks/fs/nr-fs.js index 0ae06066..40cd24d9 100644 --- a/lib/instrumentation-security/hooks/fs/nr-fs.js +++ b/lib/instrumentation-security/hooks/fs/nr-fs.js @@ -35,6 +35,12 @@ const functionsProbableToFA = [ "readdir", "readlink", "realpath", + "stat", + "statSync", + "access", + "accessSync", + "exists", + "existsSync" ]; const functionProbableToFI = [ @@ -64,6 +70,7 @@ const promiseFunctionsProbableToFA = [ "readFile", "lstat", "stat", + "access" ]; const promiseFunctionProbableToFI = [ diff --git a/test/instrumentation-security/nr-fs.test.js b/test/instrumentation-security/nr-fs.test.js index e5071516..aebd4fce 100755 --- a/test/instrumentation-security/nr-fs.test.js +++ b/test/instrumentation-security/nr-fs.test.js @@ -194,6 +194,57 @@ test('FS', (t) => { t.equal(__dirname + '/test1.txt', shim.interceptedArgs[0]); t.end() }) + + t.test('stat', (t) => { + fs.stat(fileName, function (err, stats) { + t.ok(shim.interceptedArgs) + t.equal(1, shim.interceptedArgs.length) + t.equal(fileName, shim.interceptedArgs[0]) + t.end() + }); + }) + + t.test('access', (t) => { + fs.stat(fileName, function (err, stats) { + t.ok(shim.interceptedArgs) + t.equal(1, shim.interceptedArgs.length) + t.equal(fileName, shim.interceptedArgs[0]) + t.end() + }); + }) + + t.test('exists', (t) => { + fs.stat(fileName, function (err, stats) { + t.ok(shim.interceptedArgs) + t.equal(1, shim.interceptedArgs.length) + t.equal(fileName, shim.interceptedArgs[0]) + t.end() + }); + }) + + t.test('statSync', (t) => { + fs.existsSync(fileName) + t.ok(shim.interceptedArgs) + t.equal(1, shim.interceptedArgs.length) + t.equal(fileName, shim.interceptedArgs[0]) + t.end() + }) + + t.test('accessSync', (t) => { + fs.existsSync(fileName) + t.ok(shim.interceptedArgs) + t.equal(1, shim.interceptedArgs.length) + t.equal(fileName, shim.interceptedArgs[0]) + t.end() + }) + + t.test('existsSync', (t) => { + fs.existsSync(fileName) + t.ok(shim.interceptedArgs) + t.equal(1, shim.interceptedArgs.length) + t.equal(fileName, shim.interceptedArgs[0]) + t.end() + }) })