Class: VRLinkedObject

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

Overview

VRLinkedObject is the parent class for custom links between Applications and external systems.

An Application RecordType can be set as a linked record type, at which point it can specify a VRLinkedObject to utilize. This subclass specifies the type of Entity ID to link to, the generation of linked information to display on the single_app view, and actions to take on the external system when a Test related to the Application in Vulnreport changes status.

Class Method Summary (collapse)

Class Method Details

+ (Object) doAppReassignedActions(app, uid, newOwnerUid)

Called after an Application of a RecordType linked to this object is set to a new owner

Parameters:

  • app (Application)

    The Application object being updated

  • uid (Integer)

    ID of the User who performed the action

  • newOwnerUid (Integer)

    ID of the User who is the new owner



94
95
96
# File 'lib/VRLinkedObject.rb', line 94

def doAppReassignedActions(app, uid, newOwnerUid)
	raise "NotImplemented"
end

+ (Hash) doCreateAppActions(app, uid)

Called after an Application of a RecordType linked to this object is created.

Parameters:

Returns:

  • (Hash)
    • Hash of :success - Boolean and :alerts - Array of alert messages. Each element is a hash of :color, :html



85
86
87
# File 'lib/VRLinkedObject.rb', line 85

def doCreateAppActions(app, uid)
	raise "NotImplemented"
end

+ (Hash) doDeleteAppActions(app, uid)

Called when a Application is deleted

Parameters:

Returns:

  • (Hash)
    • Hash of :success - Boolean and :errstr if failed



153
154
155
# File 'lib/VRLinkedObject.rb', line 153

def doDeleteAppActions(app, uid)
	raise "NotImplemented"
end

+ (Hash) doFailActions(app, test, uid)

Called when a Test is marked failed on an Application of a RecordType linked to this object.

Parameters:

Returns:

  • (Hash)
    • Hash of :success - Boolean and :alerts - Array of alert messages. Each element is a hash of :color, :html



144
145
146
# File 'lib/VRLinkedObject.rb', line 144

def doFailActions(app, test, uid)
	raise "NotImplemented"
end

+ (Hash) doInProgressActions(app, test, uid)

Called when an existing Test is put in progress on an Application of a RecordType linked to this object.

Parameters:

  • app (Application)

    The Application object being updated

  • test (Test)

    The newly created/in progress Test object

  • uid (Integer)

    ID of the User who performed the action

Returns:

  • (Hash)
    • Hash of :success - Boolean and :alerts - Array of alert messages. Each element is a hash of :color, :html



114
115
116
# File 'lib/VRLinkedObject.rb', line 114

def doInProgressActions(app, test, uid)
	raise "NotImplemented"
end

+ (Hash) doNewTestActions(app, test, uid)

Called when a Test is created/put in progress on an Application of a RecordType linked to this object.

Parameters:

  • app (Application)

    The Application object being updated

  • test (Test)

    The newly created/in progress Test object

  • uid (Integer)

    ID of the User who performed the action

Returns:

  • (Hash)
    • Hash of :success - Boolean and :alerts - Array of alert messages. Each element is a hash of :color, :html



104
105
106
# File 'lib/VRLinkedObject.rb', line 104

def doNewTestActions(app, test, uid)
	raise "NotImplemented"
end

+ (Hash) doPassActions(app, test, uid)

Called when a Test is marked passed on an Application of a RecordType linked to this object.

Parameters:

Returns:

  • (Hash)
    • Hash of :success - Boolean and :alerts - Array of alert messages. Each element is a hash of :color, :html



124
125
126
# File 'lib/VRLinkedObject.rb', line 124

def doPassActions(app, test, uid)
	raise "NotImplemented"
end

+ (Hash) doProvPassActions(app, test, uid)

Called when a Test is marked provisionally passed on an Application of a RecordType linked to this object.

Parameters:

Returns:

  • (Hash)
    • Hash of :success - Boolean and :alerts - Array of alert messages. Each element is a hash of :color, :html



134
135
136
# File 'lib/VRLinkedObject.rb', line 134

def doProvPassActions(app, test, uid)
	raise "NotImplemented"
end

+ (Array <Hash>) doSearch(q)

Called by Vulnreport when a system-wide search is initiated (from /search) that includes a RecordType. that links to this Linked Object. If specific results or additional results based on the linked object should be returned in the search results they can be via this method.

Returns:

  • (Array <Hash>)

    Array of results, each element is a hash with keys :text and :link



184
185
186
# File 'lib/VRLinkedObject.rb', line 184

def doSearch(q)
	raise "NotImplemented"
end

+ (Object) each(&block)



36
37
38
39
40
# File 'lib/VRLinkedObject.rb', line 36

def each(&block)
	objs.each do |member|
		block.call(member)
	end
end

+ (Object) getByKey(key)



42
43
44
45
46
47
48
49
50
# File 'lib/VRLinkedObject.rb', line 42

def getByKey(key)
	objs.each do |obj|
		if(obj.vrlo_key == key)
			return obj
		end
	end

	return nil
end

+ (Hash) getLinkedObjectInfoPanel(app, uid, params, env)

Called when loading the single_app view of an Application of a RecordType linked to this object. Generates the linked object information panel for the view as well as any error/alert messages to display above the nav breadcrumbs.

Parameters:

  • app (Application)

    The Application object being loaded

  • uid (Integer)

    The ID of the User calling the page

  • params (Hash)

    The params from the Sinatra page load is passed

  • env (Hash)

    The Sinatra request environment is passed

Returns:

  • (Hash)

    Hash of :success - Boolean, :errstr - String of error text if success is false, :infoPanelHtml - HTML for the info panel and :alerts - Array of alert messages where each element is a hash of :color, :html, :customMenuItems - Array of menu items where each element is a hash of :icon, :text, :href, :authMethods, :isDropdown, :dropdownOpts (Array of hashes - :href and :text)



63
64
65
# File 'lib/VRLinkedObject.rb', line 63

def getLinkedObjectInfoPanel(app, uid, params, env)
	raise "NotImplemented"
end

+ (String) getLinkedObjectText(app)

Returns The name or text representation of the object that this application is linked to.

Returns:

  • (String)

    The name or text representation of the object that this application is linked to.



159
160
161
# File 'lib/VRLinkedObject.rb', line 159

def getLinkedObjectText(app)
	raise "NotImplemented"
end

+ (String) getLinkedObjectURL(app)

Returns The URL of the object that this application is linked to.

Returns:

  • (String)

    The URL of the object that this application is linked to.



165
166
167
# File 'lib/VRLinkedObject.rb', line 165

def getLinkedObjectURL(app)
	raise "NotImplemented"
end

+ (Hash) getTestAlerts(app, test, uid)

Called when loading the single_test view of a Test attached to an Application of a RecordType linked to this object. Generates any alerts for display above the breadcrumbs

Parameters:

Returns:

  • (Hash)

    Hash of :success - Boolean, :errstr - String of error text if success is false, :alerts - Array of alert messages where each element is a hash of :color, :html, :customMenuItems - Array of menu items where each element is a hash of :icon, :text, :href, :authMethods, :isDropdown, :dropdownOpts (Array of hashes - :href and :text)



76
77
78
# File 'lib/VRLinkedObject.rb', line 76

def getTestAlerts(app, test, uid)
	raise "NotImplemented"
end

+ (Object) objs



22
23
24
# File 'lib/VRLinkedObject.rb', line 22

def objs
	@objs ||= []
end

+ (Hash) validateEntityID(eid, app)

Called when linking an Application to a linked object ID to validate the ID. Can mutate EID.

Parameters:

  • eid (String)

    EID to validate

  • app (Application)

    App object that will be attached to this EID

Returns:

  • (Hash)

    Hash of :valid [Boolean] and :eid with the valid (possibly mutated) EID. If :valid is false also contains :errstr.



175
176
177
# File 'lib/VRLinkedObject.rb', line 175

def validateEntityID(eid, app)
	raise "NotImplemented"
end

+ (Object) vrlo_key(key = nil)



26
27
28
29
# File 'lib/VRLinkedObject.rb', line 26

def vrlo_key(key=nil)
	@vrlo_key = key.to_s if !key.nil?
	@vrlo_key ||= self.key
end

+ (Object) vrlo_name(name = nil)



31
32
33
34
# File 'lib/VRLinkedObject.rb', line 31

def vrlo_name(name=nil)
	@vrlo_name = name.to_s if !name.nil?
	@vrlo_name ||= self.name
end