6.4. 使用 oscap
--help
选项加上oscap 命令:
oscap [options] module module_operation [module_operation_options_and_arguments] --help
例 6.4. 获取有关具体 oscap 操作的帮助
~]$ oscap ds sds-split --help
oscap -> ds -> sds-split
Split given SourceDataStream into separate files
Usage: oscap [options] ds sds-split [options] SDS TARGET_DIRECTORY
SDS - Source data stream that will be split into multiple files.
TARGET_DIRECTORY - Directory of the resulting files.
Options:
--datastream-id <id> - ID of the datastream in the collection to use.
--xccdf-id <id> - ID of XCCDF in the datastream that should be evaluated.
oscap(8)
手册页。
6.4.1. 安装 oscap
root
用户身份运行以下命令:
~]# yum install openscap-utils
~]$ oscap -V
OpenSCAP command line tool (oscap) 1.0.4
Copyright 2009--2014 Red Hat Inc., Durham, North Carolina.
==== Supported specifications ====
XCCDF Version: 1.2
OVAL Version: 5.10.1
CPE Version: 2.3
CVSS Version: 2.0
CVE Version: 2.0
Asset Identification Version: 1.1
Asset Reporting Format Version: 1.1
==== Capabilities added by auto-loaded plugins ====
SCE Version: 1.0 (from libopenscap_sce.so.8)
==== Paths ====
Schema files: /usr/share/openscap/schemas
Schematron files: /usr/share/openscap/xsl
Default CPE files: /usr/share/openscap/cpe
Probes: /usr/libexec/openscap
==== Inbuilt CPE names ====
Red Hat Enterprise Linux - cpe:/o:redhat:enterprise_linux
Red Hat Enterprise Linux 5 - cpe:/o:redhat:enterprise_linux:5
Red Hat Enterprise Linux 6 - cpe:/o:redhat:enterprise_linux:6
Red Hat Enterprise Linux 7 - cpe:/o:redhat:enterprise_linux:7
Fedora 16 - cpe:/o:fedoraproject:fedora:16
Fedora 17 - cpe:/o:fedoraproject:fedora:17
Fedora 18 - cpe:/o:fedoraproject:fedora:18
Fedora 19 - cpe:/o:fedoraproject:fedora:19
Fedora 20 - cpe:/o:fedoraproject:fedora:20
Fedora 21 - cpe:/o:fedoraproject:fedora:21
Red Hat Enterprise Linux Optional Productivity Applications - cpe:/a:redhat:rhel_productivity
Red Hat Enterprise Linux Optional Productivity Applications 5 - cpe:/a:redhat:rhel_productivity:5
==== Supported OVAL objects and associated OpenSCAP probes ====
system_info probe_system_info
family probe_family
filehash probe_filehash
environmentvariable probe_environmentvariable
textfilecontent54 probe_textfilecontent54
textfilecontent probe_textfilecontent
variable probe_variable
xmlfilecontent probe_xmlfilecontent
environmentvariable58 probe_environmentvariable58
filehash58 probe_filehash58
inetlisteningservers probe_inetlisteningservers
rpminfo probe_rpminfo
partition probe_partition
iflisteners probe_iflisteners
rpmverify probe_rpmverify
rpmverifyfile probe_rpmverifyfile
rpmverifypackage probe_rpmverifypackage
selinuxboolean probe_selinuxboolean
selinuxsecuritycontext probe_selinuxsecuritycontext
file probe_file
interface probe_interface
password probe_password
process probe_process
runlevel probe_runlevel
shadow probe_shadow
uname probe_uname
xinetd probe_xinetd
sysctl probe_sysctl
process58 probe_process58
fileextendedattribute probe_fileextendedattribute
routingtable probe_routingtable
/usr/share/xml/scap/ssg/rhel7/
目录下找到,而且您可以继续进行其他安全合规操作。
6.4.2. 显示 SCAP 内容
info
模块,解析文件,并以可读的格式提取相关信息。
oscap info
file
oscap info
命令的用法:
例 6.5. 显示 SCAP 内容信息
~]$ oscap info /usr/share/xml/scap/ssg/rhel7/ssg-rhel7-ds.xmal
Document type: Source Data Stream
Imported: 2014-03-14T12:22:01
Stream: scap_org.open-scap_datastream_from_xccdf_ssg-rhel7-xccdf-1.2.xml
Generated: (null)
Version: 1.2
Checklists:
Ref-Id: scap_org.open-scap_cref_ssg-rhel7-xccdf-1.2.xml
Profiles:
xccdf_org.ssgproject.content_profile_test
xccdf_org.ssgproject.content_profile_rht-ccp
xccdf_org.ssgproject.content_profile_common
xccdf_org.ssgproject.content_profile_stig-rhel7-server-upstream
Referenced check files:
ssg-rhel7-oval.xml
system: http://oval.mitre.org/XMLSchema/oval-definitions-5
Checks:
Ref-Id: scap_org.open-scap_cref_ssg-rhel7-oval.xml
Ref-Id: scap_org.open-scap_cref_output--ssg-rhel7-cpe-oval.xml
Ref-Id: scap_org.open-scap_cref_output--ssg-rhel7-oval.xml
Dictionaries:
Ref-Id: scap_org.open-scap_cref_output--ssg-rhel7-cpe-dictionary.xml
6.4.3. 扫描系统
oscap [options] module eval [module_operation_options_and_arguments]
XCCDF
(可扩展的配置检查清单描述格式)基准和 OVAL
(开放弱点评估语言)定义。安全策略可以以单独的OVAL文件或者XCCDF文件的形式存在,也可以以多个单独的 XML 文件的形式存在 ,这里每个 XML 文件代表了不同的组件(XCCDF, OVAL, CPE, CVE, 还有其他)。扫描结果可以打印为两种,标准输出和 XML 文件。结果文件可以经由 oscap 做进一步处理以便生成可读的报告。下面的例子说明了该命令最常见的用法。
例 6.6. 使用SSG OVAL 定义扫描系统
~]$ oscap oval eval --results
scan-oval-results.xml
/usr/share/xml/scap/ssg/rhel7/ssg-rhel7-ds.xml
scan-oval-results.xml
文件的方式保存在当前目录中。
例 6.7. 使用SSG OVAL 定义扫描系统
~]$ oscap oval eval --id
oval:ssg:def:100 --results
scan-oval-results.xml
/usr/share/xml/scap/ssg/rhel7/ssg-rhel7-ds.xml
scan-oval-results.xml
文件的方式保存在当前目录中。
例 6.8. 使用 SSG XCCDF 基准扫描系统
xccdf_org.ssgproject.content_profile_rht-ccp
配置文件执行 SSG XCCDF 基准测试,请运行以下命令:
~]$ oscap xccdf eval --profile
xccdf_org.ssgproject.content_profile_rht-ccp --results
scan-xccdf-results.xml
scan-xccdf-results.xml /usr/share/xml/scap/ssg/rhel7/ssg-rhel7-ds.xml
scan-xccdf-results.xml
文件的方式保存在当前目录中。
注意
--profile
命令行参数从给定的 XCCDF 或者数据流文件中选择安全配置文件。可用的配置文件列表可以通过运行 oscap info
命令来获取。如果 --profile
命令行参数被省略了,默认的 XCCDF 配置文件将根据 SCAP 标准的要求被使用。需要注意的是默认的 XCCDF 配置文件可能是,也可能不是一个合适的安全策略。
6.4.4. 生成报告和指南
oscap module generate sub-module [specific_module/sub-module_options_and_arguments] file
xccdf
或 oval
两者之一, sub-module 是一种生成的文档,并且 file 代表一个 XCCDF 或者 OVAL 文件。
例 6.9. 生成一份包含清单的指南
xccdf_org.ssgproject.content_profile_rht-ccp
配置文件生成一份包含清单的指南,请运行以下命令:
~]$ oscap xccdf generate guide --profile
xccdf_org.ssgproject.content_profile_rht-ccp
/usr/share/xml/scap/ssg/rhel7/ssg-rhel7-ds.xml
> ssg-guide-checklist.html
ssg-guide-checklist.html
文件的方式储存在当前目录下。
例 6.10. 将 SSG OVAL 扫描结果转换为报告
~]$oscap oval generate report
scan-oval-results.xml
>
ssg-scan-oval-report.html
ssg-scan-oval-report.html
文件的方式储存在当前目录下。此示例假定您从与 scan-oval-results.xml
文件存放的相同位置运行该命令。否则,您需要指定该文件及包含其扫描结果的完整路径。
例 6.11. 将SSG XCCDF 扫描结果转换为报告
~]$oscap xccdf generate report
scan-xccdf-results.xml
>
scan-xccdf-report.html
ssg-scan-xccdf-report.html
文件为名储存在当前目录下。 或者,您可以使用 --report
命令行参数在扫描过程中生成此报告。
~]$ oscap xccdf eval --profile
xccdf_org.ssgproject.content_profile_rht-ccp --results
scan-xccdf-results.xml
--report
scan-xccdf-report.html
/usr/share/xml/scap/ssg/rhel7/ssg-rhel7-ds.xml
6.4.5. 验证 SCAP 内容
oscap module validate [module_options_and_arguments] file
ds-validate
操作来代替 validate
。需要注意的是,所有给定数据流中的 SCAP 组件都会被自动验证,而且没有任何组件会被单独指定,这点从下面的例子中就可以看出:
~]$ oscap ds sds-validate /usr/share/xml/scap/ssg/rhel7/ssg-rhel7-ds.xml
~]$ oscap oval validate --schematron
/usr/share/xml/scap/ssg/rhel7/ssg-rhel7-ds.xml
为了尽快向用户提供最新的信息,本文档可能会包括由机器自动从英文原文翻译的内容。如需更多信息,请参阅此说明。