Class: Glue::Finding

Inherits:
Object
  • Object
show all
Defined in:
lib/glue/finding.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(appname, description, detail, source, severity, fingerprint) ⇒ Finding

Returns a new instance of Finding.



12
13
14
15
16
17
18
19
20
21
# File 'lib/glue/finding.rb', line 12

def initialize appname, description, detail, source, severity, fingerprint
	@appname = appname
      @timestamp = Time.now
	@description = description
	@detail = detail
	@source = source
      @stringsrc = source.to_s
	@severity = severity
      @fingerprint = fingerprint
end

Instance Attribute Details

#appnameObject (readonly)

Returns the value of attribute appname.



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

def appname
  @appname
end

#descriptionObject (readonly)

Returns the value of attribute description.



8
9
10
# File 'lib/glue/finding.rb', line 8

def description
  @description
end

#detailObject (readonly)

Returns the value of attribute detail.



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

def detail
  @detail
end

#fingerprintObject (readonly)

Returns the value of attribute fingerprint.



10
11
12
# File 'lib/glue/finding.rb', line 10

def fingerprint
  @fingerprint
end

#severityObject (readonly)

Returns the value of attribute severity.



6
7
8
# File 'lib/glue/finding.rb', line 6

def severity
  @severity
end

#sourceObject (readonly)

Returns the value of attribute source.



7
8
9
# File 'lib/glue/finding.rb', line 7

def source
  @source
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



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

def timestamp
  @timestamp
end

Instance Method Details

#to_csvObject



34
35
36
37
# File 'lib/glue/finding.rb', line 34

def to_csv
  s = "#{@appname},#{@description},#{@timestamp},#{@source.to_s},#{@severity},#{@fingerprint},#{@detail}\n"
  s
end

#to_jsonObject



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/glue/finding.rb', line 39

def to_json
  json = {
   'appname' => @appname,
   'description' => @description,
   'fingerprint' => @fingerprint,
   'detail' => @detail,
   'source' => @source,
   'severity' => @severity,
   'timestamp' => @timestamp
  }.to_json
  json
end

#to_stringObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/glue/finding.rb', line 23

def to_string
	s = "Finding: #{@appname}"
      s << "\n\tDescription: #{@description}"
      s << "\n\tTimestamp: #{@timestamp}"
      s << "\n\tSource: #{@stringsrc}"
      s << "\n\tSeverity: #{@severity}"
	s << "\n\tFingerprint:  #{@fingerprint}"
      s << "\n\tDetail:  #{@detail}"
	s
end