Class: Dawn::Cli::Kb

Inherits:
Thor
  • Object
show all
Defined in:
lib/dawn/cli/dawn_cli.rb

Overview

This class is responsible for the “dawn kb” command and related subcommands.

Instance Method Summary collapse

Instance Method Details

#find(string) ⇒ Object



21
22
23
24
25
# File 'lib/dawn/cli/dawn_cli.rb', line 21

def find(string)
  init_globals
  kb = Dawn::KnowledgeBase.instance
  kb.find(string)
end

#lintObject



28
29
30
31
32
# File 'lib/dawn/cli/dawn_cli.rb', line 28

def lint
  init_globals
  kb = Dawn::KnowledgeBase.instance
  kb.load(true)
end

#list(gem_name, gem_version = nil) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/dawn/cli/dawn_cli.rb', line 63

def list(gem_name, gem_version=nil)
  init_globals
  to_check="#{gem_name}"
  to_check += ":#{gem_version}" unless gem_version.nil?

  Dawn::KnowledgeBase.enabled_checks=[:bulletin]
  kb = Dawn::KnowledgeBase.instance
  kb.load
  if kb.security_checks.empty?
    $logger.error(kb.error)
  end
  issues = kb.find_issues_by_gem(to_check)

  issues.each do |issue|
    puts "#{issue.name} "
  end
end

#statusObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/dawn/cli/dawn_cli.rb', line 45

def status
  init_globals
  $logger.helo APPNAME, Dawn::VERSION
  Dawn::KnowledgeBase.enabled_checks=[:bulletin, :generic_check]
  kb = Dawn::KnowledgeBase.instance
  kb.load
  if kb.security_checks.empty?
    $logger.error(kb.error)
  end
  $logger.info("" + kb.security_checks.count.to_s + " security checks loaded")
  if kb.is_packed?
    $logger.error "The knowledge base is packed. It must be unpacked with the 'unpack' command before it can be used"
  end
  $logger.bye
  Kernel.exit(0)
end

#unpackObject



35
36
37
38
39
40
41
42
# File 'lib/dawn/cli/dawn_cli.rb', line 35

def unpack
  init_globals
  $logger.helo APPNAME, Dawn::VERSION
  kb = Dawn::KnowledgeBase.instance
  kb.unpack
  $logger.bye
  Kernel.exit(0)
end