| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | BOOLEANS=(`getsebool -a | cut -d " " -f 1 | head -n 3`) |
| 4 | |
| 5 | I=0 |
| 6 | while [ $I -lt ${#BOOLEANS[@]} ]; do |
| 7 | STATE=`getsebool ${BOOLEANS[$I]} | cut -d " " -f 3` |
| 8 | if [ $STATE = "on" ]; then |
| 9 | BOOLEAN_VAR_N=1 |
| 10 | BOOLEAN_VAR_S="true" |
| 11 | else |
| 12 | BOOLEAN_VAR_N=0 |
| 13 | BOOLEAN_VAR_S="false" |
| 14 | fi |
| 15 | BOOLEANS_VAL_N[$I]=$BOOLEAN_VAR_N |
| 16 | BOOLEANS_VAL_S[$I]=$BOOLEAN_VAR_S |
| 17 | I=$[$I+1] |
| 18 | done |
| 19 | |
| 20 | cat <<EOF |
| 21 | <?xml version="1.0"?> |
| 22 | <oval_definitions xmlns:oval-def="http://oval.mitre.org/XMLSchema/oval-definitions-5" xmlns:oval="http://oval.mitre.org/XMLSchema/oval-common-5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ind-def="http://oval.mitre.org/XMLSchema/oval-definitions-5#linux" xmlns:unix-def="http://oval.mitre.org/XMLSchema/oval-definitions-5#unix" xmlns:lin-def="http://oval.mitre.org/XMLSchema/oval-definitions-5#linux" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5" xsi:schemaLocation="http://oval.mitre.org/XMLSchema/oval-definitions-5#unix unix-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5#linux linux-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5#linux linux-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5 oval-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-common-5 oval-common-schema.xsd"> |
| 23 | |
| 24 | <generator> |
| 25 | <oval:product_name>selinuxboolean</oval:product_name> |
| 26 | <oval:product_version>1.0</oval:product_version> |
| 27 | <oval:schema_version>5.9</oval:schema_version> |
| 28 | <oval:timestamp>2011-07-13T00:00:00-00:00</oval:timestamp> |
| 29 | </generator> |
| 30 | |
| 31 | <definitions> |
| 32 | |
| 33 | <definition class="compliance" version="1" id="oval:1:def:1"> <!-- comment="false" --> |
| 34 | <metadata> |
| 35 | <title></title> |
| 36 | <description></description> |
| 37 | </metadata> |
| 38 | <criteria> |
| 39 | <criteria operator="OR"> |
| 40 | <criterion test_ref="oval:1:tst:1"/> |
| 41 | EOF |
| 42 | I=0 |
| 43 | while [ $I -lt ${#BOOLEANS[@]} ]; do |
| 44 | cat <<EOF |
| 45 | <criterion test_ref="oval:1:tst:$[I+2]"/> |
| 46 | EOF |
| 47 | I=$[$I+1] |
| 48 | done |
| 49 | |
| 50 | cat <<EOF |
| 51 | </criteria> |
| 52 | </criteria> |
| 53 | </definition> |
| 54 | |
| 55 | </definitions> |
| 56 | |
| 57 | <tests> |
| 58 | |
| 59 | <!-- DEFAULT STATELESS OBJECT --> |
| 60 | |
| 61 | <!-- check="all" --> |
| 62 | |
| 63 | <selinuxboolean_test version="1" id="oval:1:tst:1" check="at least one" comment="false" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#linux"> |
| 64 | <object object_ref="oval:1:obj:1"/> |
| 65 | <state state_ref="oval:1:ste:1"/> |
| 66 | </selinuxboolean_test> |
| 67 | EOF |
| 68 | I=0 |
| 69 | while [ $I -lt ${#BOOLEANS[@]} ]; do |
| 70 | cat <<EOF |
| 71 | <selinuxboolean_test version="1" id="oval:1:tst:$[I+2]" check="at least one" comment="false" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#linux"> |
| 72 | <object object_ref="oval:1:obj:2"/> |
| 73 | <state state_ref="oval:1:ste:$[I+2]"/> |
| 74 | </selinuxboolean_test> |
| 75 | EOF |
| 76 | I=$[$I+1] |
| 77 | done |
| 78 | |
| 79 | cat <<EOF |
| 80 | </tests> |
| 81 | |
| 82 | <objects> |
| 83 | |
| 84 | <selinuxboolean_object version="1" id="oval:1:obj:1" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#linux"> |
| 85 | <name operation="not equal">${BOOLEANS[1]}</name> |
| 86 | </selinuxboolean_object> |
| 87 | |
| 88 | <selinuxboolean_object version="1" id="oval:1:obj:2" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#linux"> |
| 89 | <name operation="pattern match">-</name> |
| 90 | </selinuxboolean_object> |
| 91 | |
| 92 | </objects> |
| 93 | |
| 94 | <states> |
| 95 | |
| 96 | <selinuxboolean_state version="1" id="oval:1:ste:1" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#linux"> |
| 97 | <name>${BOOLEANS[1]}</name> |
| 98 | <current_status datatype="boolean">${BOOLEANS_VAL_S[1]}</current_status> |
| 99 | <pending_status datatype="boolean">${BOOLEANS_VAL_S[1]}</pending_status> |
| 100 | |
| 101 | </selinuxboolean_state> |
| 102 | EOF |
| 103 | |
| 104 | I=0 |
| 105 | while [ $I -lt ${#BOOLEANS[@]} ]; do |
| 106 | cat <<EOF |
| 107 | <selinuxboolean_state version="1" id="oval:1:ste:$[$I+2]" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#linux"> |
| 108 | <name>${BOOLEANS[$I]}</name> |
| 109 | <current_status datatype="boolean">${BOOLEANS_VAL_N[$I]}</current_status> |
| 110 | <pending_status datatype="boolean">${BOOLEANS_VAL_N[$I]}</pending_status> |
| 111 | </selinuxboolean_state> |
| 112 | EOF |
| 113 | I=$[$I+1] |
| 114 | done |
| 115 | |
| 116 | cat <<EOF |
| 117 | |
| 118 | </states> |
| 119 | </oval_definitions> |
| 120 | EOF |
| 121 | |
| 122 | exit $(( ${#BOOLEANS[@]} + 1 )) |