Skip to content

Commit 8ae4ad8

Browse files
Andras Tothdszakallas
authored andcommitted
fix(security): increase buffer size for npm ls outputs
1 parent 3cdb41f commit 8ae4ad8

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/agent/security/security.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ var uniq = require('lodash.uniq')
88
var inherits = require('util').inherits
99
var Agent = require('../agent')
1010

11+
var MAX_BUFFER = 1024 * 1024 // 1 mb
12+
1113
function Security (options) {
1214
this.collectorApi = options.collectorApi
1315
Agent.call(this, 'Security')
@@ -48,7 +50,9 @@ Security.prototype.collectSnykFlags = function collectSnykFlags (callback) {
4850
return patch.split(':')[1]
4951
})
5052

51-
childProcess.execFile('npm', ['ls'].concat(uniq(packageNames)).concat(['--parseable', '--long']), function (_error, stdout, stderr) {
53+
childProcess.execFile('npm', ['ls'].concat(uniq(packageNames)).concat(['--parseable', '--long']), {
54+
maxBuffer: MAX_BUFFER
55+
}, function (_error, stdout, stderr) {
5256
if (_error) {
5357
// ignore
5458
debug.error('collectSnykFlags',
@@ -110,9 +114,8 @@ Security.prototype.collectSnykFlags = function collectSnykFlags (callback) {
110114
}
111115

112116
Security.prototype.collectDependencies = function collectDependencies (callback) {
113-
var maxBuffer = 10 * 1024 * 1024 // 10mb
114117
childProcess.execFile('npm', ['ls', '--json', '--production'], {
115-
maxBuffer: maxBuffer
118+
maxBuffer: MAX_BUFFER
116119
}, function (error, stdout, stderr) {
117120
if (error) {
118121
// ignore

0 commit comments

Comments
 (0)