OVAL學習筆記

來源:互聯網
上載者:User

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_MACHINESOFTWARE\Policies\Microsoft\PCHealth\ErrorReporting\DWDWAllowHeadless
OVAL狀態

“狀態”(State)用來描述測試主體的參考狀態值,同OVAL對象類似,State也分為多種類型,每種類型的資料結構不相同,下面是一個passwordpolicy_state的定義:

可以在Value中使用Regex以更好的完成字串匹配工作。下面是一個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>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.