1 /*
  2  * Copyright © [2008-2009] Novell, Inc. All Rights Reserved.
  3  * 
  4  * Novell grants permission, free of charge, to any person obtaining copies of this 
  5  * software and its associated documentation files (the "Software"), to deal in the 
  6  * Software without restriction, including to use, copy, adapt, publish, distribute, 
  7  * display, perform, sublicense, and sell copies of the Software, subject to the following 
  8  * condition: You must include the above copyright notice and this permission notice in 
  9  * all full or partial copies of the Software.
 10  * 
 11  * NOVELL PROVIDES THE SOFTWARE "AS IS," WITHOUT ANY EXPRESS OR IMPLIED WARRANTY, 
 12  * INCLUDING WITHOUT THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
 13  * PURPOSE, AND NON-INFRINGMENT.  NOVELL, THE AUTHORS OF THE SOFTWARE, AND THE OWNERS OF 
 14  * COPYRIGHT IN THE SOFTWARE ARE NOT LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, 
 15  * WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN 
 16  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 17  */
 18 
 19 /**
 20  * @fileoverview
 21  * This file defines the non-template methods for an Action which must be defined when
 22  * creating a new Action. The methods in this file extend a number of other classes.
 23  */
 24 
 25 /**
 26  * The initialize() method should be used to initialize the Action that is about to
 27  * be performed, including opening any connections to external services, like
 28  * Integrators, or other preliminary setup steps.
 29  * @return {Boolean}  Action will halt if this method returns false.
 30  */
 31 Action.prototype.initialize = function() {
 32 	// Most actions will use Integrators; you can disable this block of code if yours does not
 33 	this.integrator = new IntegratorInstance();
 34 	
 35 	if (this.integrator.api == null) { return false; }
 36 
 37   // Many Actions will have additional parameters to control execution behavior.
 38 	// Simply extend this section to load in any additional parameters you have defined.
 39 	this.CONFIG.params.attribute = scriptEnv.getParameter("Attribute Name");
 40 	// ...
 41 	
 42 	return true;
 43 }	
 44 
 45 /** 
 46  * The get() method is used to fetch data from the input, which will depend on what
 47  * type of Action is being created. In general the loaded data should just be added as 
 48  * attributes on the current object (this.inputstring = ...).
 49  * There are several places where JS Actions can be called:
 50  * 1) Attached to a correlation rule - in this case, the input available to the Action is:
 51  *   - The associated correlated event
 52  *     - The raw events associated with the correlated event
 53  *   - The associated incident (IF CREATED)
 54  *     - All the associated incident data
 55  * 2) Attached to a right-click menu tool - in this case, the input available to the Action is:
 56  *   - The set of events selected when the menu tool was called
 57  *   - The specific meta-tags selected for passing as arguments to the Action
 58  * 3) As part of an iTrac workflow - in this case, the input available to the Action is:
 59  *   - ??
 60  */
 61 Input.prototype.get = function(){
 62 	// Most actions will want to look at some input data before performing the action
 63 	// The code below fetches the most common types of inputs used by Actions;
 64 	// comment out those you don't need.  From these inputs you can fetch other
 65 	// associated data as well, like assets, identities, and vulnerabilities.
 66 	// Refer to the associated NDK documentation for each object type to see how to
 67 	// fetch the correct attributes.
 68 	
 69 	// returns an array of the associated events
 70 	this.events = this.getEvents();
 71 	
 72 	// returns the associated incident  
 73 	this.incident = this.getIncident();
 74 	
 75 }
 76 
 77 /**
 78  * The normalize() method is used to take the raw input data and normalize
 79  * it into whatever format will be necessary to perform the action. This
 80  * may include complex processing to locate referential data.
 81  * In general, the normalized data can just be stored as additional
 82  * attributes on the current object (this.normalstring = ...).
 83  */
 84 Input.prototype.normalize = function(){
 85 
 86 }
 87 
 88 /**
 89  * In the doAction() method, you will take the normalized input to the Action
 90  * and use it to perform whatever type of action is necessary. If this Action is using
 91  * an integrator, it will be available as instance.integrator.handle.<method()> or
 92  * instance.integrator.api.<method()>
 93  */
 94 Input.prototype.doAction = function(){
 95 
 96 }
 97 
 98 /**
 99  * Cleans up the execution environment once the Action is complete.
100  * @return {void}
101  */
102 Action.prototype.cleanup = function() {
103 	return true;
104 }
105