-
Notifications
You must be signed in to change notification settings - Fork 372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Mariner 2 in FIPS test #2916
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
# | ||
# FIPS should not affect extension processing. The test enables FIPS and then executes an extension. | ||
# | ||
# NOTE: Enabling FIPS is very specific to the distro. This test is only executed on RHEL 9.0. | ||
# NOTE: Enabling FIPS is very specific to the distro. This test is only executed on Mariner 2. | ||
# | ||
# TODO: Add other distros. | ||
# | ||
# NOTE: FIPS can be enabled on RHEL9 using these instructions: see https://access.redhat.com/solutions/137833#rhel9), | ||
# but extensions with protected settings do not work end-to-end, since the Agent can't decrypt the tenant | ||
# certificate. | ||
# | ||
name: "FIPS" | ||
tests: | ||
- source: "fips/fips.py" | ||
images: "rhel_90" | ||
images: "mariner_2" | ||
owns_vm: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Microsoft Azure Linux Agent | ||
# | ||
# Copyright 2018 Microsoft Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# | ||
# Verifies whether FIPS is enabled on Mariner 2.0 | ||
# | ||
|
||
set -euo pipefail | ||
|
||
# Check if FIPS mode is enabled by the kernel (returns 1 if enabled) | ||
fips_enabled=$(sudo cat /proc/sys/crypto/fips_enabled) | ||
if [ "$fips_enabled" != "1" ]; then | ||
echo "FIPS is not enabled by the kernel: $fips_enabled" | ||
exit 1 | ||
fi | ||
|
||
# Check if sysctl is configured (returns crypto.fips_enabled = 1 if enabled) | ||
sysctl_configured=$(sudo sysctl crypto.fips_enabled) | ||
if [ "$sysctl_configured" != "crypto.fips_enabled = 1" ]; then | ||
echo "sysctl is not configured for FIPS: $sysctl_configured" | ||
exit 1 | ||
fi | ||
|
||
# Check if openssl library is running in FIPS mode | ||
# MD5 should fail; the command's output should be similar to: | ||
# Error setting digest | ||
# 131590634539840:error:060800C8:digital envelope routines:EVP_DigestInit_ex:disabled for FIPS:crypto/evp/digest.c:135: | ||
openssl=$(openssl md5 < /dev/null 2>&1 || true) | ||
if [[ "$openssl" != *"disabled for FIPS"* ]]; then | ||
echo "openssl is not running in FIPS mode: $openssl" | ||
exit 1 | ||
fi | ||
|
||
# Check if dracut-fips is installed (returns dracut-fips-<version>) | ||
dracut_fips=$( (rpm -qa | grep dracut-fips) || true ) | ||
if [[ "$dracut_fips" != *"dracut-fips"* ]]; then | ||
echo "dracut-fips is not installed: $dracut_fips" | ||
exit 1 | ||
fi | ||
|
||
echo "FIPS mode is enabled." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Microsoft Azure Linux Agent | ||
# | ||
# Copyright 2018 Microsoft Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# | ||
# Enables FIPS on Mariner 2.0 | ||
# | ||
|
||
set -euo pipefail | ||
|
||
echo "Installing packages required packages to enable FIPS..." | ||
sudo tdnf install -y grubby dracut-fips | ||
|
||
# | ||
# Set boot_uuid variable for the boot partition if different from the root | ||
# | ||
boot_dev="$(df /boot/ | tail -1 | cut -d' ' -f1)" | ||
echo "Boot partition: $boot_dev" | ||
|
||
root_dev="$(df / | tail -1 | cut -d' ' -f1)" | ||
echo "Root partition: $root_dev" | ||
|
||
boot_uuid="" | ||
if [ "$boot_dev" != "$root_dev" ]; then | ||
boot_uuid="boot=UUID=$(blkid $boot_dev -s UUID -o value)" | ||
echo "Boot UUID: $boot_uuid" | ||
fi | ||
|
||
# | ||
# Enable FIPS and set boot= parameter | ||
# | ||
echo "Enabling FIPS..." | ||
if sudo grub2-editenv - list | grep -q kernelopts; then | ||
set -x | ||
sudo grub2-editenv - set "$(sudo grub2-editenv - list | grep kernelopts) fips=1 $boot_uuid" | ||
else | ||
set -x | ||
sudo grubby --update-kernel=ALL --args="fips=1 $boot_uuid" | ||
fi |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The steps in these 2 scripts come from the internal documentation for Mariner