Skip to content

Add hummingbird remediations type#14625

Open
jan-cerny wants to merge 13 commits intoComplianceAsCode:masterfrom
jan-cerny:hummingbird_remediations
Open

Add hummingbird remediations type#14625
jan-cerny wants to merge 13 commits intoComplianceAsCode:masterfrom
jan-cerny:hummingbird_remediations

Conversation

@jan-cerny
Copy link
Copy Markdown
Collaborator

Description:

New remediation type hummingbird has been added. The hummingbird remediations are bash scripts specifically designed to be run only during building container images in the Hummingbird project.

An example remediation for rule no_host_based_files has been added. This example demonstrates how the Humminbird should look like and shows how it differs from a generic Bash remediation.

Also, unit tests for generate_profile_remediations.py have been added to this PR.

Rationale:

Even though the remediations are Bash code, it isn't preferred to use existing Bash remediations. The reasons are:

  • different environment of containers than bare metal
  • a need to remediate filesystem mounted in the /newroot directory instead of the root filesystem

Review Hints:

./build_product hummingbird
ls build/hummingbird_scripts/
vim build/hummingbird_scripts/hummingbird-script-stig.sh

@jan-cerny jan-cerny added this to the 0.1.81 milestone Apr 7, 2026
@jan-cerny jan-cerny added New Feature Issues or pull requests related to new Features. Hummingbird Hummingbird project or container images related labels Apr 7, 2026
This new remediation type will be used to generate scripts that will
perform hardening during the build of Project Hummingbird container
images.  The `hummingbird` type remediation scripts will be Bash scripts
specifically written for the container image build environment.  They
won't be used in other situations.  They will work with the `$NEWROOT`
environment variable defined in the `Containerfile`.
Generate remediation scripts for all profiles in the `hummingbird`
product and store them in the `/build/hummingbird_scripts` directory.
These scripts will be integrated to the build process of container
images in Project Hummingbird.
Improve format of the generated hummingbird remediation script.
The main improvement is that it won't print an error message
if the rule doesn't have any remediation, because in hummingbird
remediation it's expected that most rules don't have any remediation,
for example all package rules.
Add the NEWROOT variable as an argument fo the generated
remediation script. The script is expected to be used in
Containerfile and should modify the filesystem specified
by the NEWROOT variable, typically `/new-root-fs`.
A Humminbird remediation for rule `no_host_based_files` has been
added. This demonstrates how the Humminbird should look like
and shows how it differs from a generic Bash remediation.
This fixes variable substitution code in Bash remediations.
@jan-cerny jan-cerny force-pushed the hummingbird_remediations branch from 0abe5b0 to 102504d Compare April 8, 2026 09:33
@matusmarhefka matusmarhefka self-assigned this Apr 8, 2026
Copy link
Copy Markdown
Member

@matusmarhefka matusmarhefka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some nitpicks, otherwise LGTM.

@jan-cerny
Copy link
Copy Markdown
Collaborator Author

I have risen an exception and shown a real list of languages

Copy link
Copy Markdown
Member

@Mab879 Mab879 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if value.text is None:
values["selector"] = ""

Should this values[selector] and the tests introduced in this PR be updated to follow?

If an XCCDF Value doesn't have any value but has a selector,
we should use the actual selector name. It seems the variable
name holding the selector name was accidentally quoted so instead
of the actual selector name we got "selector" literally.
@jan-cerny
Copy link
Copy Markdown
Collaborator Author

I have fixed the empty value handling in get_variable_values

@jan-cerny jan-cerny changed the title Hummingbird remediations Add hummingbird remediations type Apr 9, 2026
@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Apr 9, 2026

@jan-cerny: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-aws-openshift-node-compliance 7a233f5 link true /test e2e-aws-openshift-node-compliance
ci/prow/e2e-aws-openshift-platform-compliance ad92b52 link true /test e2e-aws-openshift-platform-compliance

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Hummingbird Hummingbird project or container images related New Feature Issues or pull requests related to new Features.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants