6.4. oscap の使用
--help オプションを使用してください。
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) man ページを参照してください。
6.4.1. oscap のインストール
root で以下のコマンドを実行します。
~]# yum install openscap-scanner~]$ 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~]#yum install scap-security-guide
/usr/share/xml/scap/ssg/content/ ディレクトリーに格納され、他のセキュリティーコンプライアンス作業を進めることができます。
6.4.2. SCAP コンテンツの表示
info モジュールを使うことができます。これはファイルを解析し、ヒューマンリーダブルな形式で関連情報を抽出します。
oscap info fileoscap info コマンドの使用方法を示します。
例6.5 SCAP コンテンツの情報表示
~]$ oscap info /usr/share/xml/scap/ssg/content/ssg-rhel7-ds.xml
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.xml6.4.3. システムのスキャン
oscap [options] module eval [module_operation_options_and_arguments]XCCDF (eXtensible Configuration Checklist Description Format) ベンチマークと OVAL (Open Vulnerability and Assessment Language) 定義の両方で表示される SCAP コンテンツに対してシステムのスキャンを行うことができます。セキュリティーポリシーは単一の OVAL または XCCDF ファイルの場合もあれば、複数の別個の XML ファイルの場合もあります。後者の場合は、各ファイルが異なるコンポーネントを表します (XCCDF、OVAL、CPE、CVE、その他)。スキャン結果は、標準出力と XML ファイルの両方にプリントすることができます。この結果のファイルは oscap でさらに処理され、人間が判読可能な形式のレポートを生成することができます。以下は、このコマンドの最も一般的な使用例になります。
例6.6 SSG OVAL 定義を使用したシステムのスキャン
~]$ oscap oval eval --results scan-oval-results.xml /usr/share/xml/scap/ssg/content/ssg-rhel7-ds.xmlscan-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/content/ssg-rhel7-ds.xmlscan-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 /usr/share/xml/scap/ssg/content/ssg-rhel7-ds.xmlscan-xccdf-results.xml ファイルとして現在のディレクトリーに保存されます。
注記
--profile コマンドラインの引数は、特定の XCCDF またはデータストリームファイルからセキュリティープロファイルを選択します。利用可能なプロファイルの一覧は、oscap info コマンドを実行すると確認できます。--profile コマンドライン引数が省略されると、SCAP 標準で必要とされるデフォルトの XCCDF プロファイルが使用されます。デフォルトの XCCDF プロファイルは適切なセキュリティーポリシーである場合もありますが、そうでない場合もあることに注意してください。
6.4.4. レポートおよびガイドの生成
oscap module generate sub-module [specific_module/sub-module_options_and_arguments] filexccdf または 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/content/ssg-rhel7-ds.xml > ssg-guide-checklist.htmlssg-guide-checklist.html ファイルとして現在のディレクトリーに保存されます。
例6.10 SSG OVAL スキャン結果をレポートに変換する
~]$oscap oval generate reportscan-oval-results.xml>ssg-scan-oval-report.html
ssg-scan-oval-report.html ファイルとして現在のディレクトリーに保存されます。この例では、scan-oval-results.xml ファイルが保存されている場所からこのコマンドが実行されることを想定しています。それ以外の場合は、スキャン結果を含んでいるファイルの完全修飾パスを指定する必要があります。
例6.11 SSG XCCDF スキャン結果をレポートに変換する
~]$oscap xccdf generate reportscan-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/content/ssg-rhel7-ds.xml6.4.5. SCAP コンテンツの検証
oscap module validate [module_options_and_arguments] filevalidate ではなく sds-validate 演算を使用します。以下の例で示されているように、特定のデータストリーム内の SCAP コンポーネントは自動的に検証され、各コンポーネントは別個に指定されないことに注意してください。
~]$ oscap ds sds-validate /usr/share/xml/scap/ssg/content/ssg-rhel7-ds.xml~]$ oscap oval validate --schematron /usr/share/xml/scap/ssg/content/ssg-rhel7-ds.xml6.4.6. OpenSCAP を使用してシステムを修正
- OpenSCAP は XCCDF 評価を実行します。
- 結果の評価は、OVAL 定義を評価することによって実行されます。失敗した各ルールは修正の候補としてマークされます。
- OpenSCAP は適切な修正要素を検索および解決し、環境を準備して、修正スクリプトを実行します。
- 修正スクリプトの出力は OpenSCAP によって取得され、
rule-result要素内に格納されます。修正スクリプトの戻り値も格納されます。 - OpenSCAP が修正スクリプトを実行すると、すぐに OVAL 定義が再び評価されます (修正スクリプトが正しく適用されたことを検証します)。この 2 回目の実行時に、OVAL 評価が成功を返す場合、ルールの結果は
fixedになり、それ以外の場合はerrorになります。 - 修正の詳細な結果は出力 XCCDF ファイルに格納されます。このファイルには 2 つの
TestResult要素が含まれます。最初のTestResult要素は修正前のスキャンを表します。2 つ目のTestResultは最初の要素から派生し、修正結果を含みます。
6.4.6.1. OpenSCAP オンライン修正
--remediate コマンドラインオプションを使用します。たとえば、scap-security-guide パッケージを使用してオンライン修正を実行するには、以下のコマンドを実行します。
~]$oscap xccdf eval --remediate --profile xccdf_org.ssgproject.content_profile_rht-ccp --results scan-xccdf-results.xml /usr/share/xml/scap/ssg/content/ssg-rhel7-ds.xml
fixed と error の結果のみを含めることができます。fixed 結果は、スキャンが修正が合格した後に実行されたことを示します。error 結果は修正の適用後であっても評価が合格していないことを示します。
6.4.6.2. OpenSCAP オフライン修正
TestResult 要素に格納されます。
oscap が修正スクリプトを実行し、結果を検証します。データが失われないよう結果を入力ファイルに格納することが推奨されます。オフライン修正中に、OpenSCAP は入力ファイルに基づいて新しい TestResult 要素を作成し、すべてのデータを継承します。新しく作成された TestResult で異なる唯一の点は失敗した rule-result 要素です。これらの要素に対して修正が実行されます。
~]$oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_rht-ccp --results scan-xccdf-results.xml /usr/share/xml/scap/ssg/content/ssg-rhel7-ds.xml
~]$oscap xccdf remediate --results scan-xccdf-results.xml scan-xccdf-results.xml
6.4.6.3. OpenSCAP 修正レビュー
~]$oscap xccdf generate fix --template urn:xccdf:fix:script:sh --profile xccdf_org.ssgproject.content_profile_rht-ccp --output my-remediation-script.sh /usr/share/xml/scap/ssg/content/ssg-rhel7-ds.xml

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.