Class: Necropsy::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/necropsy/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root:, config_path: nil, analyzers: nil) ⇒ Runner

Returns a new instance of Runner.



7
8
9
10
11
# File 'lib/necropsy/runner.rb', line 7

def initialize(root:, config_path: nil, analyzers: nil)
  @root = File.expand_path(root)
  @config = Configuration.load(root: @root, path: config_path)
  @analyzers = analyzers
end

Instance Attribute Details

#analyzersObject (readonly)

Returns the value of attribute analyzers.



5
6
7
# File 'lib/necropsy/runner.rb', line 5

def analyzers
  @analyzers
end

#configObject (readonly)

Returns the value of attribute config.



5
6
7
# File 'lib/necropsy/runner.rb', line 5

def config
  @config
end

#rootObject (readonly)

Returns the value of attribute root.



5
6
7
# File 'lib/necropsy/runner.rb', line 5

def root
  @root
end

Instance Method Details

#analyzeObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/necropsy/runner.rb', line 13

def analyze
  project = Project.new(root: root, config: config)
  graph = CallGraph.new(project.scan_result, ambiguity_limit: config.ambiguity_limit)
  rta_results = []

  apply_entry_points(graph, project)
  configured_analyzers.each do |analyzer|
    graph.add_profile(analyzer.profile)
    result = analyzer.analyze(graph, project)
    graph.apply_result(result)
    rta_results << result if analyzer.profile.name == :rta
  end
  rta_results.each { |result| graph.reconcile_rta_result(result) }

  reachability = Reachability::Engine.new(graph).call
  findings = Confidence::Scorer.new(graph: graph, reachability: reachability, project: project).findings
  Report.new(
    root: root,
    graph: graph,
    findings: findings,
    reachability: reachability,
    report_include_paths: config.report_include_paths,
    report_exclude_paths: config.report_exclude_paths
  )
end