<?xml version="1.0" encoding="utf-8" ?>
  <policy>
    <ruleset name='System' immutable='true'>
      <comment>
    This rule set will always be the the first set to be executed. Other rule sets are called from here.
  </comment>
      <rule name='Call Unenforced Devices Rules' id='1'>
        <selector>
          <and_conditions>
            <is_attribute_set negate='true'>
              <attribute>is_location_enforced</attribute>
            </is_attribute_set>
          </and_conditions>
        </selector>
        <actionset>
          <exec_ruleset>
            <ruleset_name>Unenforced Devices</ruleset_name>
          </exec_ruleset>
          <stop>
            <context>end_session</context>
          </stop>
        </actionset>
      </rule>
      <rule name='Call Device Settings Rules' id='2'>
        <selector>
          <and_conditions>
            <always_execute/>
          </and_conditions>
        </selector>
        <actionset>
          <exec_ruleset>
            <ruleset_name>Device Settings</ruleset_name>
          </exec_ruleset>
        </actionset>
      </rule>
      <rule name='Ignore Device Offline' id='3'>
        <selector>
          <and_conditions>
            <is_trigger>
              <trigger>off</trigger>
            </is_trigger>
          </and_conditions>
        </selector>
        <actionset>
          <stop/>
        </actionset>
      </rule>
      <rule name='Always in Production' id='4'>
        <selector>
          <and_conditions>
            <is_in_dev_group>
              <dev_group>always in production</dev_group>
            </is_in_dev_group>
          </and_conditions>
        </selector>
        <actionset>
          <exec_ruleset>
            <ruleset_name>Move to Production</ruleset_name>
          </exec_ruleset>
        </actionset>
      </rule>
      <rule name='Always in Quarantine' id='5'>
        <selector>
          <and_conditions>
            <is_in_dev_group>
              <dev_group>always in quarantine</dev_group>
            </is_in_dev_group>
          </and_conditions>
        </selector>
        <actionset>
          <exec_actionset>
            <actionset_name>Always in Quarantine</actionset_name>
          </exec_actionset>
        </actionset>
      </rule>
      <rule name='Call Device Enforcement Rules' id='6'>
        <selector>
          <and_conditions>
            <always_execute/>
          </and_conditions>
        </selector>
        <actionset>
          <exec_ruleset>
            <ruleset_name>Device Enforcement</ruleset_name>
          </exec_ruleset>
        </actionset>
      </rule>
      <rule name='Quarantine by Default' id='7'>
        <selector>
          <and_conditions>
            <always_execute/>
          </and_conditions>
        </selector>
        <actionset>
          <move_to_zone>
            <zone>Quarantine</zone>
            <reason>The default action is to quarantine.</reason>
          </move_to_zone>
          <stop/>
        </actionset>
      </rule>
    </ruleset>
    <ruleset name='Unenforced Devices' protected='true'>
      <comment>
    This rule set serves as an example for what might be done to launch actions based on audit results of a device not under enforcement (i.e. audits run on devices that are not on an enforced port).
  </comment>
      <rule name='Handle GAME Request' id='1'>
        <selector>
          <and_conditions>
            <is_trigger>
              <trigger>nac_request</trigger>
            </is_trigger>
            <is_attribute_set negate='true'>
              <attribute>was_immediate_run</attribute>
            </is_attribute_set>
          </and_conditions>
        </selector>
        <actionset>
          <schedule_audit>
            <type>immediate</type>
            <testset_name>Quick Scan</testset_name>
          </schedule_audit>
          <stop/>
        </actionset>
      </rule>
      <rule name='Failed Default' id='2'>
        <selector>
          <and_conditions>
            <is_health_ok negate='true'>
              <healthstandard_name>Default</healthstandard_name>
            </is_health_ok>
          </and_conditions>
        </selector>
        <actionset>
          <uilog>
            <message>The "#{health}" health verification against the "#{last_testset}" audit test set has failed.</message>
          </uilog>
        </actionset>
      </rule>
    </ruleset>
    <ruleset name='Device Settings' protected='true'>
      <comment>
    This rule set is where specific device settings should be managed (e.g. setting the production zone).
  </comment>
      <rule name='Ensure Production Zone Set' id='1' enabled='false'>
        <selector>
          <and_conditions>
            <is_attribute_set negate='true'>
              <attribute>production_zone</attribute>
            </is_attribute_set>
          </and_conditions>
        </selector>
        <actionset>
          <set_attribute>
            <attribute>production_zone</attribute>
            <value>default</value>
          </set_attribute>
        </actionset>
      </rule>
    </ruleset>
    <ruleset name='Device Enforcement' protected='true'>
      <comment>This rule set is where enforcement of devices is managed.</comment>
      <rule name='Check Recent Health' id='1' enabled='false'>
        <comment>Allow a device with good health back on immediately if the device was online recently.</comment>
        <selector>
          <and_conditions>
            <is_attribute_time_within>
              <attribute>last_online_time</attribute>
              <days>0</days>
              <time>00:30:00</time>
            </is_attribute_time_within>
            <is_attribute_time_within>
              <attribute>last_audit_time</attribute>
              <days>0</days>
              <time>12:30:00</time>
            </is_attribute_time_within>
            <is_health_ok>
              <healthstandard_name>Default</healthstandard_name>
            </is_health_ok>
          </and_conditions>
        </selector>
        <actionset>
          <exec_ruleset>
            <ruleset_name>Move to Production</ruleset_name>
          </exec_ruleset>
        </actionset>
      </rule>
      <rule name='Periodically Audit' id='2' enabled='false'>
        <selector>
          <and_conditions>
            <always_execute/>
          </and_conditions>
        </selector>
        <actionset>
          <schedule_audit>
            <type>background</type>
            <testset_name>Quick Scan</testset_name>
            <interval>720</interval>
          </schedule_audit>
        </actionset>
      </rule>
      <rule name='Wait for MAC and IP' id='3'>
        <selector>
          <and_conditions>
            <always_execute/>
          </and_conditions>
        </selector>
        <actionset>
          <exec_ruleset>
            <ruleset_name>Wait for MAC/IP</ruleset_name>
          </exec_ruleset>
        </actionset>
      </rule>
      <rule name='Require Agent' id='4' enabled='true'>
        <comment/>
        <selector>
          <and_conditions>
            <is_in_port_group>
              <port_group>corporate-agent</port_group>
            </is_in_port_group>
          </and_conditions>
          <and_conditions>
            <is_in_port_group>
              <port_group>corporate-agent-webauth</port_group>
            </is_in_port_group>
          </and_conditions>
        </selector>
        <actionset>
          <exec_ruleset>
            <ruleset_name>Require Lockdown Agent</ruleset_name>
          </exec_ruleset>
        </actionset>
      </rule>
      <rule name='Require Immediate Audit w/ Quick Scan' id='5' enabled='true'>
        <comment/>
        <selector>
          <and_conditions>
            <is_trigger negate='true'>
              <trigger>background</trigger>
            </is_trigger>
            <is_attribute_set negate='true'>
              <attribute>was_immediate_run</attribute>
            </is_attribute_set>
          </and_conditions>
        </selector>
        <actionset>
          <schedule_audit>
            <type>immediate</type>
            <testset_name>Quick Scan</testset_name>
          </schedule_audit>
        </actionset>
      </rule>
      <rule name='Requre Authentication' id='6' enabled='true'>
        <comment/>
        <selector>
          <and_conditions>
            <is_in_port_group>
              <port_group>corporate-agent-webauth</port_group>
            </is_in_port_group>
          </and_conditions>
          <and_conditions>
            <is_in_port_group>
              <port_group>corporate-webauth</port_group>
            </is_in_port_group>
          </and_conditions>
        </selector>
        <actionset>
          <exec_ruleset>
            <ruleset_name>Require Authentication</ruleset_name>
          </exec_ruleset>
        </actionset>
      </rule>
      <rule name='Move User to Production' id='7' enabled='true'>
        <comment/>
        <selector>
          <and_conditions>
            <is_health_ok>
              <healthstandard_name>Default</healthstandard_name>
            </is_health_ok>
          </and_conditions>
        </selector>
        <actionset>
          <exec_ruleset>
            <ruleset_name>Move to Production (user)</ruleset_name>
          </exec_ruleset>
        </actionset>
      </rule>
      <rule name='Move to Production' id='8' enabled='false'>
        <comment/>
        <selector>
          <and_conditions>
            <is_health_ok>
              <healthstandard_name>Default</healthstandard_name>
            </is_health_ok>
          </and_conditions>
        </selector>
        <actionset>
          <exec_ruleset>
            <ruleset_name>Move to Production</ruleset_name>
          </exec_ruleset>
        </actionset>
      </rule>
      <rule name='Handle Health Failure' id='9'>
        <selector>
          <and_conditions>
            <always_execute/>
          </and_conditions>
        </selector>
        <actionset>
          <exec_actionset>
            <actionset_name>Move to Quarantine</actionset_name>
          </exec_actionset>
        </actionset>
      </rule>
      <rule name='Request NAP Decision' id='10' enabled='false'>
        <comment/>
        <selector>
          <and_conditions>
            <always_execute/>
          </and_conditions>
        </selector>
        <actionset>
          <request_nap_decision>
            <realm>nap</realm>
          </request_nap_decision>
        </actionset>
      </rule>
    </ruleset>
    <ruleset name='Move to Production' protected='true'>
      <comment>This rule set can be used to ensure a device is finally moved into its production network.</comment>
      <rule name='Notify User' id='1' enabled='true'>
        <selector>
          <and_conditions>
            <is_attribute_set negate='true'>
              <attribute>in_production</attribute>
            </is_attribute_set>
          </and_conditions>
          <and_conditions>
            <is_trigger>
              <trigger>agent_on</trigger>
            </is_trigger>
          </and_conditions>
        </selector>
        <actionset>
          <user_log>
            <level>info</level>
            <title>Now in Production</title>
            <message>The Lockdown Enforcer has now placed you in Production.</message>
          </user_log>
        </actionset>
      </rule>
      <rule name='Execute Move' id='2' enabled='true'>
        <selector>
          <and_conditions>
            <always_execute/>
          </and_conditions>
        </selector>
        <actionset>
          <move_to_production/>
          <stop/>
        </actionset>
      </rule>
    </ruleset>
    <ruleset name='Scan With Dissolving Agent'>
      <comment>This rule set requires a Lockdown Agent only for the audit.</comment>
      <rule name='Require Agent' id='1'>
        <selector>
          <and_conditions>
            <is_attribute_set negate='true'>
              <attribute>agent_present</attribute>
            </is_attribute_set>
            <is_trigger negate='true'>
              <trigger>agent_off</trigger>
            </is_trigger>
          </and_conditions>
        </selector>
        <actionset>
          <move_to_zone>
            <zone>Quarantine</zone>
            <reason>The Lockdown Agent is required before access to the network is allowed.</reason>
          </move_to_zone>
          <show_agent/>
          <stop/>
        </actionset>
      </rule>
      <rule name='Require Immediate Audit w/ Quick Scan' id='2'>
        <selector>
          <and_conditions>
            <is_trigger negate='true'>
              <trigger>background</trigger>
            </is_trigger>
            <is_attribute_set negate='true'>
              <attribute>was_immediate_run</attribute>
            </is_attribute_set>
          </and_conditions>
        </selector>
        <actionset>
          <schedule_audit>
            <type>immediate</type>
            <testset_name>Quick Scan</testset_name>
          </schedule_audit>
          <move_to_zone>
            <zone>Quarantine</zone>
            <reason>An audit is being run to determine the health of your system.</reason>
          </move_to_zone>
          <stop/>
        </actionset>
      </rule>
      <rule name='Remove Agent' id='3'>
        <selector>
          <and_conditions>
            <is_attribute_set>
              <attribute>agent_present</attribute>
            </is_attribute_set>
            <is_health_ok>
              <healthstandard_name>Default</healthstandard_name>
            </is_health_ok>
          </and_conditions>
        </selector>
        <actionset>
          <uninstall_agent/>
        </actionset>
      </rule>
    </ruleset>
    <ruleset name='Wait for MAC/IP' immutable='true'>
      <comment>
    This rule set can be used when a MAC and an IP address is required.
  </comment>
      <rule name='Wait for MAC and IP' id='1'>
        <selector>
          <and_conditions>
            <is_attribute_set negate='true'>
              <attribute>mac</attribute>
            </is_attribute_set>
          </and_conditions>
          <and_conditions>
            <is_attribute_set negate='true'>
              <attribute>ip</attribute>
            </is_attribute_set>
          </and_conditions>
        </selector>
        <actionset>
          <move_to_zone>
            <zone>Quarantine</zone>
            <reason>Waiting to learn a MAC and an IP address.</reason>
          </move_to_zone>
          <stop/>
        </actionset>
      </rule>
    </ruleset>
    <ruleset name='Require Authentication' immutable='true'>
      <comment>This rule set can be used to require authentication.</comment>
      <rule name='Require Authentication' id='1'>
        <selector>
          <and_conditions>
            <is_attribute_set negate='true'>
              <attribute>is_authenticated</attribute>
            </is_attribute_set>
          </and_conditions>
        </selector>
        <actionset>
          <move_to_zone>
            <zone>Quarantine</zone>
            <reason>Authentication is required.</reason>
          </move_to_zone>
          <show_web_auth/>
          <stop/>
        </actionset>
      </rule>
      <rule name='Authentication Successful' id='2'>
        <selector>
          <and_conditions>
            <is_attribute_set negate='true'>
              <attribute>prev_match</attribute>
            </is_attribute_set>
          </and_conditions>
        </selector>
        <actionset>
          <uilog>
            <message>#{dev} has authenticated as #{user} via #{auth_type}</message>
          </uilog>
        </actionset>
      </rule>
    </ruleset>
    <ruleset name='Allow Before Audit' immutable='true'>
      <comment>
    This rule set can be used as a replacement for the Device Enforcement Rule Set. This one will still run a Quick Scan, but will allow devices on to the network right away and only quarantine them if the audit is failed.
  </comment>
      <rule name='Wait for MAC and IP' id='1'>
        <selector>
          <and_conditions>
            <always_execute/>
          </and_conditions>
        </selector>
        <actionset>
          <exec_ruleset>
            <ruleset_name>Wait for MAC/IP</ruleset_name>
          </exec_ruleset>
        </actionset>
      </rule>
      <rule name='Launch Quick Scan' id='2'>
        <selector>
          <and_conditions>
            <is_attribute_set negate='true'>
              <attribute>was_immediate_run</attribute>
            </is_attribute_set>
          </and_conditions>
        </selector>
        <actionset>
          <schedule_audit>
            <type>immediate</type>
            <testset_name>Quick Scan</testset_name>
          </schedule_audit>
        </actionset>
      </rule>
      <rule name='Handle Health Failure' id='3'>
        <selector>
          <and_conditions>
            <is_attribute_set>
              <attribute>was_immediate_run</attribute>
            </is_attribute_set>
            <is_health_ok negate='true'>
              <healthstandard_name>Default</healthstandard_name>
            </is_health_ok>
          </and_conditions>
        </selector>
        <actionset>
          <exec_actionset>
            <actionset_name>Move to Quarantine</actionset_name>
          </exec_actionset>
        </actionset>
      </rule>
      <rule name='Move to Production' id='4'>
        <selector>
          <and_conditions>
            <always_execute/>
          </and_conditions>
        </selector>
        <actionset>
          <exec_ruleset>
            <ruleset_name>Move to Production</ruleset_name>
          </exec_ruleset>
        </actionset>
      </rule>
    </ruleset>
    <ruleset name='Allow Last Audit Passed' immutable='true'>
      <comment>
    This rule set can be used as a replacement for the Device Enforcement Rule Set. This one will still run a Quick Scan, but will allow devices on to the network right away if they have audit results that pass.
  </comment>
      <rule name='Wait for MAC and IP' id='1'>
        <selector>
          <and_conditions>
            <always_execute/>
          </and_conditions>
        </selector>
        <actionset>
          <exec_ruleset>
            <ruleset_name>Wait for MAC/IP</ruleset_name>
          </exec_ruleset>
        </actionset>
      </rule>
      <rule name='Launch Quck Scan' id='2'>
        <selector>
          <and_conditions>
            <is_attribute_set negate='true'>
              <attribute>last_testset</attribute>
            </is_attribute_set>
          </and_conditions>
        </selector>
        <actionset>
          <schedule_audit>
            <type>immediate</type>
            <testset_name>Quick Scan</testset_name>
          </schedule_audit>
        </actionset>
      </rule>
      <rule name='Handle Health Failure' id='3'>
        <selector>
          <and_conditions>
            <is_attribute_set>
              <attribute>last_testset</attribute>
            </is_attribute_set>
            <is_health_ok negate='true'>
              <healthstandard_name>Default</healthstandard_name>
            </is_health_ok>
          </and_conditions>
        </selector>
        <actionset>
          <exec_actionset>
            <actionset_name>Move to Quarantine</actionset_name>
          </exec_actionset>
        </actionset>
      </rule>
      <rule name='Move to Production' id='4'>
        <selector>
          <and_conditions>
            <always_execute/>
          </and_conditions>
        </selector>
        <actionset>
          <exec_ruleset>
            <ruleset_name>Move to Production</ruleset_name>
          </exec_ruleset>
        </actionset>
      </rule>
    </ruleset>
    <ruleset name='Conference Room' immutable='true'>
      <comment>
    This is an example of how policy might be enforced for a particular conference room based on who has logged in. This can be used as a template to be called from the Device Enforcement Rule Set just after the rule for learning the IP. Note that this Rule Set makes use of some special names that either need to be in place or this set should be modified to use different values.
  </comment>
      <rule name='Check Conference Room' id='1'>
        <selector>
          <and_conditions>
            <is_in_port_group negate='true'>
              <port_group>Conference Room</port_group>
            </is_in_port_group>
          </and_conditions>
        </selector>
        <actionset>
          <stop>
            <context>ruleset</context>
          </stop>
        </actionset>
      </rule>
      <rule name='Require Authentication' id='2'>
        <selector>
          <and_conditions>
            <always_execute/>
          </and_conditions>
        </selector>
        <actionset>
          <exec_ruleset>
            <ruleset_name>Require Authentication</ruleset_name>
          </exec_ruleset>
        </actionset>
      </rule>
      <rule name='Require Group Membership' id='3'>
        <selector>
          <and_conditions>
            <is_attribute_set negate='true'>
              <attribute>user_groups</attribute>
            </is_attribute_set>
          </and_conditions>
        </selector>
        <actionset>
          <move_to_zone>
            <zone>Quarantine</zone>
            <reason>Waiting to learn user group membership for #{user}.</reason>
          </move_to_zone>
          <stop>
            <context>full</context>
          </stop>
        </actionset>
      </rule>
      <rule name='Handle Executives' id='4'>
        <selector>
          <and_conditions>
            <has_group_cn>
              <common_name>Executives</common_name>
            </has_group_cn>
          </and_conditions>
        </selector>
        <actionset>
          <set_attribute>
            <attribute>production_zone</attribute>
            <value>Executive VLAN</value>
          </set_attribute>
          <exec_ruleset>
            <ruleset_name>Allow Last Audit Passed</ruleset_name>
          </exec_ruleset>
        </actionset>
      </rule>
      <rule name='Handle Employees' id='5'>
        <selector>
          <and_conditions>
            <has_group_cn>
              <common_name>Employees</common_name>
            </has_group_cn>
          </and_conditions>
        </selector>
        <actionset>
          <exec_ruleset>
            <ruleset_name>Allow Before Audit</ruleset_name>
          </exec_ruleset>
        </actionset>
      </rule>
      <rule name='Handle Guests' id='6'>
        <comment>Note that this rule will fall through to the remainder of the policy. The only change here is to assign the device to a special VLAN.</comment>
        <selector>
          <and_conditions>
            <has_group_cn>
              <common_name>Guests</common_name>
            </has_group_cn>
          </and_conditions>
        </selector>
        <actionset>
          <set_attribute>
            <attribute>production_zone</attribute>
            <value>Guest VLAN</value>
          </set_attribute>
        </actionset>
      </rule>
    </ruleset>
    <ruleset name='Require Lockdown Agent' immutable='true'>
      <comment>This rule set can be used to require the Lockdown Agent.</comment>
      <rule name='Require Agent' id='1'>
        <selector>
          <and_conditions>
            <is_attribute_set negate='true'>
              <attribute>agent_present</attribute>
            </is_attribute_set>
          </and_conditions>
        </selector>
        <actionset>
          <move_to_zone>
            <zone>Quarantine</zone>
            <reason>The Lockdown Agent is required before access to the network is allowed.</reason>
          </move_to_zone>
          <show_agent/>
          <stop/>
        </actionset>
      </rule>
    </ruleset>
    <ruleset name='Move to Production (user)'>
      <comment>This rule set can be used to ensure a device is finally moved into its production network.</comment>
      <rule name='Notify User' id='1' enabled='true'>
        <selector>
          <and_conditions>
            <is_attribute_set negate='true'>
              <attribute>in_production</attribute>
            </is_attribute_set>
          </and_conditions>
          <and_conditions>
            <is_trigger>
              <trigger>agent_on</trigger>
            </is_trigger>
          </and_conditions>
        </selector>
        <actionset>
          <user_log>
            <level>info</level>
            <title>Now in Production</title>
            <message>The Lockdown Enforcer has now placed you in Production.</message>
          </user_log>
        </actionset>
      </rule>
      <rule name='Move Employees to Corporate VLAN' id='2' enabled='true'>
        <comment/>
        <selector>
          <and_conditions>
            <has_user_cn>
              <common_name>alice</common_name>
              <common_name>bob</common_name>
            </has_user_cn>
          </and_conditions>
        </selector>
        <actionset>
          <move_to_production/>
          <stop>
            <context>full</context>
          </stop>
        </actionset>
      </rule>
      <rule name='Move Guests to Guest VLAN' id='3' enabled='true'>
        <comment/>
        <selector>
          <and_conditions>
            <has_user_cn>
              <common_name>donna</common_name>
            </has_user_cn>
          </and_conditions>
        </selector>
        <actionset>
          <move_to_zone>
            <zone>guest</zone>
            <reason/>
          </move_to_zone>
          <stop>
            <context>full</context>
          </stop>
        </actionset>
      </rule>
      <rule name='Execute Move' id='4' enabled='true'>
        <selector>
          <and_conditions>
            <always_execute/>
          </and_conditions>
        </selector>
        <actionset>
          <move_to_production/>
          <stop/>
        </actionset>
      </rule>
    </ruleset>
    <actionset name='Move to Quarantine' protected='true'>
      <move_to_zone>
        <zone>Quarantine</zone>
        <reason>The "#{health}" health verification against the "#{last_testset}" audit test set has failed.</reason>
      </move_to_zone>
      <stop/>
    </actionset>
    <actionset name='Always in Quarantine' protected='true'>
      <move_to_zone>
        <zone>Quarantine</zone>
        <reason>Device #{dev} is a member of the Always in Quarantine group.</reason>
      </move_to_zone>
      <stop/>
    </actionset>
  </policy>