OnGuard Custom Scripts

Policy Manager allows you to configure three types of OnGuard custom scripts, agent script enforcement profile scripts, health collection scripts, and auto remediation scripts. Admin users can create and execute a script on endpoint devices as part of agent enforcement, or query for additional information that is not included in the existing health classes.

The responses to scripts can be used to determine the appropriate health of the endpoint. Admin users can also create remediation scripts to be executed if an endpoint does not pass health check. Custom scripts can be configured to appear to be executed by the current logged-on user, or as the system user with admin rights.

Scripts launched as a user do not support system operations that need root/admin privileges. Note that if a health collection script is launched as a user without privileges to complete the task, the script execution process can return an error code that can put the client in an unverified status for that check.

You can create custom scripts using the following approved language formats. Note that these formats may be platform-dependent based on available system capabilities.

PowerShell (PS1)

Executable Binary (exe for windows)

Visual Basic Script (VBS)

JScript (JS)

Windows Script File (WSF)

PerlScript (PLS)

PScript (PS)

PythonScript (PYS)

Bash

Python (2.7)

Python (3.x)

Perl

PHP

AppleScript

sh

csh

SED/AWK

Ruby

 

The REST Representational State Transfer. REST is a simple and stateless architecture that the web services use for providing interoperability between computer systems on the Internet. In a RESTful web service, requests made to the URI of a resource will elicit a response that may be in XML, HTML, JSON or some other defined format. API Application Programming Interface. Refers to a set of functions, procedures, protocols, and tools that enable users to build application software. for OnGuard Custom Scripts is located in theClearPass Guest API Application Programming Interface. Refers to a set of functions, procedures, protocols, and tools that enable users to build application software. Explorer, at API Explorer > Dictionaries > OnGuard Custom Script.

Agent Script Enforcement Profile Scripts

Policy Manager can use a custom script in agent script enforcement profiles to execute the script on endpoint devices as part of agent enforcement. When you associate an Agent Script Enforcement Profile script to the Enforcement profile, the details of the custom script, such as the path of the custom script, the command to be executed, and the execution level are configured in the OnGuard Custom Scripts section. You can then add one or more OnGuard custom scripts into an Agent Script Enforcement Profile that acts as a rule in an enforcement policy.

OnGuard Agent executes the OnGuard custom script in the Agent Script Enforcement profile after first applying Agent Enforcement profiles (that is, after Agent Bounce is executed, if configured). While applying an Agent Script Enforcement profile, OnGuard Agent does not check to see if a script is already running. It is possible for OnGuard Agent to launch the script multiple times if a previously launched script is still running. This can occur if OnGuard Agent performs multiple health checks (either manually triggered or caused by a change in health status). The script exits after performing its task.

Health Collection Scripts

You can use the OnGuard Custom Scripts section to create health collection scripts for the Windows, Linux or macOS Universal System Health Validator posture plugins on the Configuration > Posture > Posture Policies page. Admin users can create a health collection script for Windows, Linux or macOS and associate it with the Universal System Health Validator posture plugin for the same operating system to query for additional information that is not included in the existing health classes. The responses of health collection scripts can be used to determine the appropriate health of the endpoint. Responses can be in JSON JavaScript Object Notation. JSON is an open-standard, language-independent, lightweight data-interchange format used to transmit data objects consisting of attribute–value pairs. JSON uses a "self-describing" text format that is easy for humans to read and write, and that can be used as a data format by any programming language. format or a key-value pair. The OnGuard Custom Script configuration allows you to create a set of rules that associate exit codes and key-values with a health status of Healthy or Unhealthy.

Auto Remediation Scripts

You can also use the OnGuard Custom Scripts section to create an  auto remediation script for the Windows, Linux or macOS Universal System Health Validator posture plugins on the Configuration > Posture > Posture Policies page. If the posture plugin includes a health collection script and auto-remediation is enabled for that plugin, you can associate an additional auto remediation script to take an action by running a script on an endpoint that does not pass health checks.

Configuring OnGuard Custom Scripts

To configure a Custom Script:

1. Navigate to Administration > Dictionaries > OnGuard Custom Scripts. The OnGuard Custom Scripts page opens.

2. Click the Add link. The OnGuard Custom Scripts > Add window opens.

3. In the Name and Description fields, enter a name and description of the script .

4. Click the Operating System drop-down list and select the operating system on which the script will run. OnGuard custom scripts are supported on Windows, macOS, and on all Linux operating systems that support OnGuard.

5. Click the Script type dropdown menu and identify how this custom script will be used:

Agent Script Enforcement Profile: Script will execute as part of a Agent Script Enforcement Profile.

Health Collection: Script will execute as part of a Universal Health Validator posture plugin for Windows, Linux or macOS devices to collect additional health data for devices of that type.

Auto Remediation: If you have associated a health collection script with the Universal Health Validator posture plugin for Windows, Linux or macOS devices, you can also associate a custom auto remediation script to run on non-compliant endpoints.

Figure 1  OnGuard Custom Scripts > Script Configuration Dialog

6. Click the Attributes tab. Mandatory attributes appear by default with information about the attribute. Select the Click to Add link to add other attributes.

Table 1: OnGuard Custom Scripts > Attributes

Attribute

Action/Description

Path of the Script

Required for all script types. Complete the path of the script/program, including the filename. This attribute checks for the existence of a file on an endpoint device and also verifies the SHA256 Checksum.

Command to Execute

Required for all script types. Specify the complete command that OnGuard Agent should execute. You can use the command to launch scripts or pass command line arguments.
For example, to launch VBScript (InstallHotfixes.vbs) and pass All as an argument, you would enter the following:
cscript /nologo C:\Test\InstallHotfixes.vbs All
If it is not required to pass arguments, set the value of this attribute to the same value specified for Path of the Script.

Execution Level

The attribute values are: User and System.

To launch the script/program as the current logged-on user, select User.

To launch the script/program as the system user with admin rights, select System.

SHA256 Checksum

Required for all script types. Specify the SHA256 checksum of the script or program. This attribute accepts comma-separated multiple SHA256 checksums to allow execution of different versions of same script or program.

Signer Name

Applicable only to Windows and macOS scripts that can be code signed. This attribute requires admins to enter a signer name to verify code signing of custom scripts. This field accepts multiple signer names separated by “|”.

NOTE: The Signer Name should be the value of ‘Issued to” in the Code Signing certificate that is used to sign the script/executable file. For example, all OnGuard executable files on Windows and macOS are signed using Aruba's code signing certificate. To verify code signing of any OnGuard executable using custom scripts, use Aruba Networks, Inc. as the signer name.

Wait Time (Seconds) Before Executing Script

Specify the time (in seconds) after which OnGuard Agent should launch the script/program.

When Wait Time Before Executing Script is configured, the OnGuard Agent does not process events such as Interface Up/Interface Down and health changes during the wait time.

Pass Health Evaluation Results to Script

Check the check box (which sets the value to true) to enable OnGuard Agent to pass health evaluation results to the script/program as an argument. The default is false.

When the Pass Health Evaluation Results to Script attribute is set to true, OnGuard Agent passes health evaluation results to the script in a URL Uniform Resource Locator. URL is a global address used for locating web resources on the Internet. Encoded JSson format.

URL Uniform Resource Locator. URL is a global address used for locating web resources on the Internet. Encode replaces double quotes, spaces, and Unicode characters with their ASCII American Standard Code for Information Interchange. An ASCII code is a numerical representation of a character or an action. value in %XX format. For example, spaces are replaced by %20 and double quotes are replaced by %22.

Success Message

Enter the message to be shown to the end user when the script or program is launched successfully.

Failure Message

Enter the message to be shown to the end user when execution of the script or program fails.

Progress Message

This message will be shown on the OnGuard Progress Page (see Creating OnGuard Custom Web Pages) while OnGuard Agent is executing the custom script and states what action is being performed.

Description

Provides a description of the custom user interface window or script.

Download URL Uniform Resource Locator. URL is a global address used for locating web resources on the Internet.

If the script or program configured in the Path of the Script attribute is not present on the client machine, enter the URL Uniform Resource Locator. URL is a global address used for locating web resources on the Internet. of the remote server from which OnGuard Agent can download the script or program.

OnGuard Agent supports downloading scripts only from HTTP Hypertext Transfer Protocol. The HTTP is an application protocol to transfer data over the web. The HTTP protocol defines how messages are formatted and transmitted, and the actions that the w servers and browsers should take in response to various commands. and HTTPS Hypertext Transfer Protocol Secure. HTTPS is a variant of the HTTP that adds a layer of security on the data in transit through a secure socket layer or transport layer security protocol connection. URLs Uniform Resource Locator. URL is a global address used for locating web resources on the Internet..

For HTTPS Hypertext Transfer Protocol Secure. HTTPS is a variant of the HTTP that adds a layer of security on the data in transit through a secure socket layer or transport layer security protocol connection. URLs Uniform Resource Locator. URL is a global address used for locating web resources on the Internet., OnGuard skips server certificate verification.

NOTE: OnGuard Agent does not support downloading files from URLs Uniform Resource Locator. URL is a global address used for locating web resources on the Internet. that require credentials.

Script Execution Timeout (Seconds)

Specify the Script Execution Timeout attribute value in the number of seconds. The value must be an integer between 60 and 3600.

When this attribute is configured, OnGuard Agent waits for the specified time for the custom script to finish execution. If the custom script does not finish execution within the specified time, OnGuard Agent returns failure for that script.

 

When this attribute is not configured, OnGuard Agent uses varying timeout values, depending upon whether or not custom remediation is enabled.

When Custom Remediation is enabled: the default value is 20 minutes.

When Custom Remediation is not enabled: 1 minute.

Configuring Auto Remediation

7. If you are configuring auto remediation and Agent Scripts Enforcement Profile scripts, click Save to save your settings. For health collection scripts only, you must continue the configuration process to define output details and rules.

a. To configure output details for a health collection script, click the Output Details tab. (This tab appears only for health collection custom scripts.)

b. Click the Output Format drop-down menu and select either Json or Key-Value Pair to output the exit code integer in JSON JavaScript Object Notation. JSON is an open-standard, language-independent, lightweight data-interchange format used to transmit data objects consisting of attribute–value pairs. JSON uses a "self-describing" text format that is easy for humans to read and write, and that can be used as a data format by any programming language. format or as a key-value pair. Select the Key-Value Pair option for custom scripts do not have built-in support for JSON JavaScript Object Notation. JSON is an open-standard, language-independent, lightweight data-interchange format used to transmit data objects consisting of attribute–value pairs. JSON uses a "self-describing" text format that is easy for humans to read and write, and that can be used as a data format by any programming language., such as batch files or VB scripts. For more information on exit codes, see OnGuard Custom Script Exit Codes

Figure 2  Output Details for a Health Collection Script

c. The Output Details tab includes the ExitCode key by default. To create a new key-value, click the Key Name column and enter a custom key name, then click the Key Value column and select String, Integer or Boolean as the value for that key type. Click any blank row in the table to enter your key-value data into the table, as shown in Figure 2. If you do not click into another row, the data you just entered will not be saved.

d. Next, click The Rules tab to define health evaluation rules based on the exit code and key-values returned by the health collection script.

Figure 3  Health Evaluation Rules

e. In the Rules Evaluation Algorithm field, click Select first match to return the health status for the first matched condition, or click Select all matches and return more than one health status value if more than one condition is matched.

f. Click Add Rule to open the Rules Editor.

Figure 4  Rules Editor

g. In the Matches field, select the match conditions for the health evaluation exit code. Select ANY to assign a health status to a rule that matches any of the conditions, or select ALL to assign the health status only if all the conditions are matched.

h. Click the Name field and select ExitCode or a key name, as defined in step c.

i. Click the Operator field and select any of the available operator types (for example, EQUALS, GREATER_THAN or LESS_THAN, or EQUALS, EXISTS or NOT_EXISTS).

j. Click the Value field and enter a value for the selected key.

k. In the Actions field, click the Health Status dropdown menu and assign a value or Healthy or Unhealthy to a rule that matches these conditions.

l. Click Save to exit the rule editor, and return to the OnGuard Custom Scripts dialog.

m. Click Save again to save your custom script.