Skip to content

Commit 7bdecd0

Browse files
committed
Merge branch 'maint-1.3'
2 parents e90df48 + 5e1dbfb commit 7bdecd0

8 files changed

+41
-62
lines changed

CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ cmake_dependent_option(ENABLE_OSCAP_UTIL_AS_RPM "enable the scap-as-rpm utility,
330330
cmake_dependent_option(ENABLE_OSCAP_UTIL_SSH "enables the oscap-ssh utility, this lets you scan remote machines over ssh" ON "NOT WIN32" OFF)
331331
cmake_dependent_option(ENABLE_OSCAP_UTIL_VM "enables the oscap-vm utility, this lets you scan VMs and VM storage images" ON "NOT WIN32" OFF)
332332
cmake_dependent_option(ENABLE_OSCAP_UTIL_PODMAN "enables the oscap-podman utility, this lets you scan Podman containers and container images" ON "NOT WIN32" OFF)
333-
cmake_dependent_option(ENABLE_OSCAP_UTIL_BOOTC "enables the oscap-bootc utility, this lets you build hardened bootable container images" ON "NOT WIN32" OFF)
333+
cmake_dependent_option(ENABLE_OSCAP_UTIL_IM "enables the oscap-im utility, this lets you build hardened bootable container images" ON "NOT WIN32" OFF)
334334
cmake_dependent_option(ENABLE_OSCAP_UTIL_CHROOT "enables the oscap-chroot utility, this lets you scan entire chroots using offline scanning" ON "NOT WIN32" OFF)
335335
option(ENABLE_OSCAP_UTIL_AUTOTAILOR "enables the autotailor utility that is able to perform command-line tailoring" TRUE)
336336
option(ENABLE_OSCAP_REMEDIATE_SERVICE "enables the oscap-remediate service" FALSE)
@@ -468,7 +468,7 @@ message(STATUS "scap-as-rpm: ${ENABLE_OSCAP_UTIL_AS_RPM}")
468468
message(STATUS "oscap-ssh: ${ENABLE_OSCAP_UTIL_SSH}")
469469
message(STATUS "oscap-vm: ${ENABLE_OSCAP_UTIL_VM}")
470470
message(STATUS "oscap-podman: ${ENABLE_OSCAP_UTIL_PODMAN}")
471-
message(STATUS "oscap-bootc: ${ENABLE_OSCAP_UTIL_BOOTC}")
471+
message(STATUS "oscap-im: ${ENABLE_OSCAP_UTIL_IM}")
472472
message(STATUS "oscap-chroot: ${ENABLE_OSCAP_UTIL_CHROOT}")
473473
message(STATUS "autotailor: ${ENABLE_OSCAP_UTIL_AUTOTAILOR}")
474474
message(STATUS " ")

docs/manual/manual.adoc

+8-17
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,6 @@ Checklists:
189189
system: http://scap.nist.gov/schema/ocil/2
190190
security-data-oval-com.redhat.rhsa-RHEL8.xml
191191
system: http://oval.mitre.org/XMLSchema/oval-definitions-5
192-
Checks:
193-
Ref-Id: scap_org.open-scap_cref_ssg-rhel8-oval.xml
194-
Ref-Id: scap_org.open-scap_cref_ssg-rhel8-ocil.xml
195-
Ref-Id: scap_org.open-scap_cref_ssg-rhel8-cpe-oval.xml
196-
Ref-Id: scap_org.open-scap_cref_security-data-oval-com.redhat.rhsa-RHEL8.xml
197-
Dictionaries:
198-
Ref-Id: scap_org.open-scap_cref_ssg-rhel8-cpe-dictionary.xml
199192
----
200193

201194
* **Document type** describes what format the file is in. Common types include
@@ -216,8 +209,6 @@ shown for XCCDF files and Checklists and is sourced from the XCCDF **Status**
216209
element.
217210
* **Profiles** lists available profiles, their titles and IDs that you can use for
218211
the `--profile` command line attribute.
219-
* **Checks** and **Dictionaries** lists OVAL checks components and CPE
220-
dictionaries components in the given data stream.
221212

222213
To display more detailed information about a profile including the profile
223214
description, use the `--profile` option followed by the profile ID.
@@ -1840,15 +1831,15 @@ registry.access.redhat.com/ubi8 latest 3269c37eae33 2 months ago 208 MB
18401831

18411832
Note that the `oscap-podman` command requires root privileges.
18421833

1843-
=== Building hardened bootable container images using oscap-bootc
1834+
=== Building hardened bootable container images using oscap-im
18441835

1845-
The `oscap-bootc` tool is a convenience script that makes building hardened bootable container images easier.
1836+
The `oscap-im` tool is a convenience script that makes building hardened bootable container images easier.
18461837
This tool is designed to be used during the build of the bootable container image.
18471838

1848-
Include `oscap-bootc` in your `Containerfile` that will be used to build your bootable container image.
1849-
The `Containerfile` first needs to install the `openscap-utils` package which ships the `oscap-bootc` tool.
1839+
Include `oscap-im` in your `Containerfile` that will be used to build your bootable container image.
1840+
The `Containerfile` first needs to install the `openscap-utils` package which ships the `oscap-im` tool.
18501841

1851-
Also, SCAP content needs to be installed to the image before `oscap-bootc` will be run.
1842+
Also, SCAP content needs to be installed to the image before `oscap-im` will be run.
18521843
Although any SCAP content can be consumed by the tool, the SCAP source data streams shipped in `scap-security-guide` are specially cared to be compatible with bootable containers.
18531844

18541845
Example `Containerfile`:
@@ -1858,7 +1849,7 @@ FROM quay.io/centos-bootc/centos-bootc:stream9
18581849
18591850
RUN dnf install -y openscap-utils scap-security-guide
18601851
1861-
RUN oscap-bootc --profile stig /usr/share/xml/scap/ssg/content/ssg-cs9-ds.xml
1852+
RUN oscap-im --profile stig /usr/share/xml/scap/ssg/content/ssg-cs9-ds.xml
18621853
----
18631854

18641855
Once you have your `Containerfile`, execute the image build:
@@ -1867,15 +1858,15 @@ Once you have your `Containerfile`, execute the image build:
18671858
podman build -t hardened_image .
18681859
----
18691860

1870-
The `oscap-bootc` tool installs and removes all packages required by the selected profile to or from the image.
1861+
The `oscap-im` tool installs and removes all packages required by the selected profile to or from the image.
18711862
Then, it runs a scan and remediation with the selected profile.
18721863
It doesn't use offline scanning.
18731864
The configuration files and other content in the image are modified by this process, depending on the used SCAP content.
18741865

18751866
The built bootable container image can be then deployed and booted.
18761867
After booting the image, the state of the resulting system will be in line with the selected security profile.
18771868

1878-
The `oscap-bootc` tool can't be used anywhere else than in a `Containerfile`.
1869+
The `oscap-im` tool can't be used anywhere else than in a `Containerfile`.
18791870

18801871
=== Scanning of Docker containers and images using oscap-docker
18811872

openscap.spec

-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ Summary: OpenSCAP Utilities
8888
Requires: %{name}%{?_isa} = %{epoch}:%{version}-%{release}
8989
Requires: rpmdevtools rpm-build
9090
Requires: %{name}-scanner%{?_isa} = %{epoch}:%{version}-%{release}
91-
Requires: %{name}-engine-sce%{?_isa} = %{epoch}:%{version}-%{release}
9291

9392
%description utils
9493
The %{name}-utils package contains command-line tools build on top

swig/openscap_api.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ def init(self, path, paths={}):
811811
if OSCAP.oscap_err():
812812
desc = OSCAP.oscap_err_desc()
813813
else:
814-
desc = "Unknown error, please report this bug (http://bugzilla.redhat.com/)"
814+
desc = "Unknown error, please report this bug (https://github.com/OpenSCAP/openscap/issues)"
815815
raise ImportError(
816816
"Benchmark \"%s\" loading failed: %s" % (f_XCCDF, desc))
817817

@@ -832,7 +832,7 @@ def init(self, path, paths={}):
832832
if OSCAP.oscap_err():
833833
desc = OSCAP.oscap_err_desc()
834834
else:
835-
desc = "Unknown error,please report this bug (http://bugzilla.redhat.com/)"
835+
desc = "Unknown error,please report this bug (https://github.com/OpenSCAP/openscap/issues)"
836836
raise ImportError(
837837
"Cannot import definition model for \"%s\": %s" % (f_OVAL, desc))
838838
def_models.append(def_model)
@@ -841,7 +841,7 @@ def init(self, path, paths={}):
841841
if OSCAP.oscap_err():
842842
desc = OSCAP.oscap_err_desc()
843843
else:
844-
desc = "Unknown error,please report this bug (http://bugzilla.redhat.com/)"
844+
desc = "Unknown error,please report this bug (https://github.com/OpenSCAP/openscap/issues)"
845845
raise ImportError(
846846
"Cannot create agent session for \"%s\": %s" % (f_OVAL, desc))
847847
sessions[file] = sess

utils/CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,11 @@ if(ENABLE_OSCAP_UTIL_PODMAN)
139139
DESTINATION "${CMAKE_INSTALL_MANDIR}/man8"
140140
)
141141
endif()
142-
if(ENABLE_OSCAP_UTIL_BOOTC)
143-
install(PROGRAMS "oscap-bootc"
142+
if(ENABLE_OSCAP_UTIL_IM)
143+
install(PROGRAMS "oscap-im"
144144
DESTINATION ${CMAKE_INSTALL_BINDIR}
145145
)
146-
install(FILES "oscap-bootc.8"
146+
install(FILES "oscap-im.8"
147147
DESTINATION "${CMAKE_INSTALL_MANDIR}/man8"
148148
)
149149
endif()

utils/oscap-bootc utils/oscap-im

+13-7
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import subprocess
2121
import sys
2222
import tempfile
2323

24+
from pathlib import Path
25+
2426

2527
def parse_args():
2628
parser = argparse.ArgumentParser(
@@ -55,17 +57,21 @@ def parse_args():
5557
return parser.parse_args()
5658

5759

58-
def ensure_sce_installed():
59-
query_cmd = ["rpm", "-q", "openscap-engine-sce"]
60-
query_process = subprocess.run(query_cmd, capture_output=True)
61-
if query_process.returncode != 0:
60+
def verify_bootc_build_env():
61+
rv = subprocess.run(
62+
["rpm", "-q", "bootc"],
63+
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
64+
bootc_env = (rv.returncode == 0)
65+
container_env = Path("/run/.containerenv").exists()
66+
if not bootc_env or not container_env:
6267
raise RuntimeError(
63-
"The script requires to have the openscap-engine-sce package "
64-
"installed.")
68+
"This script is supposed to be used only in the bootable "
69+
"container build environment.")
6570

6671

6772
def install_sce_dependencies():
6873
required_packages = [
74+
"openscap-engine-sce",
6975
"setools-console" # seinfo is used by the sebool template
7076
]
7177
install_cmd = ["dnf", "-y", "install"] + required_packages
@@ -129,7 +135,7 @@ def scan_and_remediate(args):
129135

130136
def main():
131137
args = parse_args()
132-
ensure_sce_installed()
138+
verify_bootc_build_env()
133139
install_sce_dependencies()
134140
pre_scan_fix(args)
135141
scan_and_remediate(args)

utils/oscap-bootc.8 utils/oscap-im.8

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
.TH oscap-bootc "8" "November 2024" "Red Hat, Inc." "System Administration Utilities"
1+
.TH oscap-im "8" "January 2025" "Red Hat, Inc." "System Administration Utilities"
22

33
.SH NAME
4-
oscap-bootc \- Tool for building hardened bootable container images
4+
oscap-im \- Tool for building hardened bootable container images
55

66
.SH DESCRIPTION
7-
The oscap-bootc tool is a convenience script that makes building hardened bootable container images easier.
7+
The oscap-im tool is a convenience script that makes building hardened bootable container images easier.
88
This tool is designed to be used during the build of the bootable container image.
9-
Include oscap-bootc in your Containerfile that will be used to build your bootable container image.
10-
The oscap-bootc runs oscap tool on a given container image.
9+
Include oscap-im in your Containerfile that will be used to build your bootable container image.
10+
The oscap-im runs oscap tool on a given container image.
1111

12-
The oscap-bootc tool can't be used anywhere else than in a Containerfile.
12+
The oscap-im tool can't be used anywhere else than in a Containerfile.
1313

1414
.SH USAGE
1515

16-
oscap-bootc [OPTION...] DATASTREAM_FILE
16+
oscap-im [OPTION...] DATASTREAM_FILE
1717

1818
Usage of the tool mimics usage and options of oscap(8) tool.
1919

utils/oscap-info.c

+5-22
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,11 @@ static inline void _print_xccdf_referenced_files(struct xccdf_policy_model *poli
209209
printf("%sReferenced check files:\n", prefix);
210210
while (oscap_file_entry_iterator_has_more(files_it)) {
211211
struct oscap_file_entry *file_entry = (struct oscap_file_entry *) oscap_file_entry_iterator_next(files_it);
212-
printf("%s\t%s\n", prefix, oscap_file_entry_get_file(file_entry));
213-
printf("%s\t\tsystem: %s\n", prefix, oscap_file_entry_get_system(file_entry));
212+
const char *system = oscap_file_entry_get_system(file_entry);
213+
if (strcmp(system, "http://open-scap.org/page/SCE")) {
214+
printf("%s\t%s\n", prefix, oscap_file_entry_get_file(file_entry));
215+
printf("%s\t\tsystem: %s\n", prefix, oscap_file_entry_get_system(file_entry));
216+
}
214217
}
215218
oscap_file_entry_iterator_free(files_it);
216219
oscap_file_entry_list_free(referenced_files);
@@ -490,26 +493,6 @@ static int app_info_single_ds_all(struct ds_stream_index_iterator* sds_it, struc
490493
ds_sds_session_reset(session);
491494
}
492495
oscap_string_iterator_free(checklist_it);
493-
494-
printf("Checks:\n");
495-
struct oscap_string_iterator* checks_it = ds_stream_index_get_checks(stream);
496-
while (oscap_string_iterator_has_more(checks_it)) {
497-
const char * id = oscap_string_iterator_next(checks_it);
498-
printf("\tRef-Id: %s\n", id);
499-
}
500-
oscap_string_iterator_free(checks_it);
501-
502-
struct oscap_string_iterator* dict_it = ds_stream_index_get_dictionaries(stream);
503-
if (oscap_string_iterator_has_more(dict_it)) {
504-
printf("Dictionaries:\n");
505-
} else {
506-
printf("No dictionaries.\n");
507-
}
508-
while (oscap_string_iterator_has_more(dict_it)) {
509-
const char * id = oscap_string_iterator_next(dict_it);
510-
printf("\tRef-Id: %s\n", id);
511-
}
512-
oscap_string_iterator_free(dict_it);
513496
return OSCAP_OK;
514497
}
515498

0 commit comments

Comments
 (0)