Module: RailVerdict::Repair::Verifier
- Defined in:
- lib/rail_verdict/repair/verifier.rb
Defined Under Namespace
Classes: Result
Class Method Summary collapse
Class Method Details
.verify(packet:, new_outcome:) ⇒ Object
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/rail_verdict/repair/verifier.rb', line 22 def self.verify(packet:, new_outcome:) packet_hash = packet.is_a?(Packet) ? packet.to_h : packet fingerprint = packet_hash.dig("target", "finding", "fingerprint") new_findings = new_outcome.findings || [] new_result = new_outcome.result if new_result&.incomplete? return Result.new( target_status: "incomplete", gate: new_result.gate, completion_status: new_result.completion_status, new_blocking_findings: new_result.findings.count { |f| f["blocking"] }, verification_boundary_changed: boundary_changed?(packet_hash, new_outcome), regressed: false ) end target_still = new_findings.find { |f| f.fingerprint == fingerprint } target_status = if target_still.nil? changed = new_findings.find { |f| f.location["path"] == packet_hash.dig("target", "finding", "location", "path") && f.analyzer == packet_hash.dig("target", "finding", "analyzer") && f.rule_id == packet_hash.dig("target", "finding", "rule_id") } if changed changed. == packet_hash.dig("target", "finding", "message") ? "moved" : "changed" else "fixed" end else "still_present" end boundary = boundary_changed?(packet_hash, new_outcome) blocking_now = new_result.findings.count { |f| f["blocking"] } old_blocking = packet_hash.dig("verification", "comparison_counts") || {} regressed = blocking_now > 0 && target_status == "fixed" res = Result.new( target_status: target_status, gate: new_result.gate, completion_status: new_result.completion_status, new_blocking_findings: blocking_now, verification_boundary_changed: boundary, regressed: regressed ) res[:overall_status] = res.overall_status res end |