Device Policies (Policy Library and Rules Library)

Download this manual as a PDF file

You can use Skylar Compliance to create rules and policies to verify that your devices comply with corporate or regulatory guidelines.

A rule is a pattern that is applied to configurations or device firmware version to test whether the configurations or firmware contain a certain phrase or regular expressions, or if they match an existing device template. If the tests fail, a compliance violation is triggered and an email alert is sent to the device owner. A policy is a group of one or more rules.

Device Policies and Rules

You can use the three tabs on the Device Policies page (Compliance > Device Policies) to create and use configuration compliance rules and policies that you can assign to devices.

A rule is a pattern that is applied to configurations or device firmware version to test whether the configurations or firmware contain a certain phrase or regular expressions, or if they match an existing device template. A rule can also be applied to or tested against a command output. If the tests fail, a compliance violation is triggered and an email alert is sent to the device owner.

A policy is a group of one or more rules. You can create Configuration Policies for devices that have a text configuration file or a TGZ archive of text configuration files.

The Policies Tab

The Policies tab on the Device Policies page (Compliance > Device Policies) contains a list of the currently installed compliance policies for your devices. This tab displays by default when you first go to the Device Policies page.

Select a policy from the list to make changes to the policy on the Edit device policy page. For more information, see Editing a Device Policy.

Creating a Device Policy

After you have created one or more rules, or if you want to use one or more of the existing rules, you can create a new device policy.

To create a new device policy:

  1. On the Device Policies page (Compliance > Device Policies), click Add Policy. An Add device policy page appears.

  1. Enter the following details on the Details tab:

    • Name. Type a name for the new device policy.

    • Device Type. Select a device type from the drop-down field. Click the Info button to view a pop-up with more information about the device you selected.

    • Low-risk Alert. Choose the criteria for low risk alerts to generate from the drop-down field.

    • Medium-risk Alert. Choose the criteria for medium risk alerts to generate from the drop-down field.

    • High-risk Alert. Choose the criteria for high risk alerts to generate from the drop-down field.

    • Critical-risk Alert. Choose the criteria for critical risk alerts to generate from the drop-down field.

    • Additional Comments. Add any other information you might need for this policy.

    • Log Transcript. Enable this option to capture and store transcripts for all compliance rules. You can view the transcript on the Logs page (Information > Logs) or on the Logs tab of a device. Transcripts are not stored by default.  Using this option will increase the number of stored records and overall storage usage.

  2. Click Save Changes.

Editing a Device Policy

When you click the name of a policy, an Edit device policy page for that policy appears, where you can edit or clone (make a copy) of that policy.

The Policy Library Tab

The Policy Library tab on the Device Policies page (Compliance > Device Policies > Policy Library) provides access to the packaged policies from ScienceLogic installed on the system. These read-only policies, also called library policies, are delivered with compliance updates (Administration > Software Updates).

Library policies contain a set of rules, such as hardening baselines, for one device type or for all device types, along with a changelog and documentation that explains what the rules do. ScienceLogic maintains these library policies through policy library updates.

The Policy Library tab lists all of the library policies installed on the appliance. Library policies do not belong to a domain. Every domain sees the same list.

For each library policy, the list shows:

  • Policy Name. Select a name to open the library policy page.
  • Plugin. The device type the policy applies to. N/A means the policy applies to any device type.
  • Description. A summary of what the policy checks.
  • Vendor. The organization whose benchmark or guide the policy is based on, such as CIS. N/A displays for policies authored by ScienceLogic.
  • Vendor Version. The version of the vendor's benchmark or guide that the policy is based on.
  • Revision. When ScienceLogic published the installed version of the policy. The revision is the same on every appliance. Select it to see the policy's changelog.
  • Rules. The number of rules in the policy.
  • Instances. The number of instances of the policy in the domains you can access.
  • Documentation. Click View to read the policy's documentation.
  • Install. When the installed version of the policy was installed on this appliance.

If the Policy Library tab is empty, no policy library update has been installed on the appliance yet. For more information, see Policy Library Updates.

You need the View Device Policy permission to see the contents of the Policy Library tab, and the Modify Device Policy permission to create instances and clones.

Viewing a Library Policy

To view the details of a library policy, click the name of the policy from the Policy Library tab. A Library policy page appears:

Library policy pages include the following sections:

  • Details. The plugin, vendor, vendor version, and revision of the policy, when the appliance first received the policy (First Install), and when its current revision was installed (Last Install).

  • Documentation. Notes from ScienceLogic about what the policy checks and why.

  • Rules. The rules in the policy, with the name and severity that the policy gives each rule, and the type and group for each rule. Select a rule name to view the rule. You cannot edit it.

  • Changelog. The changes ScienceLogic made in each revision of the policy.

  • Instances. The instances of the policy in the domains you can access. Select an instance to edit it. This section appears once the policy has at least one instance.

The [Clone] and [Create Instance] buttons at the top of the page let you clone (copy) or create a policy based on that library policy.

Creating an Instance of a Library Policy

A library policy is a read-only template. To use a library policy, you need to select the library policy and then create a device policy from it, either as an instance or as a clone:

  • An instance of a policy stays linked to its library policy. When ScienceLogic updates the library policy, the instance is updated too, and the changes you made to the instance are kept. For more information, see the following procedure.
  • A clone of a policy is an independent copy of the library policy. Its rules become your own rules, and policy library updates never change it. For more information, see cloning an instance.

Create an instance to keep up with changes that ScienceLogic makes to a benchmark. Create a clone when you need to change the policy beyond what an instance allows, for example to remove rules permanently or to use the rules with another device type.

To create an instance of a library policy:

  1. Go to the Policy Library tab on the Device Policies page (Compliance > Device Policies > Policy Library).

  2. Click the checkbox next to the library policy you want to use and click Create Instance. You can also click Create Instance on the library policy page.

    The Add device policy page appears, with fields already filled in from the library policy. A banner names the library policy aligned with the instance; click Open in the Rule Library to see the rule on the Rule Library tab.

    Add device policy page for an instance of a library policy, with a banner that names the library policy.

  3. Complete the fields on the page:

    • Name and Additional Comments show the library policy name and description. To use your own, turn on Override library value under the field, and then edit the field. For more information, see Instance Name and Comments.

    • Device Type is set to the library policy's device type and cannot be changed. To use a library policy's rules with another device type, clone the library policy instead.

    • Complete the remaining fields, such as Domain and the alert thresholds, as you would for any device policy.

  4. If needed, click the Rules tab to review the rules that the instance gets from the library policy. All of these rules are enabled in a new instance. You can add rules of your own by clicking Add Rule. Add from Library becomes available after you save the policy.

    Rules tab of a new instance listing the rules from the library policy.

  5. If needed, select devices on the Devices tab, or set up the Auto-Apply tab.

  6. Click Save Changes. The new policy appears on the Policies tab with a Library tag. Select the tag to open the library policy.

    Policies tab showing a device policy with a Library tag.

You can create several instances of the same library policy. For example, you can create one for each domain, or one for each group of devices that needs different alert thresholds.

Editing an Instance

You edit an instance the same way as any other device policy, with the differences described in this section.

Instance Name and Comments

The Override library value switch under the Name and Additional Comments fields controls where each value comes from:

  • Off. The field shows the library policy's name or description, and you cannot edit it. When an update renames the library policy or changes its description, the instance follows.
  • On. The field holds your own value, and updates do not change it.

If you turn the switch off again, the field returns to the library policy's current value.

Name field of an instance with the Override library value switch turned on.

Rules from the Library Policy

On the Rules tab of an instance, the rules that come from the library policy have a Library tag. You cannot delete these rules. When one of them is selected, the Delete button is unavailable.

Rules tab of an instance with a library rule selected and the Delete button unavailable.

Instead of deleting a rule from a library policy, you can:

  • Disable a rule that does not apply to your network. For more information, see Disabling Rules.

  • Change how a rule is applied in this policy. Select the rule's name to open the Edit Library Rule window. Each setting that you can change has an Override library value switch. While a switch is off, the setting comes from the library and follows updates. Turn a switch on to give the setting your own value in this policy. You can override the rule's name, description, severity, and remediation. Depending on the rule, you can also change its files and ignored lines, and add your own filters, configuration types, and test data. Work through the steps, or click Skip to Finish, and then click Save.

    Your changes apply only to this policy. The rule itself, and other policies that use the rule, are not affected.

    If the library policy already renames the rule or changes its severity, the switch for that setting is already on, and the rule's name in the Rule Library appears under the Name field.

    Edit Library Rule window showing Override library value switches.

You can also add rules of your own to an instance with Add Rule or Add from Library. These rules belong to the instance: you can edit or delete them, and policy library updates do not change them. Make Standalone is not available for rules from the library policy, because they are already library rules.

Cloning an Instance

When you click Clone at the top of an instance's page, you create another instance of the same library policy. The new instance starts with a copy of the source instance's rules, including your changes to the library policy's rules and which rules are disabled. Until you save the new instance, you cannot disable or delete its library rules.

Disabling Rules

You can disable a rule in any device policy, including an instance, to stop the rule from being checked without deleting it. Disabling is useful for rules in a library policy that do not apply to your network.

To disable or enable rules:

  1. Open the device policy and select the Rules tab.

  2. Select the checkbox for one or more rules.

  3. Click Disable or Enable. In a saved policy, the change takes effect immediately.

    Rules tab with a disabled rule dimmed and marked with a Disabled tag.

A disabled rule:

  • Appears dimmed, with a Disabled tag.
  • Is skipped by the compliance checks that run during backups and scheduled actions. Backups also stop running device commands that only disabled rules need.
  • Does not count toward a device's compliance score or violations, or in compliance reports. The rule's earlier results are kept, and they count again as soon as you enable the rule.
  • Is skipped by Test All Rules, which notes that disabled rules are not tested. You can still test a single disabled rule with Test, for example to check the rule before you enable it.
  • Stays disabled through policy library updates, and when you clone, export, or import the policy.

Cloning a Library Policy

To clone a library policy:

  1. Go to the Device Policies page (Compliance > Device Policies) and select the Policy Library tab.

  2. Select the checkbox for the library policy and click Clone. You can also click Clone on the library policy page. The Add device policy page appears. The Name is "Clone of" followed by the library policy's name, and a banner names the library policy being cloned. The Device Type is set to the library policy's device type.

    Add device policy page for a clone of a library policy, with a banner that names the library policy.

  3. Edit the name and the other fields as needed. The Rules tab lists the rules that will be copied.

  4. Click Save Changes. The library policy's rules are copied into the new policy as rules of its own.

The clone is a standard device policy. You can edit or delete any of its rules, and change its device type as you would for any policy. The clone is not linked to the library policy: it has no Library tag, it is not listed among the library policy's instances, and policy library updates do not change it.

Policy Library Updates

ScienceLogic publishes new library policies and rules, and changes to existing ones, in policy library updates. Some windows call them compliance updates. The appliance receives policy library updates with its software updates:

  • An appliance that is connected to the Internet receives them when it checks for updates. They are installed automatically, unless Disable Automatic Minor Updates is selected. If it is selected, the updates wait for you to review and install them.
  • On an appliance that is not connected to the Internet, they are included in the update file that you upload, and are installed with it.

To manage policy library updates, go to the System Settings page (Administration > System Settings), click the Appliance tab, and use the Software Updates section.

Software Updates section of the Appliance tab showing the policy library update buttons.

When updates are waiting to be installed, the Software Updates section shows how many are waiting, and the following buttons:

  • Install policy library updates. Installs the waiting updates. The installation runs as a task.
  • View changelog. Opens the Compliance updates ready to install window, where you can review the waiting updates before you install them.

View last policy library updates is always available. It opens the Last compliance update window, which shows when the most recent installation ran, and lists each library policy and rule that it added, updated, or removed, with the changelog entries for each.

Last compliance update window listing the library policies and rules from the most recent installation.

You need the View Sysadmin permission to review policy library updates, and the Update Sysadmin permission to install them or change update settings.

Reviewing Updates Before You Install Them

In the Compliance updates ready to install window, each waiting library policy or rule has two tags: the kind of change (add, update, or remove), and what is changing (policy or rule). Select an entry to see:

  • The changelog entries that the update adds.
  • The installed changelog (left) next to the changelog in the update (right), with the new entries highlighted.

For an update or a removal, select Installed policy or Installed rule to open the version that is installed now.

Compliance updates ready to install window listing the waiting updates and their tags.

Some updates cannot be installed yet, because they require a newer version of Skylar Compliance or a device plugin that is not installed. An update that requires a newer version shows the version it needs, as "Cisco IOS Session Timeout Baseline" does in the figure above. These updates stay waiting, and are installed by the first installation after the appliance meets the requirement. The rest of the updates install normally.

Turning Off Policy Library Updates

To stop receiving policy library updates, select Disable policy library updates in the Software Updates section and click Save. When you do so:

  • Any updates waiting to be installed are discarded.
  • The library policies and rules that are already installed, and the instances you created from them, do not change.
  • If you clear the option later, the appliance receives the complete current set of library policies and rules with its next update.

How Updates Change Your Instances

When a policy library update changes a library policy, the changes are applied to every instance of the policy, and the changes you made to each instance are kept. Clones never change.

When the update... Each instance...

Adds a rule to the library policy.

Gets the new rule disabled, so that the rule does not report violations before you review it. Review the rule, and enable it if it applies to your network. Instances that you create after the update start with all of their rules enabled.

Removes a rule from the library policy.

Loses the rule, along with the rule's compliance results.

Renames a rule or changes its severity in the library policy.

Follows the change, unless you changed that setting in the instance. The name and the severity are handled separately.

Changes how a rule checks devices, such as its patterns, filters, or remediation.

Uses the new version of the rule from the next compliance check. The settings you overrode in the instance still apply.

Renames the library policy or changes its description.

Follows the change, unless Override library value is on for Name or Additional Comments.

Withdraws the library policy.

Is not affected. The appliance does not remove a library policy while the policy has instances. The removal waits until all of the instances are deleted.

An update never changes the rules you disabled or enabled, the rules you added to the instance yourself, or the instance's devices, Auto-Apply settings, alert thresholds, and domain.

For example, after an update adds the "localUserSecretsOnly" rule to "CIS Cisco IOS Benchmark - Level 1", the instance below has the new rule, disabled. The "sshVersion2Only" rule stays disabled, as the user left it.

Rules tab of an instance after an update, showing the new rule disabled.

Packaged Rules in the Rule Library

The rules that ScienceLogic publishes appear on the Rule Library tab, next to the rules you create. Packaged rules:

  • Cannot be edited or deleted.
  • Can be added to any of your device policies with Add from Library, where you can override their settings for that policy.
  • Are updated by policy library updates. For a packaged rule, the Rule Library shows the revision, and you can view the rule's changelog and earlier versions.

Rules that a library policy defines for itself are not listed in the Rule Library. You can view them on the library policy page.

Exporting and Importing Instances

You export and import instances the same way as other device policies. The export contains the instance's link to its library policy, your changes to the library policy's rules, and which rules are disabled. It does not contain the library policy's rules themselves.

Before you import an instance on another appliance, make sure that the same library policy is installed on that appliance. Any rule of the library policy that is not in the export is added disabled, as it would be by an update.

The Rule Library Tab

The Rule Library tab on the Device Policies page lists all library rules, which are rules that can be used with any device policy. Like a library policy, a library rule is reusable, and a library rule is not tied to just one specific device policy.

The process for creating a device-specific rule or a library rule uses the New Skylar Compliance Rule wizard. The type of rule depends on where you are in the user interface when you create the rule:

  • To create a rule that is specific to a device policy, go to the Policies page (Compliance > Device Policies) click Add Policy to create a new policy or select an existing policy. On the Rules tab for the policy, click the Add Rule button.
  • To create a library rule, go to the Rule Library tab (Compliance > Device Policies > Rule Library tab) and click the Add Rule button

For both situations, the New Skylar Compliance Rule wizard appears.

Creating a New Rule

After you create a rule, you can edit, remove, clone, or test it against an existing backup with the appropriate buttons on the Rule Library tab

To create a new rule specific to a device policy:

  1. Go to the Device Policies page (Compliance > Device Policies) and click the name of the device policy to which you want to add the rule and click the Rules tab.

    If you want to create a library rule, go to the Rule Library tab (Compliance > Device Policies > Rule Library tab) instead.

  2. Click Add Rule. The Rule Builder appears and displays step 1, Basic Information.

    Step 1 of 6, Basic Information, on the page for a new rule.

  3. On the Basic Information step, complete the following fields:

    • Name. Type a name for the rule. Reports and email alerts use this name to identify the rule.

    • Description. Type a description of the rule.

    • Severity. Select the alert level for a violation of the rule from the drop-down list: None, Low, Medium, High, or Critical. The severity feeds the alert thresholds and scoring of the policy.The default is None.

  4. Click Continue. The Filters step appears. Filters are pre-conditions that are evaluated before the rule runs. If a filter is not met, the rule is skipped and counts as a pass. Multiple filters are combined with AND. The values within one filter are combined with OR. Complete the following fields as needed:

    • Filter Type. How each value is matched: Phrase (substring) or Regex.

    • Data Type. The device data to test against: Asset, Additional Info (the output of a device command), or Label.

    • Data. The specific asset field or Additional Info command. This field is hidden when Data Type is Label.

    • Requirement. Must Match or Must Not Match.

    • Value. One phrase or regular expression per line. The filter passes if any line matches.

  1. Click Continue. The Rule step appears. Complete the following fields as needed:

    • Type. Select the type of data that the rule test: a configuration, software version, runtime command, or the output of a scheduled action. If you select a runtime command or a scheduled action, select the command or schedule in the new field that appears below this field.

    • Process line-by-line. Select this toggle to evaluate the output of a runtime command line by line instead of as a whole string. This field appears only for older rules that still evaluate the output as a whole string.

    • Rule Method. Phrase, regular expressions, Lua function, device, or device templates. The Phrase match type matches any (case sensitive) number of characters, including multi-line. The Regex match type (see Regular Expressions) takes a Perl-flavoured regular expression, and applies it to the whole configuration, or firmware string.

    • Must Match / Must Not Match. If you select the Phrase or Regex rule method, enter the pattern values. You can enter both Must Match and Must Not Match values.

      • Case Insensitive. Select this toggle to ignore case. You set this for each pattern.

      • Match Type / Subtype. For multi-line patterns: All (Consecutive) (default), All (Unordered), All (Ordered), All (Consecutive, once), Any, or One (Must Match only).

      • Scan Entire File. For Must Not Match patterns with an All subtype, collect and report all occurrences.

    • Condition. If you select the Lua function or device rule method, select Must Match or Must Not Match.

    • Lua Function. If you select the Lua function rule method, enter the Lua source code to evaluate.

    • Device. If you select the device rule method, select the peer device to compare the configuration against.

    • Template. If you select the device templates rule method, select the template to match. The rule always uses Must Match.

    • Files. If you select a configuration rule, restrict the rule to specific file paths within the backup.

    • Ignore Lines. If you select the device rule method, enter the lines to remove before matching.

  2. Click Continue. The Remediation step appears. Complete the following fields as needed:

    • Remediation. None, Manual, Automatic, or Command. For more information, see Remediation.

    • Command. If you select Command, select the stored command that runs to remediate.

    • Value. If you select Manual or Automatic, enter the remediation instructions or commands text.

    For more information, see Remediation.

  3. Click Continue. The Test Data step appears. Test data are named test inputs that validate the rule. They are not evaluated against real devices. Test data is not supported for the device and device templates rule methods. Complete the following fields as needed:

    • Test Name. An identifier for the test case.

    • Should Pass. A toggle for the expected outcome.

    • Description. Optional notes.

    • Data. The sample text that the rule runs against (up to 10 KB).

    • Run Tests. Runs all test cases against the current, unsaved rule and displays a badge with the result of each case.

  4. On the Test Data step, test the rule before you save it. Click Continue. The Finish step appears.

  5. The Finish step displays a read-only summary of all your entries for review before you save the rule. Click Finish when you are done reviewing the data for the rule and click Save Changes if you are working in a device policy.

    The device-specific rule appears on the Rules tab of the device policy or the library rule appears on the Rule Library tab.

Remediation

You can use remediation when a compliance rule is not met, generally intended to rectify the violation. The following remediation types can be configured:

  • Manual. The remediation text is appended to the notification email to signify that the recipient should take the appropriate action.
  • Command. One of the stored Actions on the device is executed. For more information, see Device Control.
  • Automatic. The text specified in the textbox is used as a command and executed on the device.

If the rule match type is Regex, the remediation can make use of the Capture feature, whereby parts of the pattern in brackets can be captured and then referred to in the remediation text (as $1, $2, etc.). For example, a rule may state that a configuration must not contain the regex:

set telnet (\d+\.\d+\.\d+\.\d+)

Where the command in brackets is a match for an IP address. If this rule is violated, the configuration can be remedied using the phrase:

unsettelnet$1

In this case, the brackets in the rule will capture the IP address, and apply it when the command is performed. The rule is then expanded:

unsettelnet1.2.3.4

Regular Expressions

A regular expression specifies a set of strings as a pattern, rather than a list. For example, the pattern C(o|as?)t matches the strings Cot, Cat, and Cast, but not Coast. Skylar Compliance uses Go's RE2 regular expressions.

Most characters can be used in a regular expression. Some characters, called metacharacters, have special meanings:

  • () denote grouping: (a|b)b matches ab and bb
  • | denotes an alternative (see above)
  • ^ matches the beginning of a line
  • $matches the end of a line
  • . matches any character
  • + denotes one or more occurrences of the previous character: a+b matches ab, aab, abb, but not b
  • * denotes zero or more occurrences of the previous character: a*b matches b, ab, aab, aaab
  • ? denotes zero or one occurrences of the previous character: a?b matches b and ab, but not aab or aaab

Character classes are matches for sets of possible characters, rather than just a single character. For example:

  • [bcr]at matches bat, cat and rat
  • - can be used as a range operator in a character class. For example,[a-g] matches any character from a to g

There are some abbreviations for common character classes:

  • \d matches a digit
  • \s matches whitespace (a space or a tab)
  • \w matches a word character (alphanumeric or a _)

For example, \d\d:\d\d:\d\d matches time in a hh:mm:ss format

Lua Functions

You can use Skylar Compliance to define rules using Lua functions.

Available functions for compliance rules are:

  • nextline() returns the next line of text
  • getline(n) returns the given line of text
  • numlines() returns the number of lines
  • addmessage(m) allows you to replace a series of variables in the remediation text. For example, addmessage("Hello") with a remediation text of $1World! would output Hello World!. The next addmessage call would replace $2, and so on.

This function checks that the number of lines containing configure matches the lines containing port:

num1 = 0 
 num2 = 0 
line, next = nextline() 
 while next do 
   if line:match("configure") then num1 = num1+1 end 
   if line:match("port") then num2 = num2+1 end
   line, next = nextline() 
 end 
 if num1 > num2 then addmessage("more") 
 else if num2 < num1 then addmessage("less") end 
return num1 == num2

Remediation Text: Config contains $1 configures than ports.

Skylar Compliance Built-in Functions

The following functions can be used in a Lua applet:

  • timeout(seconds) - set the maximum timeout when waiting for device output
  • sleep(seconds) - do nothing for the given number of seconds.
  • send(command) - send command to the device
  • wait(string) - wait for timeout seconds for string from the device
  • sendget(command,output) - combined send/wait
  • before() - used after wait() or sendget(); it contains the output from the device up to the expected string.
  • print(string) - displays the value of string
  • splitlines(string) - split a multi-line string (for example, the output of a command) into an array of lines.

Other standard Lua commands that may be useful include, string.match, string.gsub. and string.trim.

You do not need to write any code to connect and authenticate to the device. Skylar Compliance will automatically connect and authenticate the device for you.

Users are not permitted to run any “os” or “system” functions when making Lua scripts. This restriction is in place to maintain the security of your Skylar Compliance appliance.

Examples

Show Version (Cisco)

A basic example is to display the output of the show version command on a Cisco switch:

timeout(20)
send('show version')
wait('#')
out=before()
print(out)

The send() & wait() commands can also be combined into a sendget():

timeout(20)
sendget("show version","#")
out=before()
print(out)

Show Interface (Cisco)

The following is a more complex example using control structures. It runs show interfaces on a Cisco switch and checks that all interfaces that are not connected (line protocol is down) are also administratively down. Note that everything after -- is a comment, and is not executed:

timeout(20)                      -- set the timeout to 20 seconds
sendget("terminal length 0","#") -- send command to the device, and
                                 -- wait for the prompt
sendget('show interfaces', '#')
out = before()                   -- set "out" to the output
lines = splitlines(out)          -- split the output lines into array
for k,v in pairs(lines) do       -- loop over each line, and
                                 -- set k=number and v=text

int,st1,st2 = v:match(
"^(%S+Ethernet[0-9/]+) is ([a-z ]+), line protocol is ([a-z]+)"
)                              -- extract the interface name,
                             -- interface status, and the
                             -- line protocol status

if int ~= nil and
( st1 ~= 'administratively down' and st2 == 'down' ) then
print("Interface "..int.." is disconnected but not shutdown")
end

end                              -- end loop

IP Spoofing (ScreenOS)

For ScreenOS, use the following script to check for ip-spoofing:

timeout(5)
sendget("set console page 0",">")
sendget("get zone | inc L3",">")
ret = before()
sendget("get config | inc ip-spoofing",">")
conf = before()

for zone in ret:gmatch(" [0-9]+ (.-)%s+Sec") do
    if conf:match('zone "'..zone..'" screen ip%-spoofing') then
      print('Zone '..zone..': antispoofing enabled')
    else
      print('Zone '..zone..': antispoofing disabled')
    end
end

IP Spoofing (Palo Alto)

You can use the following script to check for ip-spoofing, but for Palo Alto devices:

timeout(5)
sendget("set cli pager off",">")
sendget("set cli config-output-format set",">")
waitprompt()
sendget("configure","#")
send("show zone")
sleep(1)
waitlast("#")
ret = before()
sendget("exit",">")
tbl = {}

for key in ret:gmatch("set zone (.-) ") do
  tbl[key] = true
end
for k, _ in pairs(tbl) do
  send('show zone-protection zone '..k)
  sleep(1)
  waitlast('>')
  ret = before()
  if ret:match('discard%-ip%-spoof:%s+enabled: yes') then
    print('Zone '..k..': antispoofing enabled')
  else
    print('Zone '..k..': antispoofing disabled')
  end
end