Class: Necropsy::Runner
- Inherits:
-
Object
- Object
- Necropsy::Runner
- Defined in:
- lib/necropsy/runner.rb
Constant Summary collapse
- ANALYZER_ERROR_MESSAGE_BYTES =
500- INVALID_BLOCKER_KINDS =
%i[ analyzer_failure blocker_invalid evidence_collision rails_route_health resolution_invalid unsound_rta_pruning ].freeze
- DEGRADED_BLOCKER_KINDS =
%i[ reference_scan_incomplete reference_scope_incomplete source_discovery_incomplete ].freeze
Instance Attribute Summary collapse
-
#analyzers ⇒ Object
readonly
Returns the value of attribute analyzers.
-
#clock ⇒ Object
readonly
Returns the value of attribute clock.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#ignored_reference_paths ⇒ Object
readonly
Returns the value of attribute ignored_reference_paths.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #analyze(rta_pruning: config.rta_pruning, profile: false) ⇒ Object
-
#initialize(root:, config_path: nil, analyzers: nil, ignored_reference_paths: [], as_of: nil) ⇒ Runner
constructor
A new instance of Runner.
Constructor Details
#initialize(root:, config_path: nil, analyzers: nil, ignored_reference_paths: [], as_of: nil) ⇒ Runner
Returns a new instance of Runner.
17 18 19 20 21 22 23 |
# File 'lib/necropsy/runner.rb', line 17 def initialize(root:, config_path: nil, analyzers: nil, ignored_reference_paths: [], as_of: nil) @root = File.(root) @config = Configuration.load(root: @root, path: config_path) @analyzers = analyzers @ignored_reference_paths = ignored_reference_paths @clock = Clock.new(as_of: as_of) end |
Instance Attribute Details
#analyzers ⇒ Object (readonly)
Returns the value of attribute analyzers.
15 16 17 |
# File 'lib/necropsy/runner.rb', line 15 def analyzers @analyzers end |
#clock ⇒ Object (readonly)
Returns the value of attribute clock.
15 16 17 |
# File 'lib/necropsy/runner.rb', line 15 def clock @clock end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
15 16 17 |
# File 'lib/necropsy/runner.rb', line 15 def config @config end |
#ignored_reference_paths ⇒ Object (readonly)
Returns the value of attribute ignored_reference_paths.
15 16 17 |
# File 'lib/necropsy/runner.rb', line 15 def ignored_reference_paths @ignored_reference_paths end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
15 16 17 |
# File 'lib/necropsy/runner.rb', line 15 def root @root end |
Instance Method Details
#analyze(rta_pruning: config.rta_pruning, profile: false) ⇒ Object
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/necropsy/runner.rb', line 25 def analyze(rta_pruning: config.rta_pruning, profile: false) rta_pruning = normalize_rta_pruning(rta_pruning) profiler = profile ? PerformanceProfiler.new : nil project = measure_phase(profiler, 'project') { Project.new(root: root, config: config) } source_snapshot = measure_phase(profiler, 'source_snapshot') { project.source_snapshot } graph = measure_phase(profiler, 'scan') do CallGraph.new(project.scan_result, ambiguity_limit: config.ambiguity_limit) end project.scope_blockers.each { |blocker| graph.add_blocker(blocker) } graph.add_blocker(unsound_rta_pruning_blocker) if rta_pruning == :legacy rta_results = [] measure_phase(profiler, 'entry_points') { apply_entry_points(graph, project) } configured_analyzers.each do |configured_analyzer| analyzer_name = configured_analyzer.profile.name analyzer_profile, result = measure_phase(profiler, "analyzer:#{analyzer_name}") do run_analyzer(graph, project, configured_analyzer, rta_pruning) end rta_results << result if analyzer_profile&.name == :rta && result end graph.refresh_derived_state measure_phase(profiler, 'reachability') do rta_results.each { |result| graph.reconcile_rta_result(result) } if rta_pruning == :legacy end reachability = measure_phase(profiler, 'reachability_engine') { Reachability::Engine.new(graph).call } LoadGraph.record_unrooted_units(graph: graph, reachability: reachability) findings = measure_phase(profiler, 'scoring') do scorer = Confidence::Scorer.new(graph: graph, reachability: reachability, project: project, clock: clock) scorer.findings end = measure_phase(profiler, 'reference_barrier') do ReferenceBarrier.new( graph: graph, project: project, ignored_paths: ignored_reference_paths ).apply(findings) end if .positive? findings = Confidence::Scorer.new( graph: graph, reachability: reachability, project: project, clock: clock ).findings end final_source_snapshot = measure_phase(profiler, 'source_snapshot_verification') { project.fresh_source_snapshot } analysis_health = build_analysis_health(graph, source_snapshot, final_source_snapshot) source_snapshot = verified_source_snapshot(source_snapshot, final_source_snapshot) performance = profiler&.report( counts: graph.performance_counts, report_index_size_bytes: report_index_size_bytes(graph) ) Report.new( root: root, graph: graph, findings: findings, reachability: reachability, project: project, source_snapshot: source_snapshot, analysis_health: analysis_health, report_include_paths: config.report_include_paths, report_exclude_paths: config.report_exclude_paths, performance_profile: performance ) end |