Skip to content

Commit 54cda96

Browse files
authored
fix(arborist): do not audit in offline mode (#4410)
1 parent 408d2fc commit 54cda96

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

workspaces/arborist/lib/audit-report.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ class AuditReport extends Map {
304304

305305
async [_getReport] () {
306306
// if we're not auditing, just return false
307-
if (this.options.audit === false || this.tree.inventory.size === 1) {
307+
if (this.options.audit === false || this.options.offline === true || this.tree.inventory.size === 1) {
308308
return null
309309
}
310310

workspaces/arborist/test/audit-report.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,24 @@ t.test('audit disabled by config', async t => {
260260
t.equal(report.error, null, 'no error encountered')
261261
})
262262

263+
t.test('audit disabled by offline mode', async t => {
264+
const path = resolve(fixtures, 'audit-nyc-mkdirp')
265+
266+
const logs = []
267+
const onlog = (...msg) => logs.push(msg)
268+
process.on('log', onlog)
269+
t.teardown(() => process.removeListener('log', onlog))
270+
271+
const arb = newArb(path, { offline: true })
272+
273+
const tree = await arb.loadVirtual()
274+
const report = await AuditReport.load(tree, arb.options)
275+
t.equal(report.report, null, 'did not get audit response')
276+
t.equal(report.size, 0, 'did not find any vulnerabilities')
277+
t.match(logs, [], 'no logs of error')
278+
t.equal(report.error, null, 'no error encountered')
279+
})
280+
263281
t.test('one vulnerability', async t => {
264282
const path = resolve(fixtures, 'audit-one-vuln')
265283
const auditFile = resolve(path, 'audit.json')

0 commit comments

Comments
 (0)