(2)OVAL Test(OVAL测试)
Test通过定义一组Object和State来执行测试,OVAL Test的数据结构如表4所示,而图3 则较为清晰地表达了Test 中Object 和State是如何相互配合执行测试的。
(3)OVAL Object(OVAL对象)
Object指明系统中用于测试的对象,由于OVAL中的Object分为多种类型,每种类型的Objec t 数据结构各不相同,如下面是一个passworkpolicy_object的定义,可以看出系统策略类的Object只需要指明一个id即可被解释器识别:
<passwordpolicy_object id="oval:gov.nis t.usgcb.
windowsseven:obj:27"version="2"/>
下面是一个registry_object的定义,可以看到注册表类Object需要指明注册表Hive、注册表路径和注册表项目名称:
<registry_objectid="oval:gov.nist.usgcb.winseven:obj:
16"version="2">
<hive>HKEY_LOCAL_MACHINE</hive>
<key>
SOFTWARE\Policies\Microsoft\PCHealth\ErrorReporting\DW
</key>
<name>DWAllowHeadless</name>
</registry_object>
(4)OVAL State(OVAL状态)
State指明用于测试的对象的状态值,同Object类似,State也分为多种类型,每种类型的State数据结构不相同,下面是一个passwordpol icy_state的定义:
<passwordpolicy_stateid="oval:gov.nist.usgcb.winseven:ste:33"version="2">
<min_ pas swd_ lenoper at ion="gr eat er than o r equal"datatype="int"var_ref="oval:gov.nist.usgcb.winseven:var:22"/>
</passwordpolicy_state>
下面是一个registry_state的定义,用来识别注册表中获取的值能与字符串“Windows 7”相匹配,可以在Value中使用正则表达式以更好的完成字符串匹配工作。
<r eg is t r y _ s t at e id=" oval:o rg.mi t r e. oval: s t e :5027"version="4"comment="Matches with Windows 7">
<valueoperation="pattern match">
^[a-zA-Z0-9\(\)\s]*[Ww][Ii][Nn][Dd][Oo][Ww][Ss] 7[a-zAZ0-9\(\)\s]*$
</value>
</registry_state>
可以看出,State中可以使得var_ref引用一个Variable对象表示State的值,或者直接将值写入到value节点中。
(5)OVAL Variable(OVAL变量)
Variable定义了执行测试时State所需的值,其有三种类型:constant_variable(常量)、local_variable(本地变量)和external_variable(外部变量)。Constant_variable定义一个不能在运行时改变的值,local_variable定义在OVAL中直接使用的值,而external_variable通常用于将XCCDF的Value值传递到OVAL中。下面是一个external类型的Variable定义:
<external_variableid="oval:gov.nist.usgcb.winseven:var:
22"version="2"comment="Minimum Password Length is
g r e at er than or e qu a l to t he pr e s c r i be d
value"datatype="int"/>
(6)典型的OVAL文档片段
下面展示了USGCB 1.2.0.0 版的用于Windows 7系统基线配置检查的OVAL文档的片段,通过这段XML代码,更能够加深我们对OVAL文档结构的理解。
<oval_definitions>
<!-- OVAL Definitions列表-->
<definitions>
<definitionid="oval:gov.nist.usgcb.windowsseven:def:1"version="2"class="compliance">
<metadata><title>Account Lockout Duration</title>……
</metadata>
<criteriaoperator="AND">
<e xt e nd_ def i ni t ioncomment="Windows 7 i s installed"definition_ref="oval:gov.nist.cpe.oval:def:1"/>
<criteriaoperator="OR">
<criterioncomment="Account Lockout Duration is set to …
"test_ref="oval:gov.nist.usgcb.windowsseven:tst:60070"/>
……
</definition>
……
<!-- 以下是Test列表-->
<tests>
<r e gi s t r y_ t e s t i d=" ov al :o r g.mi t r e . o va l : t s t :1 0 7 9 2 "ve r s i on=" 4 " comment="Windows 7 i s
installed"check_existence="at_least_one_exists"check="at least one">
<objectobject_ref="oval:org.mitre.oval:obj:5590"/>
<statestate_ref="oval:org.mitre.oval:ste:5027"/>
</registry_test>
......
<!-- 以下是Object列表-->
<objects>
<regis try_obje ct id=" oval: org.mit r e. oval: obj :219"version="1"comment="Identifies the system root.">
<hive>HKEY_LOCAL_MACHINE</hive>
<key>SOFTWARE\Microsoft\Windows NT\CurrentVersion
</key>
<name>Sy s t emRoot</name>
</regis t ry_object>
......
<!-- 以下是States列表(略)-->
<states>......</states>
<!-- 以下是Variable列表(略)-->
<variables>…</variables>
</oval_definitions>
特别声明:本站注明稿件来源为其他媒体的文/图等稿件均为转载稿,本站转载出于非商业性的教育和科研之目的,并不意味着赞同其观点或证实其内容的真实性。如转载稿涉及版权等问题,请作者在两周内速来电或来函联系。