Class: Bundler::Audit::Task

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/bundler/audit/task.rb

Overview

Defines the bundle:audit rake tasks.

Defined Under Namespace

Classes: CommandNotFound

Instance Method Summary collapse

Constructor Details

#initializeTask

Initializes the task.



15
16
17
# File 'lib/bundler/audit/task.rb', line 15

def initialize
  define
end

Instance Method Details

#bundler_audit(*arguments) ⇒ true (protected)

Note:

If the bundler-audit command exits with an error, the rake task will also exit with the same error code.

Runs the bundler-audit command with the additional arguments.

Parameters:

  • arguments (Array<String>)

    Additional command-line arguments for bundler-audit.

Returns:

  • (true)

    The bundler-audit command successfully exited.

Raises:

  • (CommandNotFound)

    The bundler-audit command could not be executed or was not found.



62
63
64
65
66
67
68
69
70
71
# File 'lib/bundler/audit/task.rb', line 62

def bundler_audit(*arguments)
  case system('bundler-audit',*arguments)
  when false
    exit $?.exitstatus || 1
  when nil
    raise(CommandNotFound,"bundler-audit could not be executed")
  else
    return true
  end
end

#defineObject (protected)

Defines the bundle:audit and bundle:audit:update task.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/bundler/audit/task.rb', line 24

def define
  namespace :bundle do
    namespace :audit do
      desc 'Checks the Gemfile.lock for insecure dependencies'
      task :check do
        bundler_audit 'check'
      end

      desc 'Updates the bundler-audit vulnerability database'
      task :update do
        bundler_audit 'update'
      end
    end

    task :audit => 'audit:check'
  end

  task 'bundler:audit'        => 'bundle:audit'
  task 'bundler:audit:check'  => 'bundle:audit:check'
  task 'bundler:audit:update' => 'bundle:audit:update'
end