Debian Codegraph @

tests/probes/environmentvariable58/test_probes_environmentvariable58.xml.sh

raw symbols SCIP
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 C=$I
25
26 catscip-shell system . . cat. <<EOF
27 <?xml version="1.0"?>
28 <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">
29
30 <generator>
31 <oval:product_name>environmentvariable58</oval:product_name>
32 <oval:product_version>1.0</oval:product_version>
33 <oval:schema_version>5.9</oval:schema_version>
34 <oval:timestamp>2011-07-13T00:00:00-00:00</oval:timestamp>
35 </generator>
36
37 <definitions>
38
39 <definition class="compliance" version="1" id="oval:1:def:1"> <!-- comment="true" -->
40 <metadata>
41 <title></title>
42 <description></description>
43 </metadata>
44 <criteria>
45 <criteria operator="AND">
46 EOF
47 I=0
48 while [scip-shell system . . `[`. $I -lt ${#ENV_VAR[@]} ]; do
49 echoscip-shell system . . echo. "<criterion test_ref=\"oval:1:tst:$[$I+1]\"/>"
50 echoscip-shell system . . echo. "<criterion test_ref=\"oval:1:tst:$[$C+$I+1]\"/>"
51 I=$[$I+1]
52 done
53 I=0
54 while [scip-shell system . . `[`. $I -lt $(( ${#ENV_VAR[@]} - 1 )) ]; do
55 echoscip-shell system . . echo. "<criterion test_ref=\"oval:1:tst:$[$C+$C+$I+1]\"/>"
56 I=$[$I+1]
57 done
58 catscip-shell system . . cat. <<EOF
59 </criteria>
60 </criteria>
61 </definition>
62
63 </definitions>
64
65 <tests>
66
67 <!-- DEFAULT STATELESS OBJECT -->
68
69 <!-- check="all" -->
70
71 EOF
72
73 I=0
74 while [scip-shell system . . `[`. $I -lt ${#ENV_VAR[@]} ]; do
75 catscip-shell system . . cat. <<EOF
76 <environmentvariable58_test version="1" id="oval:1:tst:$[$I+1]" check="at least one" comment="true" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
77 <object object_ref="oval:1:obj:$[$I+1]"/>
78 <state state_ref="oval:1:ste:$[$I+1]"/>
79 </environmentvariable58_test>
80
81 <environmentvariable58_test version="1" id="oval:1:tst:$[$C+$I+1]" check="at least one" comment="true" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
82 <object object_ref="oval:1:obj:$[$C+1]"/>
83 <state state_ref="oval:1:ste:$[$C+$I+1]"/>
84 </environmentvariable58_test>
85 EOF
86 I=$[$I+1]
87 done
88
89 I=0
90 while [scip-shell system . . `[`. $I -lt $(( ${#ENV_VAR[@]} - 1 )) ]; do
91 catscip-shell system . . cat. <<EOF
92 <environmentvariable58_test version="1" id="oval:1:tst:$[$C+$C+$I+1]" check="at least one" comment="true" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
93 <object object_ref="oval:1:obj:$[$C+2]"/>
94 <state state_ref="oval:1:ste:$[$C+$C+$I+1]"/>
95 </environmentvariable58_test>
96 EOF
97 I=$[$I+1]
98 done
99
100 catscip-shell system . . cat. <<EOF
101
102 </tests>
103
104 <objects>
105
106 EOF
107
108 I=0
109 while [scip-shell system . . `[`. $I -lt ${#ENV_VAR[@]} ]; do
110 catscip-shell system . . cat. <<EOF
111 <environmentvariable58_object version="1" id="oval:1:obj:$[$I+1]" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
112 <pid datatype="int" xsi:nil="true" />
113 <name>${ENV_VAR[$I]}</name>
114 </environmentvariable58_object>
115
116 EOF
117 I=$[$I+1]
118 done
119
120 catscip-shell system . . cat. <<EOF
121 <environmentvariable58_object version="1" id="oval:1:obj:$[$I+1]" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
122 <pid datatype="int" xsi:nil="true" />
123 <name operation="pattern match">.*</name>
124 </environmentvariable58_object>
125
126 <environmentvariable58_object version="1" id="oval:1:obj:$[$I+2]" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
127 <pid datatype="int" xsi:nil="true" />
128 <name operation="not equal">${ENV_VAR[$I-1]}</name>
129 </environmentvariable58_object>
130
131 <environmentvariable58_object version="1" id="oval:1:obj:$[$I+3]" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
132 <pid datatype="int">$$</pid>
133 <name>PATH</name>
134 </environmentvariable58_object>
135
136 EOF
137 catscip-shell system . . cat. <<EOF
138
139 </objects>
140
141 <states>
142
143 EOF
144
145 I=0
146 while [scip-shell system . . `[`. $I -lt ${#ENV_VAR[@]} ]; do
147 catscip-shell system . . cat. <<EOF
148 <environmentvariable58_state version="1" id="oval:1:ste:$[$I+1]" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
149 <pid operation="greater than" datatype="int">1</pid>
150 <name>${ENV_VAR[$I]}</name>
151 <value>${VAR_VAL[$I]}</value>
152 </environmentvariable58_state>
153
154 <environmentvariable58_state version="1" id="oval:1:ste:$[$C+$I+1]" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
155 <pid operation="greater than" datatype="int">1</pid>
156 <name>${ENV_VAR[$I]}</name>
157 <value>${VAR_VAL[$I]}</value>
158 </environmentvariable58_state>
159
160 EOF
161 I=$[$I+1]
162 done
163
164 I=0
165 while [scip-shell system . . `[`. $I -lt $(( ${#ENV_VAR[@]} - 1 )) ]; do
166 catscip-shell system . . cat. <<EOF
167 <environmentvariable58_state version="1" id="oval:1:ste:$[$C+$C+$I+1]" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
168 <pid operation="greater than" datatype="int">1</pid>
169 <name>${ENV_VAR[$I]}</name>
170 <value>${VAR_VAL[$I]}</value>
171 </environmentvariable58_state>
172 EOF
173 I=$[$I+1]
174 done
175
176 catscip-shell system . . cat. <<EOF
177 </states>
178
179 </oval_definitions>
180 EOF
181
182 exit $(( 3 * ${#ENV_VAR[@]}))