Class: Necropsy::Analyzers::Dynamic::CoverbandImporter

Inherits:
Necropsy::Analyzer show all
Defined in:
lib/necropsy/analyzers/dynamic/coverband_importer.rb

Instance Method Summary collapse

Methods inherited from Necropsy::Analyzer

#capabilities

Constructor Details

#initialize(config) ⇒ CoverbandImporter

Returns a new instance of CoverbandImporter.



13
14
15
# File 'lib/necropsy/analyzers/dynamic/coverband_importer.rb', line 13

def initialize(config)
  @config = config || {}
end

Instance Method Details

#analyze(graph, project) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/necropsy/analyzers/dynamic/coverband_importer.rb', line 17

def analyze(graph, project)
  source = config['source']
  return AnalyzerResult.empty unless source

  payload = load_payload(source, project.root)
  observation = ObservationPolicy.(payload, expected_revision: config['expected_source_revision'])
  node_ids, line_diagnostics = alive_ids_from_payload(graph, payload)
  observation = observation.merge(line_diagnostics) unless line_diagnostics.empty?
  alive = node_ids.map do |node_id|
    node = graph.nodes.lookup(node_id).node
    details = node ? "Coverband executed #{node.file}:#{node.line}" : "Coverband marked #{node_id} as executed"
    AliveEvidence.new(
      node_id: node_id,
      evidence: evidence(
        kind: :alive,
        details: details,
        metadata: observation.merge('node_reference' => node_id),
        grade: :observed,
        relation: :execution,
        source: { 'type' => 'coverband', 'node_reference' => node_id },
        scope: ObservationPolicy.evidence_scope(observation).merge('node_reference' => node_id)
      )
    )
  end

  AnalyzerResult.new(
    edge_evidences: [],
    alive_evidences: alive,
    uncertainties: {},
    observation: { 'coverband' => observation },
    resolutions: [],
    evidences: result_evidences(alive)
  )
end

#profileObject



52
53
54
55
56
57
58
59
60
61
# File 'lib/necropsy/analyzers/dynamic/coverband_importer.rb', line 52

def profile
  AnalyzerProfile.new(
    name: :coverband,
    kind: :dynamic,
    soundness: :observational,
    description: 'Imports file and line execution data compatible with coverband-style exports.',
    version: Necropsy::VERSION,
    assumptions: %w[line_execution_mapping positive_observations_only]
  )
end