Class: Hashira::Analysis::Finding

Inherits:
Data
  • Object
show all
Defined in:
lib/hashira/analysis/finding.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cycle: nil, digest: nil, detail: nil, **rest) ⇒ Finding

Returns a new instance of Finding.



11
# File 'lib/hashira/analysis/finding.rb', line 11

def initialize(cycle: nil, digest: nil, detail: nil, **rest) = super

Instance Attribute Details

#cycleObject (readonly)

Returns the value of attribute cycle

Returns:

  • (Object)

    the current value of cycle



9
10
11
# File 'lib/hashira/analysis/finding.rb', line 9

def cycle
  @cycle
end

#detailObject (readonly)

Returns the value of attribute detail

Returns:

  • (Object)

    the current value of detail



9
10
11
# File 'lib/hashira/analysis/finding.rb', line 9

def detail
  @detail
end

#digestObject (readonly)

Returns the value of attribute digest

Returns:

  • (Object)

    the current value of digest



9
10
11
# File 'lib/hashira/analysis/finding.rb', line 9

def digest
  @digest
end

#evidenceObject (readonly)

Returns the value of attribute evidence

Returns:

  • (Object)

    the current value of evidence



9
10
11
# File 'lib/hashira/analysis/finding.rb', line 9

def evidence
  @evidence
end

#kindObject (readonly)

Returns the value of attribute kind

Returns:

  • (Object)

    the current value of kind



9
10
11
# File 'lib/hashira/analysis/finding.rb', line 9

def kind
  @kind
end

#packageObject (readonly)

Returns the value of attribute package

Returns:

  • (Object)

    the current value of package



9
10
11
# File 'lib/hashira/analysis/finding.rb', line 9

def package
  @package
end

Instance Method Details

#identityObject



17
# File 'lib/hashira/analysis/finding.rb', line 17

def identity = digest || package

#magnitudeObject



15
# File 'lib/hashira/analysis/finding.rb', line 15

def magnitude = detail.to_h[MAGNITUDES[kind]]

#plain(text) ⇒ Object



25
# File 'lib/hashira/analysis/finding.rb', line 25

def plain(text) = TRACKS.reduce(text) { |left, mark| left.gsub(mark, "") }

#signatureObject



13
# File 'lib/hashira/analysis/finding.rb', line 13

def signature = "#{kind}:#{identity}"

#siteObject



23
# File 'lib/hashira/analysis/finding.rb', line 23

def site = detail.to_h[:site].to_s

#to_hObject



27
# File 'lib/hashira/analysis/finding.rb', line 27

def to_h = super.merge(detail: detail&.to_h).compact

#traceObject



19
20
21
# File 'lib/hashira/analysis/finding.rb', line 19

def trace
  "#{kind}|#{plain(site)}|#{evidence.map { plain(it) }.join(";")}" unless digest
end