Class: FiberAudit::Finding

Inherits:
Data
  • Object
show all
Defined in:
lib/fiber_audit/findings/finding.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rule_id:, category:, severity:, confidence:, message:, title: nil, location: nil, symbol: nil, operation: nil, execution_context: nil, evidence: [], remediation: nil, fingerprint: nil) ⇒ Finding

Returns a new instance of Finding.



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
51
52
53
54
55
56
# File 'lib/fiber_audit/findings/finding.rb', line 19

def initialize(
  rule_id:,
  category:, severity:, confidence:, message:, title: nil,
  location: nil,
  symbol: nil,
  operation: nil,
  execution_context: nil,
  evidence: [],
  remediation: nil,
  fingerprint: nil
)
  severity = Severity.coerce(severity)
  confidence = Confidence.coerce(confidence)
  evidence = Array(evidence).freeze

  fingerprint ||= Correlation::Fingerprint.call(
    rule_id: rule_id,
    path: location&.path,
    enclosing_symbol: symbol,
    operation: operation
  )

  super(
    rule_id: rule_id,
    title: title,
    category: category,
    severity: severity,
    confidence: confidence,
    location: location,
    symbol: symbol,
    operation: operation,
    execution_context: execution_context,
    message: message,
    evidence: evidence,
    remediation: remediation,
    fingerprint: fingerprint
  )
end

Instance Attribute Details

#categoryObject (readonly)

Returns the value of attribute category

Returns:

  • (Object)

    the current value of category



4
5
6
# File 'lib/fiber_audit/findings/finding.rb', line 4

def category
  @category
end

#confidenceObject (readonly)

Returns the value of attribute confidence

Returns:

  • (Object)

    the current value of confidence



4
5
6
# File 'lib/fiber_audit/findings/finding.rb', line 4

def confidence
  @confidence
end

#evidenceObject (readonly)

Returns the value of attribute evidence

Returns:

  • (Object)

    the current value of evidence



4
5
6
# File 'lib/fiber_audit/findings/finding.rb', line 4

def evidence
  @evidence
end

#execution_contextObject (readonly)

Returns the value of attribute execution_context

Returns:

  • (Object)

    the current value of execution_context



4
5
6
# File 'lib/fiber_audit/findings/finding.rb', line 4

def execution_context
  @execution_context
end

#fingerprintObject (readonly)

Returns the value of attribute fingerprint

Returns:

  • (Object)

    the current value of fingerprint



4
5
6
# File 'lib/fiber_audit/findings/finding.rb', line 4

def fingerprint
  @fingerprint
end

#locationObject (readonly)

Returns the value of attribute location

Returns:

  • (Object)

    the current value of location



4
5
6
# File 'lib/fiber_audit/findings/finding.rb', line 4

def location
  @location
end

#messageObject (readonly)

Returns the value of attribute message

Returns:

  • (Object)

    the current value of message



4
5
6
# File 'lib/fiber_audit/findings/finding.rb', line 4

def message
  @message
end

#operationObject (readonly)

Returns the value of attribute operation

Returns:

  • (Object)

    the current value of operation



4
5
6
# File 'lib/fiber_audit/findings/finding.rb', line 4

def operation
  @operation
end

#remediationObject (readonly)

Returns the value of attribute remediation

Returns:

  • (Object)

    the current value of remediation



4
5
6
# File 'lib/fiber_audit/findings/finding.rb', line 4

def remediation
  @remediation
end

#rule_idObject (readonly)

Returns the value of attribute rule_id

Returns:

  • (Object)

    the current value of rule_id



4
5
6
# File 'lib/fiber_audit/findings/finding.rb', line 4

def rule_id
  @rule_id
end

#severityObject (readonly)

Returns the value of attribute severity

Returns:

  • (Object)

    the current value of severity



4
5
6
# File 'lib/fiber_audit/findings/finding.rb', line 4

def severity
  @severity
end

#symbolObject (readonly)

Returns the value of attribute symbol

Returns:

  • (Object)

    the current value of symbol



4
5
6
# File 'lib/fiber_audit/findings/finding.rb', line 4

def symbol
  @symbol
end

#titleObject (readonly)

Returns the value of attribute title

Returns:

  • (Object)

    the current value of title



4
5
6
# File 'lib/fiber_audit/findings/finding.rb', line 4

def title
  @title
end

Instance Method Details

#to_h_for_jsonObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/fiber_audit/findings/finding.rb', line 58

def to_h_for_json
  {
    rule_id: rule_id,
    title: title,
    category: category,
    severity: severity,
    confidence: confidence,
    location: location&.to_h_for_json,
    symbol: symbol,
    operation: operation,
    execution_context: execution_context,
    message: message,
    evidence: evidence.map(&:to_h_for_json),
    remediation: remediation,
    fingerprint: fingerprint
  }
end