Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(arborist): do not audit in offline mode #4410

Merged
merged 1 commit into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion workspaces/arborist/lib/audit-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ class AuditReport extends Map {

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

Expand Down
18 changes: 18 additions & 0 deletions workspaces/arborist/test/audit-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,24 @@ t.test('audit disabled by config', async t => {
t.equal(report.error, null, 'no error encountered')
})

t.test('audit disabled by offline mode', async t => {
const path = resolve(fixtures, 'audit-nyc-mkdirp')

const logs = []
const onlog = (...msg) => logs.push(msg)
process.on('log', onlog)
t.teardown(() => process.removeListener('log', onlog))

const arb = newArb(path, { offline: true })

const tree = await arb.loadVirtual()
const report = await AuditReport.load(tree, arb.options)
t.equal(report.report, null, 'did not get audit response')
t.equal(report.size, 0, 'did not find any vulnerabilities')
t.match(logs, [], 'no logs of error')
t.equal(report.error, null, 'no error encountered')
})

t.test('one vulnerability', async t => {
const path = resolve(fixtures, 'audit-one-vuln')
const auditFile = resolve(path, 'audit.json')
Expand Down