Skip to contentSkip to conversation

package/compliance-as-code: introduce new package

PATCH Superseded Alexis Lothoré via buildroot 1 participant 6 messages Jul 31, 2025

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover package/compliance-as-code: introduce new package

Hello,
this is the v2 of the series bringing in Compliance As Code policies [1] (CaC) on a target. This project aims to provide security policy content on systems: this content brings data files describing checks standards and automations for system configuration. Those files come in various formats (XCCDF, OVAL, SCAP). This project is tightly coupled to the OpenSCAP tool [2]:
- to build the data files to embed on the target system
- and to perform analysis on the system, by consuming the data files

CaC then depends on both openscap and host-openscap.
The series brings in the following commits:
- commit 1 brings libxmsec1, one of openscap dependencies
- commit 2 brings back host-libcurl (which has been supported and later removed from BR, as there was no user anymore), since host-openscap needs host-libcurl
- commit 3 brings openscap package
- commit 4 brings CaC package

The new CaC package brings a minimal feature set for now: it only brings the security policy data files (ie: XML files) on the target. It can be extended later as needed to bring in for example generated bash script, ansible playbooks, etc.

Testing output:

$ ./utils/test-pkg -c cac.config -p compliance-as-code
   bootlin-armv5-uclibc [1/6]: OK
   bootlin-armv7-glibc [2/6]: OK
   bootlin-armv7m-uclibc [3/6]: SKIPPED
   bootlin-x86-64-musl [4/6]: OK
   br-arm-full-static [5/6]: SKIPPED
   arm-aarch64 [6/6]: OK

[1] https://github.com/ComplianceAsCode/content
[2] https://github.com/OpenSCAP/openscap

---
Changes in v2:
- reworded commits titles and messages
- reformated, reordered content and/or cleaned multiple files
- added Kconfig comments for toolchain deps
- added missing DEVELOPERS entry
- fixed licensing issues for openscap
- disabled python3 in openscap
- removed some non existing KConfig dependencies and hooks
- fixed KConfig management in CaC .mk file
- updated install target in CaC to use cp
- introduced a simple runtime test for openscap/CaC
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Alexis Lothoré (5):
package/libxmlsec1: new package
package/libcurl: Reapply "libcurl: add host variant" package/openscap: new package package/compliance-as-code: new package support/testing: add runtime testing for compliance-as-code

 DEVELOPERS                                         |  6 ++
 package/Config.in                                  |  3 +
 package/compliance-as-code/Config.in               | 33 +++++++++++
 package/compliance-as-code/compliance-as-code.hash |  4 ++
 package/compliance-as-code/compliance-as-code.mk   | 41 +++++++++++++
 package/libcurl/libcurl.mk                         | 11 ++++
 package/libxmlsec1/Config.in                       | 13 ++++
 package/libxmlsec1/libxmlsec1.hash                 |  3 +
 package/libxmlsec1/libxmlsec1.mk                   | 32 ++++++++++
 package/openscap/Config.in                         | 21 +++++++
 package/openscap/openscap.hash                     |  3 +
 package/openscap/openscap.mk                       | 69 ++++++++++++++++++++++
 .../tests/package/test_compliance_as_code.py       | 23 ++++++++
 13 files changed, 262 insertions(+)

---
base-commit: 0461043a51322ebcf7cdd90b0d2f9b59df17bb9c
change-id: 20250724-openscap-7166fbe1571e

Best regards,

Signature · 8 lines
Alexis Lothoré, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

PATCH v2 1/5 package/libxmlsec1: new package

Introduce the libxmlsec1 library package. libxmlsec implements XML security standards.

The library has only a few mandatory dependencies(libxml2 and libxslt and a crypto library). It needs one of the following cryptographic
libraries: OpenSSL, NSS, or Gcrypt/GNUTLS. Default to openssl for now to keep the package simple.

---
Changes in v2:
- reword commit title
- add maintainer entry
- remove duplicate comment in hash file
- reformat conf opts list
- remove hardcoded static build conf opt
- properly duplicate conf opts for host variant

---
 DEVELOPERS                         |  3 +++
 package/Config.in                  |  1 +
 package/libxmlsec1/Config.in       | 13 +++++++++++++
 package/libxmlsec1/libxmlsec1.hash |  3 +++
 package/libxmlsec1/libxmlsec1.mk   | 32 ++++++++++++++++++++++++++++++++
 5 files changed, 52 insertions(+)
DEVELOPERS +3 -0
index 12a41597afb0f01eb4f6836306cf701b25a4faa5..b7bd8bac9d3f1bdd3d1ccae03d25985b3860db08 100644
@@ -152,6 +152,9 @@ F:	configs/cubieboard2_defconfig
 N:	Alexey Lukyanchuk <[email protected]>
 F:	package/zabbix/
 
+N:	Alexis Lothoré <[email protected]>
+F:	package/libxmlsec1/
+
 N:	Alistair Francis <[email protected]>
 F:	board/sifive/
 F:	boot/opensbi/
package/Config.in +1 -0
index 137f74ed82ce8029e7d8f53fc3e1fabc9584f73e..2d19bc81306abf66634b8fcea40712107612aed7 100644
@@ -1947,6 +1947,7 @@ menu "JSON/XML"
 	source "package/libxmlb/Config.in"
 	source "package/libxmlpp/Config.in"
 	source "package/libxmlrpc/Config.in"
+	source "package/libxmlsec1/Config.in"
 	source "package/libxslt/Config.in"
 	source "package/libyaml/Config.in"
 	source "package/mxml/Config.in"
package/libxmlsec1/Config.in new file +13 -0
new file mode 100644
index 0000000000000000000000000000000000000000..155efac825c071d0d3518a92ca35caf7d7decf9e
@@ -0,0 +1,13 @@
+config BR2_PACKAGE_LIBXMLSEC1
+	bool "libxmlsec1"
+	select BR2_PACKAGE_OPENSSL
+	select BR2_PACKAGE_LIBXML2
+	select BR2_PACKAGE_LIBXSLT
+	help
+	  XMLSec library provides C based implementation for major XML
+	  Security standards:
+	    - XML Signature Syntax and Processing
+	    - XML Encryption Syntax and Processing
+
+	  https://www.aleksey.com/xmlsec/
+	  https://github.com/lsh123/xmlsec
package/libxmlsec1/libxmlsec1.hash new file +3 -0
new file mode 100644
index 0000000000000000000000000000000000000000..db1dc77effd7c756f7da0fb99f4a3e3f9aae4516
@@ -0,0 +1,3 @@
+# Locally computed
+sha256  d82e93b69b8aa205a616b62917a269322bf63a3eaafb3775014e61752b2013ea  xmlsec1-1.3.7.tar.gz
+sha256  d5e9388534256360c6a009d4f19ab2b8d6ec0aa7ff32a51e22d899ed7beb5c48  Copyright
package/libxmlsec1/libxmlsec1.mk new file +32 -0
new file mode 100644
index 0000000000000000000000000000000000000000..16b3bcf84887244ed63a5746194249f339b8a20f
@@ -0,0 +1,32 @@
+################################################################################
+#
+# libxmlsec1
+#
+################################################################################
+
+LIBXMLSEC1_VERSION = 1.3.7
+LIBXMLSEC1_SOURCE = xmlsec1-$(LIBXMLSEC1_VERSION).tar.gz
+LIBXMLSEC1_SITE = https://github.com/lsh123/xmlsec/releases/download/$(LIBXMLSEC1_VERSION)
+LIBXMLSEC1_LICENSE = MIT
+LIBXMLSEC1_LICENSE_FILES = Copyright
+LIBXMLSEC1_INSTALL_STAGING = YES
+LIBXMLSEC1_DEPENDENCIES = libxml2 libxslt openssl
+HOST_LIBXMLSEC1_DEPENDENCIES = host-libxml2 host-libxslt host-openssl
+LIBXMLSEC1_AUTORECONF = YES
+
+LIBXMLSEC1_CONF_OPTS = \
+	--enable-crypto-dl=no \
+	--with-openssl \
+	--without-gnutls \
+	--without-gcrypt \
+	--without-nss
+
+HOST_LIBXMLSEC1_CONF_OPTS = \
+	--enable-crypto-dl=no \
+	--with-openssl \
+	--without-gnutls \
+	--without-gcrypt \
+	--without-nss
+
+$(eval $(autotools-package))
+$(eval $(host-autotools-package))
Signature · 6 lines
2.50.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

PATCH v2 2/5 package/libcurl: Reapply "libcurl: add host variant"

In reply to Alexis Lothoré via buildroot

libcurl host build support has initially been added with 736e0fc5d610 ("libcurl: add host variant") while adding support for host-cargo build, and reverted with 69e84008abf8 ("Revert "libcurl: add host variant"") when standalone cargo build has been removed. In order to bring a new host package depending on libcurl, re-enable host-libcurl build support. While doing so, remove the not-needed-anymore post-patch hook.

This reverts commit w9e84008abf87eaeeb3f2d53c880cf33492a3bf8.

---
Changes in v2:
- remove the post-patch hook, as the corresponding command does not exist anymore

---
 package/libcurl/libcurl.mk | 11 +++++++++++
 1 file changed, 11 insertions(+)
package/libcurl/libcurl.mk +11 -0
index 1cfdda27d215775cb8021979bc955c30ae4fea4c..c311f58fb223a671712084108d4c4ab18ee729e7 100644
@@ -189,4 +189,15 @@ endef
 LIBCURL_POST_INSTALL_TARGET_HOOKS += LIBCURL_TARGET_CLEANUP
 endif
 
+HOST_LIBCURL_DEPENDENCIES = host-openssl
+HOST_LIBCURL_CONF_OPTS = \
+	--disable-manual \
+	--disable-ntlm-wb \
+	--disable-curldebug \
+	--with-ssl \
+	--without-gnutls \
+	--without-mbedtls \
+	--without-nss
+
 $(eval $(autotools-package))
+$(eval $(host-autotools-package))
Signature · 6 lines
2.50.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#3 lore raw

PATCH v2 3/5 package/openscap: new package

In reply to Alexis Lothoré via buildroot

Introduce the openscap package. openscap is a command line tool allowing to scan a system configuration to perform security compliance checks. The tool consumes XCCDF and OVAL files to perform system evaluation against a list of policies.

The package provides both a target and a host build configuration, as it is needed on both sides:
- it is needed on the host to allow building the security policy files to be embedded on the target
- it is needed on the target to actually parse and evaluate those security policy files.

---
Changes in v2:
- reword commit title and message
- add DEVELOPERS entry
- update comment on Config.in deps
- reorder and reformat various variables and Kconfig entries
- drop uneeded selects on host Config entries
- add a comment about the toolchain configuration in Config.in
- drop duplicate comment in hash file
- drop additional license file reference
- use assign rather than concat for package conf opts
- drop python dependency

---
 DEVELOPERS                     |  1 +
 package/Config.in              |  1 +
 package/openscap/Config.in     | 21 +++++++++++++
 package/openscap/openscap.hash |  3 ++
 package/openscap/openscap.mk   | 69 ++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 95 insertions(+)
DEVELOPERS +1 -0
index b7bd8bac9d3f1bdd3d1ccae03d25985b3860db08..c405958682c39adc454853fe2cd80d2ae74799d3 100644
@@ -154,6 +154,7 @@ F:	package/zabbix/
 
 N:	Alexis Lothoré <[email protected]>
 F:	package/libxmlsec1/
+F:	package/openscap/
 
 N:	Alistair Francis <[email protected]>
 F:	board/sifive/
package/Config.in +1 -0
index 2d19bc81306abf66634b8fcea40712107612aed7..29fff74876731856819364f7fd7e2b94f6ffc895 100644
@@ -2352,6 +2352,7 @@ menu "Security"
 	source "package/libselinux/Config.in"
 	source "package/libsemanage/Config.in"
 	source "package/libsepol/Config.in"
+	source "package/openscap/Config.in"
 	source "package/safeclib/Config.in"
 	source "package/softhsm2/Config.in"
 endmenu
package/openscap/Config.in new file +21 -0
new file mode 100644
index 0000000000000000000000000000000000000000..225503060179903693a9e634f7e19df1b9c75379
@@ -0,0 +1,21 @@
+config BR2_PACKAGE_OPENSCAP
+	bool "openscap"
+	depends on BR2_PACKAGE_LIBGPG_ERROR_ARCH_SUPPORTS  # libgcrypt
+	depends on !BR2_STATIC_LIBS # dlfcn.h
+	select BR2_PACKAGE_LIBCURL
+	select BR2_PACKAGE_LIBGCRYPT
+	select BR2_PACKAGE_LIBXML2
+	select BR2_PACKAGE_LIBXMLSEC1
+	select BR2_PACKAGE_MUSL_FTS if !BR2_TOOLCHAIN_USES_GLIBC
+	select BR2_PACKAGE_OPENSSL
+	select BR2_PACKAGE_PCRE
+	help
+	  The purpose of this project is to create security policy
+	  content for various platforms
+
+	  https://www.open-scap.org/
+	  https://github.com/OpenSCAP/openscap
+
+comment "openscap needs a toolchain w/ dynamic library"
+	depends on BR2_PACKAGE_LIBGPG_ERROR_ARCH_SUPPORTS
+	depends on BR2_STATIC_LIBS
package/openscap/openscap.hash new file +3 -0
new file mode 100644
index 0000000000000000000000000000000000000000..e98631372d517c1ce96058477b11d8add35342b1
@@ -0,0 +1,3 @@
+# Locally computed
+sha256  6e61913fca3a74d310d7cf9354973eeaefa42be909ae649af1df48c3c08bc6ff  openscap-1.3.12.tar.gz
+sha256  5df07007198989c622f5d41de8d703e7bef3d0e79d62e24332ee739a452af62a  COPYING
package/openscap/openscap.mk new file +69 -0

69 lines not on this page · raw message

Signature · 6 lines
2.50.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#4 lore raw

PATCH v2 4/5 package/compliance-as-code: new package

In reply to Alexis Lothoré via buildroot

Introduce the Compliance As Code package. This project provides data files consumed by the openscap tool to evaluate a host compliance in regard with security policies. The package depends on both host-openscap (needed at build time to process the input files into usable files) and openscap (needed on the target, will use the generated files to evaluate the system configuration)

The project is based on cmake, but it also exposes a wrapper script (build_product). The package uses the cmake build system, but exposes a few Kconfig options to replicate some of the build_product options:
- BR2_PACKAGE_COMPLIANCE_AS_CODE_DATASTREAM_ONLY: replicates the -d option, building only the datastream files instead of all the files
- BR2_PACKAGE_COMPLIANCE_AS_CODE_PRODUCTS: allow selecting the product(s) for which we want to generate policies files.

The default install target provided by the project expects a full build, and so it will try to generate all the files for all the products when executed (which cancels the benefit of being able to select only a single or a few products), so the package defines a custom install command.

---
Changes in v2:
- reword commit title
- add entry to DEVELOPERS file
- remove non-relevant KConfig deps
- add comment about depends in Config.in
- remove FOO_REDISTRIBUTE = NO
- fix datastream-only build configuration management
- update install target to use cp rather than rsync

---
 DEVELOPERS                                         |  1 +
 package/Config.in                                  |  1 +
 package/compliance-as-code/Config.in               | 33 +++++++++++++++++
 package/compliance-as-code/compliance-as-code.hash |  4 +++
 package/compliance-as-code/compliance-as-code.mk   | 41 ++++++++++++++++++++++
 5 files changed, 80 insertions(+)
DEVELOPERS +1 -0
index c405958682c39adc454853fe2cd80d2ae74799d3..7aea75d267a7bb4b65af97d98454ed5be23b85e0 100644
@@ -155,6 +155,7 @@ F:	package/zabbix/
 N:	Alexis Lothoré <[email protected]>
 F:	package/libxmlsec1/
 F:	package/openscap/
+F:	package/compliance-as-code/
 
 N:	Alistair Francis <[email protected]>
 F:	board/sifive/
package/Config.in +1 -0
index 29fff74876731856819364f7fd7e2b94f6ffc895..f44cd884a0a8a7e5cd2705eb0ba247a5c3feaa90 100644
@@ -2348,6 +2348,7 @@ endif
 endmenu
 
 menu "Security"
+	source "package/compliance-as-code/Config.in"
 	source "package/libapparmor/Config.in"
 	source "package/libselinux/Config.in"
 	source "package/libsemanage/Config.in"
package/compliance-as-code/Config.in new file +33 -0
new file mode 100644
index 0000000000000000000000000000000000000000..f791f0c88cad4cb2e9e2930a44295fd5a69a9364
@@ -0,0 +1,33 @@
+config BR2_PACKAGE_COMPLIANCE_AS_CODE
+	bool "compliance-as-code"
+	depends on BR2_PACKAGE_LIBGPG_ERROR_ARCH_SUPPORTS  # openscap
+	depends on !BR2_STATIC_LIBS # dlfcn.h
+	select BR2_PACKAGE_OPENSCAP
+	help
+	  Generate and install the profiles used for
+	  security (e.g. FIPS, CSPN) compliance analysis.
+
+	  Uses ComplianceAsCode to generate profiles
+	  https://complianceascode.readthedocs.io/en/latest/
+
+comment "compliance-as-code needs a toolchain w/ dynamic library"
+	depends on BR2_PACKAGE_LIBGPG_ERROR_ARCH_SUPPORTS
+	depends on BR2_STATIC_LIBS
+
+if BR2_PACKAGE_COMPLIANCE_AS_CODE
+
+config BR2_PACKAGE_COMPLIANCE_AS_CODE_DATASTREAM_ONLY
+	bool "datastream only"
+	default y
+	help
+	  Build only the datastreams (do not build the html tables,
+	  guides, etc)
+
+config BR2_PACKAGE_COMPLIANCE_AS_CODE_PRODUCTS
+	string "products"
+	help
+	  Provide a space-separated list of products for which you want
+	  to build security content. Leave empty to build content for
+	  all supported products.
+
+endif
package/compliance-as-code/compliance-as-code.hash new file +4 -0
new file mode 100644
index 0000000000000000000000000000000000000000..223216295de39ac1f2dbf4e5146e669758c80d6a
@@ -0,0 +1,4 @@
+
+# Locally computed
+sha256  bb79e996035a1d985c49e5df8988a5d5f2310f5b3b5d49492f95a6845db00f43  compliance-as-code-0.1.77.tar.gz
+sha256  ade633d5db670a58ff5f735c3602caafc72657a516416969fff79ff8a0c10298  LICENSE
package/compliance-as-code/compliance-as-code.mk new file +41 -0

41 lines not on this page · raw message

Signature · 6 lines
2.50.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#5 lore raw

PATCH v2 5/5 support/testing: add runtime testing for compliance-as-code

In reply to Alexis Lothoré via buildroot

Add some basic runtime testing for openscap/compliance-as-code. By running a single command, we test that:
- the oscap binary is installed and can execute
- the compliance-as-code policy files are properly installed
- oscap can parse a policy file, and so those are correctly built

---
Changes in v2:
- new commit

---
 DEVELOPERS                                         |  1 +
 .../tests/package/test_compliance_as_code.py       | 23 ++++++++++++++++++++++
 2 files changed, 24 insertions(+)
DEVELOPERS +1 -0
index 7aea75d267a7bb4b65af97d98454ed5be23b85e0..5e4e1a026076e66f8727e868f3a8cb3b50527007 100644
@@ -156,6 +156,7 @@ N:	Alexis Lothoré <[email protected]>
 F:	package/libxmlsec1/
 F:	package/openscap/
 F:	package/compliance-as-code/
+F:	support/testing/tests/package/test_compliance_as_code.py
 
 N:	Alistair Francis <[email protected]>
 F:	board/sifive/
support/testing/tests/package/test_compliance_as_code.py new file +23 -0
new file mode 100644
index 0000000000000000000000000000000000000000..10a53c12d0c26dcf124ee64d260ab6adb4765c0e
@@ -0,0 +1,23 @@
+import os
+from infra.basetest import BRTest, BASIC_TOOLCHAIN_CONFIG
+
+
+class TestComplianceAsCode(BRTest):
+    config = BASIC_TOOLCHAIN_CONFIG + \
+        """
+        BR2_PACKAGE_COMPLIANCE_AS_CODE=y
+        BR2_PACKAGE_COMPLIANCE_AS_CODE_PRODUCTS="debian12"
+        BR2_TARGET_ROOTFS_CPIO=y
+        # BR2_TARGET_ROOTFS_TAR is not set
+        """
+
+    def test_run(self):
+        cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
+        self.emulator.boot(arch="armv5",
+                           kernel="builtin",
+                           options=["-initrd", cpio_file])
+        self.emulator.login()
+
+        # Check that oscap can parse the generated datastream
+        self.assertRunOk(
+                "oscap info /etc/openscap/ssg-debian12-ds.xml", timeout=10)
Signature · 6 lines
2.50.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot