Class: Vtk::Commands::Scan::Repo

Inherits:
Vtk::Command show all
Defined in:
lib/vtk/commands/scan/repo.rb

Overview

Scan a repository for compromised packages and backdoor workflows Shells out to shai-hulud-repo-check.sh for the actual scanning

Constant Summary collapse

OPTION_FLAGS =
{
  refresh: '--refresh',
  json: '--json',
  quiet: '--quiet',
  verbose: '--verbose',
  recursive: '--recursive'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Vtk::Command

#command, #cursor, #editor, #exec_exist?, #generator, #pager, #platform, #prompt, #screen, #which

Constructor Details

#initialize(path, options) ⇒ Repo

Returns a new instance of Repo.



22
23
24
25
26
# File 'lib/vtk/commands/scan/repo.rb', line 22

def initialize(path, options)
  @path = path || Dir.pwd
  @options = options
  super()
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



20
21
22
# File 'lib/vtk/commands/scan/repo.rb', line 20

def options
  @options
end

#pathObject (readonly)

Returns the value of attribute path.



20
21
22
# File 'lib/vtk/commands/scan/repo.rb', line 20

def path
  @path
end

Instance Method Details

#execute(output: $stdout) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/vtk/commands/scan/repo.rb', line 28

def execute(output: $stdout)
  @output = output

  unless File.directory?(@path)
    output.puts "ERROR: Directory not found: #{@path}"
    return 1
  end

  script_path, gem_root = find_script
  return script_not_found(output, gem_root) unless script_path

  run_script(script_path)
end