| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | |
| 3 | # i=0; |
| 4 | # IFS=$'\n' |
| 5 | # for line in `env`; do |
| 6 | # VAR=`echo $line | sed 's/\([A-Za-z_1-9]*\)=.*$/\1/'` |
| 7 | # if [ "x$VAR" == "x_" ] || [ "x$VAR" == "xSHLVL" ]; then |
| 8 | # continue; |
| 9 | # fi |
| 10 | # ENV_VAR[$i]="$VAR"; |
| 11 | # VAR_VAL[$i]=`echo $line | sed 's/\([A-Za-z_1-9]*\)=\(.*\)$/\2/'` |
| 12 | # i=$[$i+1]; |
| 13 | # done |
| 14 | |
| 15 | ENV_VAR=(`envscip-shell system . . env. | sedscip-shell system . . sed. -n 's|^\([A-Z]*\)=[a-zA-Z0-9/]\{1,\}$|\1|p' | egrepscip-shell system . . egrep. -v SHLVL`) |
| 16 | |
| 17 | I=0 |
| 18 | while [scip-shell system . . `[`. $I -lt ${#ENV_VAR[@]} ]; do |
| 19 | eval "VAL=\$${ENV_VAR[$I]}" |
| 20 | VAR_VAL[$I]=$VAL |
| 21 | I=$[$I+1] |
| 22 | done |
| 23 | |
| 24 | catscip-shell system . . cat. <<EOF |
| 25 | <?xml version="1.0"?> |
| 26 | <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#independent" 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#independent independent-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"> |
| 27 | |
| 28 | <generator> |
| 29 | <oval:product_name>environmentvariable58</oval:product_name> |
| 30 | <oval:product_version>1.0</oval:product_version> |
| 31 | <oval:schema_version>5.9</oval:schema_version> |
| 32 | <oval:timestamp>2011-07-13T00:00:00-00:00</oval:timestamp> |
| 33 | </generator> |
| 34 | |
| 35 | <definitions> |
| 36 | |
| 37 | <definition class="compliance" version="1" id="oval:1:def:1"> <!-- comment="false" --> |
| 38 | <metadata> |
| 39 | <title></title> |
| 40 | <description></description> |
| 41 | </metadata> |
| 42 | <criteria> |
| 43 | <criteria operator="OR"> |
| 44 | <criterion test_ref="oval:1:tst:1"/> |
| 45 | EOF |
| 46 | I=0 |
| 47 | while [scip-shell system . . `[`. $I -lt ${#ENV_VAR[@]} ]; do |
| 48 | catscip-shell system . . cat. <<EOF |
| 49 | <criterion test_ref="oval:1:tst:$[I+2]"/> |
| 50 | EOF |
| 51 | I=$[$I+1] |
| 52 | done |
| 53 | |
| 54 | catscip-shell system . . cat. <<EOF |
| 55 | </criteria> |
| 56 | </criteria> |
| 57 | </definition> |
| 58 | |
| 59 | </definitions> |
| 60 | |
| 61 | <tests> |
| 62 | |
| 63 | <!-- DEFAULT STATELESS OBJECT --> |
| 64 | |
| 65 | <!-- check="all" --> |
| 66 | |
| 67 | <environmentvariable58_test version="1" id="oval:1:tst:1" check="at least one" comment="false" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent"> |
| 68 | <object object_ref="oval:1:obj:1"/> |
| 69 | <state state_ref="oval:1:ste:1"/> |
| 70 | </environmentvariable58_test> |
| 71 | EOF |
| 72 | I=0 |
| 73 | while [scip-shell system . . `[`. $I -lt ${#ENV_VAR[@]} ]; do |
| 74 | catscip-shell system . . cat. <<EOF |
| 75 | <environmentvariable58_test version="1" id="oval:1:tst:$[I+2]" check="at least one" comment="false" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent"> |
| 76 | <object object_ref="oval:1:obj:2"/> |
| 77 | <state state_ref="oval:1:ste:$[I+2]"/> |
| 78 | </environmentvariable58_test> |
| 79 | EOF |
| 80 | I=$[$I+1] |
| 81 | done |
| 82 | |
| 83 | catscip-shell system . . cat. <<EOF |
| 84 | </tests> |
| 85 | |
| 86 | <objects> |
| 87 | |
| 88 | <environmentvariable58_object version="1" id="oval:1:obj:1" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent"> |
| 89 | <pid datatype="int" xsi:nil="true" /> |
| 90 | <name operation="not equal">${ENV_VAR[1]}</name> |
| 91 | </environmentvariable58_object> |
| 92 | |
| 93 | <environmentvariable58_object version="1" id="oval:1:obj:2" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent"> |
| 94 | <pid datatype="int" xsi:nil="true" /> |
| 95 | <name operation="pattern match">_</name> |
| 96 | </environmentvariable58_object> |
| 97 | |
| 98 | </objects> |
| 99 | |
| 100 | <states> |
| 101 | |
| 102 | <environmentvariable58_state version="1" id="oval:1:ste:1" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent"> |
| 103 | <pid operation="greater than" datatype="int">1</pid> |
| 104 | <name>${ENV_VAR[1]}</name> |
| 105 | <value>${VAR_VAL[1]}</value> |
| 106 | </environmentvariable58_state> |
| 107 | EOF |
| 108 | |
| 109 | I=0 |
| 110 | while [scip-shell system . . `[`. $I -lt ${#ENV_VAR[@]} ]; do |
| 111 | catscip-shell system . . cat. <<EOF |
| 112 | <environmentvariable58_state version="1" id="oval:1:ste:$[$I+2]" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent"> |
| 113 | <pid operation="greater than" datatype="int">$$</pid> |
| 114 | <name>${ENV_VAR[$I]}</name> |
| 115 | <value>${VAR_VAL[$I]}</value> |
| 116 | </environmentvariable58_state> |
| 117 | EOF |
| 118 | I=$[$I+1] |
| 119 | done |
| 120 | |
| 121 | catscip-shell system . . cat. <<EOF |
| 122 | |
| 123 | </states> |
| 124 | |
| 125 | </oval_definitions> |
| 126 | EOF |
| 127 | |
| 128 | exit $(( ${#ENV_VAR[@]} + 2 )) |