rubysec / bundler-audit

Patch-level verification for Bundler
GNU General Public License v3.0
2.68k stars 228 forks source link

Can no longer be called programatically #352

Closed nello closed 2 years ago

nello commented 2 years ago

Attempting to use as per this (2015) documentation: http://caseywest.com/run-bundle-audit-from-rake/

Now calling Bundler::Audit::CLI.new.check fails to report anything, but just says "Unknown format:".

It looks like somewhere along the line, default formatting has stopped working. Is there any way to do this now?

postmodern commented 2 years ago

That error is likely due to how Thor (which Bundler::Audit::CLI uses) doesn't initialize default values for options when you directly initialize the Thor sub-class object.

There is now a rake task you can use directly in the Rakefile.

require 'bundler/audit/task'
Bundler::Audit::Task.new
nello commented 2 years ago

The rake task just calls system('...'). Are you saying there is now no way to invoke the application programatically directly?

postmodern commented 2 years ago

I did not say that. If you want to invoke bundle-audit programmatically (which is not recommended, because it is a CLI util, not a library), then see the API documentation. It is not recommended to directly invoke Bundler::Audit::CLI as it is a Thor app, and cannot simply be initialized with .new. If you need to automate bundler-audit then simply use the rake tasks provided by bundler/audit/task or write your own rake tasks which invoke system('bundle-audit', ...) with specific arguments.

postmodern commented 2 years ago

btw the way you are supposed to invoke Thor apps directly is via the .start(["arg1", ...]) method, if that helps. The .start method does additional initialization beyond what .new does.

nello commented 2 years ago

Thanks