Class: Bootprint::Rules::Finding

Inherits:
Struct
  • Object
show all
Defined in:
lib/bootprint/rules/finding.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#categoryObject

Returns the value of attribute category

Returns:

  • (Object)

    the current value of category



5
6
7
# File 'lib/bootprint/rules/finding.rb', line 5

def category
  @category
end

#causeObject

Returns the value of attribute cause

Returns:

  • (Object)

    the current value of cause



5
6
7
# File 'lib/bootprint/rules/finding.rb', line 5

def cause
  @cause
end

#evidenceObject

Returns the value of attribute evidence

Returns:

  • (Object)

    the current value of evidence



5
6
7
# File 'lib/bootprint/rules/finding.rb', line 5

def evidence
  @evidence
end

#impactObject

Returns the value of attribute impact

Returns:

  • (Object)

    the current value of impact



5
6
7
# File 'lib/bootprint/rules/finding.rb', line 5

def impact
  @impact
end

#metadataObject

Returns the value of attribute metadata

Returns:

  • (Object)

    the current value of metadata



5
6
7
# File 'lib/bootprint/rules/finding.rb', line 5

def 
  @metadata
end

#referencesObject

Returns the value of attribute references

Returns:

  • (Object)

    the current value of references



5
6
7
# File 'lib/bootprint/rules/finding.rb', line 5

def references
  @references
end

#remediationObject

Returns the value of attribute remediation

Returns:

  • (Object)

    the current value of remediation



5
6
7
# File 'lib/bootprint/rules/finding.rb', line 5

def remediation
  @remediation
end

#rule_idObject

Returns the value of attribute rule_id

Returns:

  • (Object)

    the current value of rule_id



5
6
7
# File 'lib/bootprint/rules/finding.rb', line 5

def rule_id
  @rule_id
end

#severityObject

Returns the value of attribute severity

Returns:

  • (Object)

    the current value of severity



5
6
7
# File 'lib/bootprint/rules/finding.rb', line 5

def severity
  @severity
end

#source_locationObject

Returns the value of attribute source_location

Returns:

  • (Object)

    the current value of source_location



5
6
7
# File 'lib/bootprint/rules/finding.rb', line 5

def source_location
  @source_location
end

#summaryObject

Returns the value of attribute summary

Returns:

  • (Object)

    the current value of summary



5
6
7
# File 'lib/bootprint/rules/finding.rb', line 5

def summary
  @summary
end

#suppressedObject

Returns the value of attribute suppressed

Returns:

  • (Object)

    the current value of suppressed



5
6
7
# File 'lib/bootprint/rules/finding.rb', line 5

def suppressed
  @suppressed
end

#suppression_reasonObject

Returns the value of attribute suppression_reason

Returns:

  • (Object)

    the current value of suppression_reason



5
6
7
# File 'lib/bootprint/rules/finding.rb', line 5

def suppression_reason
  @suppression_reason
end

#titleObject

Returns the value of attribute title

Returns:

  • (Object)

    the current value of title



5
6
7
# File 'lib/bootprint/rules/finding.rb', line 5

def title
  @title
end

Instance Method Details

#blocking?(policy) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/bootprint/rules/finding.rb', line 29

def blocking?(policy)
  !suppressed && policy.fail_on.include?(severity.to_s)
end

#localObject



35
# File 'lib/bootprint/rules/finding.rb', line 35

def local = evidence&.fetch("source", nil)

#messageObject



37
# File 'lib/bootprint/rules/finding.rb', line 37

def message = summary

#pathObject

Compatibility readers for 0.1 integrations.



34
# File 'lib/bootprint/rules/finding.rb', line 34

def path = &.fetch("path", nil) || source_location&.fetch("path", nil)

#targetObject



36
# File 'lib/bootprint/rules/finding.rb', line 36

def target = evidence&.fetch("target", nil)

#to_hObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/bootprint/rules/finding.rb', line 10

def to_h
  {
    "rule_id" => rule_id,
    "title" => title,
    "category" => category.to_s,
    "severity" => severity.to_s,
    "summary" => summary,
    "cause" => cause,
    "impact" => impact,
    "evidence" => evidence || {},
    "remediation" => remediation || {},
    "references" => references || [],
    "metadata" =>  || {},
    "source_location" => source_location,
    "suppressed" => !suppressed.nil?,
    "suppression_reason" => suppression_reason
  }.compact
end