Class: Section

Inherits:
Object
  • Object
show all
Includes:
DataMapper::Resource
Defined in:
models/section.rb

Overview

A single piece of information relating to a Vulnerability that has been found and logged

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods included from DataMapper::Resource

#make_dirty

Class Method Details

+ (String) body(repository = nil)

Returns Body of section (details of vuln). In case of SSHOT or PAYLOAD is B64 encoded file data. Max 12MB.

Returns:

  • (String)

    Body of section (details of vuln). In case of SSHOT or PAYLOAD is B64 encoded file data. Max 12MB.



16
# File 'models/section.rb', line 16

property :body, 				Text, :length => 1024*1024*12

+ (DateTime) created_at(repository = nil)

Returns Date/Time Section created (DM Handled)

Returns:

  • (DateTime)

    Date/Time Section created (DM Handled)



18
# File 'models/section.rb', line 18

property :created_at, 			DateTime

+ (String) fname(repository = nil)

Returns Original filename for SSHOT or PAYLOAD

Returns:

  • (String)

    Original filename for SSHOT or PAYLOAD



17
# File 'models/section.rb', line 17

property :fname,				String

+ (Integer) id(repository = nil)

Returns Primary Key

Returns:

  • (Integer)

    Primary Key



13
# File 'models/section.rb', line 13

property :id, 					Serial

+ (Integer) listOrder(repository = nil)

Returns Order in which to display (relative to other Sections on same Vulnerability)

Returns:

  • (Integer)

    Order in which to display (relative to other Sections on same Vulnerability)



21
# File 'models/section.rb', line 21

property :listOrder,			Integer, :default => 0

+ (Object) show(repository = nil)

Deprecated.

@return [Boolean] True if section should be shown



20
# File 'models/section.rb', line 20

property :show, 				Boolean, :default => true

+ (SECT_TYPE) type(repository = nil)

Returns Type of section from SECT_TYPE

Returns:



15
# File 'models/section.rb', line 15

property :type, 				Integer

+ (DateTime) updated_at(repository = nil)

Returns Date/Time Section last updated (DM Handled)

Returns:

  • (DateTime)

    Date/Time Section last updated (DM Handled)



19
# File 'models/section.rb', line 19

property :updated_at, 			DateTime

+ (Vulnerability) vulnerability(repository = nil)

Returns Vulnerability that this Section belongs to

Returns:



23
# File 'models/section.rb', line 23

belongs_to :vulnerability

+ (Integer) vulnerability_id(repository = nil)

Returns ID of Test the Vulnerability belongs to

Returns:

  • (Integer)

    ID of Test the Vulnerability belongs to



14
# File 'models/section.rb', line 14

property :vulnerability_id,  	Integer

Instance Method Details

- (String) body

Returns Body of section (details of vuln). In case of SSHOT or PAYLOAD is B64 encoded file data. Max 12MB.

Returns:

  • (String)

    Body of section (details of vuln). In case of SSHOT or PAYLOAD is B64 encoded file data. Max 12MB.



16
# File 'models/section.rb', line 16

property :body, 				Text, :length => 1024*1024*12

- (String) body=(value)

Returns Body of section (details of vuln). In case of SSHOT or PAYLOAD is B64 encoded file data. Max 12MB.

Returns:

  • (String)

    Body of section (details of vuln). In case of SSHOT or PAYLOAD is B64 encoded file data. Max 12MB.



16
# File 'models/section.rb', line 16

property :body, 				Text, :length => 1024*1024*12

- (DateTime) created_at

Returns Date/Time Section created (DM Handled)

Returns:

  • (DateTime)

    Date/Time Section created (DM Handled)



18
# File 'models/section.rb', line 18

property :created_at, 			DateTime

- (DateTime) created_at=(value)

Returns Date/Time Section created (DM Handled)

Returns:

  • (DateTime)

    Date/Time Section created (DM Handled)



18
# File 'models/section.rb', line 18

property :created_at, 			DateTime

- (String) edit_size

Get textarea edit size for UI

Returns:

  • (String)

    edit size for UI



41
42
43
44
45
46
47
# File 'models/section.rb', line 41

def edit_size
	if (self.type == SECT_TYPE::OUTPUT || self.type == SECT_TYPE::CODE || self.type == SECT_TYPE::NOTES)
		return "large"
	else
		return "small"
	end
end

- (String) fname

Returns Original filename for SSHOT or PAYLOAD

Returns:

  • (String)

    Original filename for SSHOT or PAYLOAD



17
# File 'models/section.rb', line 17

property :fname,				String

- (String) fname=(value)

Returns Original filename for SSHOT or PAYLOAD

Returns:

  • (String)

    Original filename for SSHOT or PAYLOAD



17
# File 'models/section.rb', line 17

property :fname,				String

- (String) html_formatted

Return the HTML formatted output of this section for use in export reports

Returns:

  • (String)

    HTML output



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'models/section.rb', line 52

def html_formatted
	return "" if self.type == SECT_TYPE::PAYLOAD

	v = self.vulnerability

	str = "<div id=\"section_#{self.id}\"><h4 class=\"sectHeader\">#{self.type_str}" 
	str += "</h4><div id=\"section_body_#{self.id}\" class=\"sectBody\">"

	if self.type == SECT_TYPE::SSHOT
		str += "<img src=\"data:image/png;base64,#{self.body}\" alt='Screenshot' style=\"max-width:870px;\" />"
	elsif self.type == SECT_TYPE::URL
		str += "#{Rack::Utils::escape_html(self.body)}"
	elsif self.type == SECT_TYPE::OUTPUT
		str += "<pre class=\"code\">\n"+Rack::Utils::escape_html(self.body)+"</pre>"
	elsif self.type == SECT_TYPE::CODE
		str += "<pre class=\"code\">\n"+Rack::Utils::escape_html(self.body)+"</pre>"
	elsif self.type == SECT_TYPE::NOTES
		str += "<pre>\n"+Rack::Utils::escape_html(self.body)+"</pre>"
	else
		str += "#{Rack::Utils::escape_html(self.body)}"
	end

	str += "</div></div>"
	str.force_encoding('UTF-8')

	return str
end

- (Integer) id

Returns Primary Key

Returns:

  • (Integer)

    Primary Key



13
# File 'models/section.rb', line 13

property :id, 					Serial

- (Integer) id=(value)

Returns Primary Key

Returns:

  • (Integer)

    Primary Key



13
# File 'models/section.rb', line 13

property :id, 					Serial

- (Integer) listOrder

Returns Order in which to display (relative to other Sections on same Vulnerability)

Returns:

  • (Integer)

    Order in which to display (relative to other Sections on same Vulnerability)



21
# File 'models/section.rb', line 21

property :listOrder,			Integer, :default => 0

- (Integer) listOrder=(value)

Returns Order in which to display (relative to other Sections on same Vulnerability)

Returns:

  • (Integer)

    Order in which to display (relative to other Sections on same Vulnerability)



21
# File 'models/section.rb', line 21

property :listOrder,			Integer, :default => 0

- (Object) show

Deprecated.

@return [Boolean] True if section should be shown



20
# File 'models/section.rb', line 20

property :show, 				Boolean, :default => true

- (Object) show=(value)

Deprecated.

@return [Boolean] True if section should be shown



20
# File 'models/section.rb', line 20

property :show, 				Boolean, :default => true

- (SECT_TYPE) type

Returns Type of section from SECT_TYPE

Returns:



15
# File 'models/section.rb', line 15

property :type, 				Integer

- (SECT_TYPE) type=(value)

Returns Type of section from SECT_TYPE

Returns:



15
# File 'models/section.rb', line 15

property :type, 				Integer

- (String) type_str

Get Human-readable string representing Section's type

Returns:

  • (String)

    Human-readable section type



28
29
30
31
32
33
34
35
36
# File 'models/section.rb', line 28

def type_str
	return "URL" if self.type == SECT_TYPE::URL
	return "File" if self.type == SECT_TYPE::FILE
	return "Screenshot" if self.type == SECT_TYPE::SSHOT
	return "Output" if self.type == SECT_TYPE::OUTPUT
	return "Code" if self.type == SECT_TYPE::CODE
	return "Notes" if self.type == SECT_TYPE::NOTES
	return "Payload" if self.type == SECT_TYPE::PAYLOAD
end

- (DateTime) updated_at

Returns Date/Time Section last updated (DM Handled)

Returns:

  • (DateTime)

    Date/Time Section last updated (DM Handled)



19
# File 'models/section.rb', line 19

property :updated_at, 			DateTime

- (DateTime) updated_at=(value)

Returns Date/Time Section last updated (DM Handled)

Returns:

  • (DateTime)

    Date/Time Section last updated (DM Handled)



19
# File 'models/section.rb', line 19

property :updated_at, 			DateTime

- (Vulnerability) vulnerability

Returns Vulnerability that this Section belongs to

Returns:



23
# File 'models/section.rb', line 23

belongs_to :vulnerability

- (Vulnerability) vulnerability=(resource)

Returns Vulnerability that this Section belongs to

Returns:



23
# File 'models/section.rb', line 23

belongs_to :vulnerability

- (Integer) vulnerability_id

Returns ID of Test the Vulnerability belongs to

Returns:

  • (Integer)

    ID of Test the Vulnerability belongs to



14
# File 'models/section.rb', line 14

property :vulnerability_id,  	Integer

- (Integer) vulnerability_id=(value)

Returns ID of Test the Vulnerability belongs to

Returns:

  • (Integer)

    ID of Test the Vulnerability belongs to



14
# File 'models/section.rb', line 14

property :vulnerability_id,  	Integer