Creating compliance definitions using scripts
Script-based definitions allow you to compose your own validation logic, thereby enhancing your control over what you are trying to validate. Use this procedure to create compliance definitions using JavaScript.
Before you begin
For more information on using scripts, see the related links.
About this task
You use the Create a Definition window of the Compliance user interface to create a new compliance definition.
Tip: You can copy an existing definition and modify it to create
a new definition.
Procedure
- Select Create->Definition from the menu. The Create a Definition window displays.
- Use the following descriptions as a guide to entering the
appropriate information in the Create a Definition window.
- Name
- Name chosen to identify the compliance definition. The maximum number of characters for the name is 255. This is a mandatory field.
- Description
- Brief narrative attached to the compliance definition to be created that explains its function and use. The maximum number of characters is 4000.
- Revision
- This number is automatically assigned and initially given a value of 1. Each time the compliance definition is edited, the revision number increments by 1. This is for versioning control. The revision changes only if the entity is active.
- Select Definition Type
- Radio buttons that allow you to create the following types of
compliance definitions:
Radio button Description Create compliance definition using CLI configuration lines Select this definition type if you want to define a Compliance Definition with a native definition that uses a stored configuration. Selecting this option causes the Enter Native Definition Details (CLI configuration lines) window to display. Create compliance definition using Native Commands Select this definition type if you want to define a Compliance Definition with Native Commands. Selecting this option causes the Enter Native Definition Details (Native Commands) window to display. Create compliance definition using a Device Model Select this definition type if you want to define a Compliance Definition with a modeled definition. Selecting this option causes the Enter Modeled Definition Details window to display. Create compliance definition using a Script Select this definition type if you want to define a Compliance Definition with a script. Selecting this option causes the Enter Script-Based Definition Details window to display. Create compliance definition using a Golden Configuration Select this definition type if you want to define a Compliance Definition using a device’s golden configuration as a template for automatically generating evaluations. Selecting this option causes the Select a Golden Device window to display. - Prev
- Go to the previous selection.
- Next
- Go to the next selection.
- Finish
- Complete process.
- Cancel
- Cancel activities.
- Select the Create compliance definition using
a script radio button, and then click Next.
The Enter Script-Based Definition Details window displays.
- Edit the definition:
- Script Type drop-down
- Currently only JavaScript can be used to create a script-based definition.
- Script syntax and examples
- Remember: A script definition must return a boolean value true or false
- You can use a number of methods that form part of a helper class specifically designed to help you write scripts. For more information on using scripts, see the related links.
- Validate Syntax
- Checks to see if the JavaScript syntax entered is valid.
- Script Parameters
- These are external parameters that can be used by the JavaScript. They could be Global, Group or Extraction values.
- For more information on script parameters, see the related links.
- Click Next. The Choose a Save Location window displays.
- Navigate through the tree structure, and choose the location to which you want to save the compliance definition. Otherwise, it is possible to create a new realm from here if required.
- Click Finish to complete the creation of the compliance definition.