OVAL学习笔记


OVAL由MITRE公司开发,是一种用来定义检查项、脆弱点等技术细节的一种描述语言。OVAL同样使用标准的XML格式组织其内容。它提供了足够的灵活性,可以用于分析Windows、Linux、Unix以及各种嵌入式操作系统的系统状态、漏洞、配置、补丁等情况,而且还能用于描述测试报告。OVAL能够清晰地对与安全相关的检查点作出描述,并且这种描述是机器可读的,能够直接应用到自动化的安全扫描中。OVAL的核心是“公开”(Open),这就意味着任何人都可以为OVAL的发展作出自己的贡献,共享知识和经验,避免重复劳动。 实际上XCCDF设计的目标是能够支持与多种基础配置检查技术交互。其中推荐的,默认的检查技术是MITRE公司的OVAL。在实际的SCAP应用中,XCCDF和OVAL往往是成对出现,XCCDF定义检查单,而OVAL定义每个检查项的具体实施细节。

OVAL以XML格式描述,包含如下几种XML格式(Schema):OVAL定义格式(OVAL Definition Schema),OVAL系统特性格式(OVAL System Characteristics Schema)与OVAL结果格式(OVAL Result Schema)。OVAL系统特性格式用于描述系统信息快照,该快照可用于和OVAL定义文件进行匹配以得出评估结果,OVAL结果格式用于描述评估结果。 \

在三种OVAL格式中,OVAL定义格式占有较为重要的位置,OVAL定义格式提供了一种机器可读的对系统进行安全评估的操作指南,它可用来描述系统的配置信息、分析系统的安全状态、报告评估结果等。典型的OVAL定义格式的XML文档由定义(Definition)、测试(Test)、对象(Object)、状态(State)和变量(Variable)等要素构成,其结构比较简单,主要是将各个要素以枚举的方式列出,如下图所示。 \

“定义”是最重要的构成元素,它会引用一个或多个“测试”,根据“测试”的结果综合判定整体的结果,“测试”使用“对象”和“状态”与系统交互并得出检查结果,“状态”可以使用固定值或引用“变量”中的值。OVAL各组成要素之间的逻辑关系如下图。在下图中,Definition1包含两个“测试”Test1和Test2,假设其判定标准为AND的逻辑关系,那么如果两个Test均为True,整个Definition1结果为True。举例来说,如果Test1测试结果为True,Test2测试结果为False,根据Definition1中的判定条件Test1=True AND Test2=True,整个Definition的测试结果为False。

\

OVAL定义

“定义”(Definition)用于描述如何对某一特定安全问题进行检查,通常一个OVAL文档中包含多个“定义”。主要有四类定义,分别是漏洞(Vulnerability):描述如何根据系统状态判定系统中是否存在某个特定漏洞;补丁(Patch):与漏洞定义类似,但它更关注如何判定系统中是否安装了某个特定补丁;软件(Inventory):描述如何对系统中是否安装了某个特定的软件进行判定;合规(Compliance):描述如何对系统是否满足某个特定的配置要求进行判定。表1是一个OVAL定义的示例数据。

规则字段 释义 示例数据
id Definition的标识,必须是全局唯一的 oval:gov.nist.usgcb.winseven:def:7
version Definition的版本 2
class 指定Definition的类别(漏洞、补丁、软件、合规等) Compliance
metadata(元标记):
title Definition的标题 Minimum Password Length
affected 会受到影响的操作系统或应用程序名称及版本 Microsoft Windows 7
references 此Definition与其它检查单或文档的映射关系 NIST SP800-68 Appendix A,1.4b
http://cce.mitre.org
CCE-9357-5
description Definition的描述 Minimum Password Length
Criteria(判定标准):
extend_definition definition_ref 另一个Definition的标识(当此Definition需要协同使用另一个Definition时) oval:gov.nist.cpe.oval:def:1
extend_definition comment 一般用于指出协同使用上述Definition的原因,本例中是用于判定目标操作系统是否符合要求 Windows 7 is installed
criterion test_ref 此Definition所使用的Test的标识 oval:gov.nist.usgcb.winseven:tst:36
criterion comment 通常是一段人工可读的语言用于描述出上述Test的检测行为 Minimum Password Length is greater than or equal to the prescribed value

OVAL测试

“测试”(Test)通过定义一组OVAL对象(Object)和OVAL状态(State)执行,OVAL 测试的数据结构如表2所示,而图2则较为清晰地表达了OVAL测试中OVAL对象与OVAL状态是如何相互配合执行测试。

规则字段 释义 示例数据
测试类型 通过不同的节点名字表达不同的测试类型,如文件、注册表、策略等 passwordpolicy_test
id 此Test的唯一标识 oval:gov.nist.usgcb.winsseven:tst:36
version Test的版本 2
check_existence 是否要求必需存在(如注册表键值) at_least_one_exists
object_ref 此Test使用的Object的id oval:gov.nist.usgcb.winseven:obj:27
state_ref 此Test使用的State的id oval:gov.nist.usgcb.winseven:ste:33

OVAL对象

“对象”(Object)用来描述测试主体,由于测试主体类别众多(如注册表、组策略、文件、软件包等),因此Object的类型也很多,且每种类型的数据结构各不相同。下面是一个passworkpolicy_object的定义,可以看出系统策略类的OVAL对象只需要指明一个id即可被解释器识别:

下面是一个registry_object的定义,可以看到注册表类OVAL对象需要指明注册表Hive、注册表键和注册表项的名称:


HKEY_LOCAL_MACHINE
SOFTWARE\Policies\Microsoft\PCHealth\ErrorReporting\DW
DWAllowHeadless

OVAL状态

“状态”(State)用来描述测试主体的参考状态值,同OVAL对象类似,State也分为多种类型,每种类型的数据结构不相同,下面是一个passwordpolicy_state的定义:

可以在Value中使用正则表达式以更好的完成字符串匹配工作。下面是一个registry_state的定义,用来识别注册表中获取的值能与字符串“Windows 7”相匹配。

^[a-zA-Z0-9\(\)\s]*[Ww][Ii][Nn][Dd][Oo][Ww][Ss] 7[a-zA-Z0-9\(\)\s]*$

可以看出,OVAL状态中可以使用var_ref引用一个OVAL变量表示OVAL状态的值,或者直接将值写入到value节点中。

OVAL变量

“变量”(Variable)定义了执行测试时State所需的值,其有三种类型:常量(constant_variable)、本地变量(local_variable)和外部变量(external_variable)。常量定义一个不能在运行时改变的值,本地变量定义在OVAL中直接使用的值,而外部变量通常用于将XCCDF的Value值传递到OVAL中。下面是一个外部变量的定义:

下面是小弟自己写的验证系统是否为win10的oval:

<?xml version="1.0" encoding="UTF-8"?>

-<oval_definitions xsi:schemaLocation="http://oval.mitre.org/XMLSchema/oval-definitions-5 oval-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5#windows windows-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5#independent independent-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-common-5 oval-common-schema.xsd" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oval="http://oval.mitre.org/XMLSchema/oval-common-5" xmlns:oval-def="http://oval.mitre.org/XMLSchema/oval-definitions-5">


<generator>

<oval:product_name>The OVAL Repository</oval:product_name>

<oval:schema_version>5.10.1</oval:schema_version>

<oval:timestamp>2015-07-24T02:18:25.200-04:00</oval:timestamp>

</generator>


<definitions>


<definition xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5" class="inventory" version="3" id="oval:org.mitre.oval:def:28779">


<metadata>

<title>Microsoft Windows 10 Insider Preview is installed</title>


<affected family="windows">

<platform>Microsoft Windows 10 Insider Preview</platform>

</affected>

<reference ref_id="microsoft_windows_10_insider_preview" source="ICM"/>

<description>The operating system installed on the system is Microsoft Windows 10 Insider Preview.</description>


<oval_repository>


<dates>


<submitted date="2015-05-07T08:31:03">

<contributor organization="ALTX-SOFT">Maria Mikhno</contributor>

</submitted>

<status_change date="2015-05-12T14:33:42.950-04:00">DRAFT</status_change>

<status_change date="2015-06-01T04:00:20.683-04:00">INTERIM</status_change>

<status_change date="2015-06-22T04:00:44.312-04:00">ACCEPTED</status_change>

</dates>

<status>ACCEPTED</status>

</oval_repository>

</metadata>


<criteria>

<criterion test_ref="oval:org.mitre.oval:tst:99" comment="the installed operating system is part of the Microsoft Windows family"/>

<criterion test_ref="oval:org.mitre.oval:tst:138532" comment="Check if Microsoft Windows 10 Insider Preview is installed"/>

</criteria>

</definition>

</definitions>


<tests>


<family_test xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" version="1" id="oval:org.mitre.oval:tst:99" comment="the installed operating system is part of the Microsoft Windows family" check="only one" check_existence="at_least_one_exists">

<object object_ref="oval:org.mitre.oval:obj:99"/>

<state state_ref="oval:org.mitre.oval:ste:99"/>

</family_test>


<registry_test xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#windows" version="1" id="oval:org.mitre.oval:tst:138532" comment="Check if Microsoft Windows 10 Insider Preview is installed" check="all" check_existence="at_least_one_exists">

<object object_ref="oval:org.mitre.oval:obj:5590"/>

<state state_ref="oval:org.mitre.oval:ste:38384"/>

</registry_test>

</tests>


<objects>

<family_object xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" version="1" id="oval:org.mitre.oval:obj:99" comment="This is the default family object. Only one family object should exist."/>


<registry_object xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#windows" version="1" id="oval:org.mitre.oval:obj:5590" comment="This registry key identifies the Windows ProductName">

<hive datatype="string">HKEY_LOCAL_MACHINE</hive>

<key datatype="string">SOFTWARE\Microsoft\Windows NT\CurrentVersion</key>

<name datatype="string">ProductName</name>

</registry_object>

</objects>


<states>


<family_state xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" version="2" id="oval:org.mitre.oval:ste:99" comment="Microsoft Windows family">

<family operation="case insensitive equals">windows</family>

</family_state>


<registry_state xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#windows" version="1" id="oval:org.mitre.oval:ste:38384" comment="The registry key matches with Windows 10 Insider Preview">

<value operation="pattern match">^.*Windows.*10.*Insider.*Preview.*$</value>

</registry_state>

</states>

</oval_definitions>

相关内容