Skip to content
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

add azure linux-specific fips tests #3688

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

tobiasb-ms
Copy link

Add Azure Linux-specific tests around FIPS compliance. Specifically, this change adds:

verify_fips_is_enabled_azl: Verifies that an AZL system is in FIPS mode.
verify_fips_is_disabled_azl: Verifies that an AZL system is not in FIPS mode.
verify_fips_enable_azl: Verifies that an AZL system can be put into FIPS mode.
verify_fips_disable_azl: Verifies that an AZL system can be taken out of FIPS mode.

It also removes the AZL code from verify_fips_enable.

Due to the nature of these tests, they only make sense to run if we believe a machine is already in the correct mode. For example, verify_fips_is_enabled_azl would make sense on the marketplace image MicrosoftCBLMariner:azure-linux-3:azure-linux-3-fips:latest but not on MicrosoftCBLMariner:azure-linux-3:azure-linux-3:latest.

To accomplish this, we look at two things (see function ensure_fips_expectations).
First, we see if a variable testing_fips_image was provided to the test case. If so, and if it is yes or no, we respect that.
Second, we try to hit the azure metadata endpoint to get the image sku name. If that is a FIPS sku, we consider it to be a FIPS machine.
If neither exist, we skip the test.

).is_false()


class AzlFips(ABC):
Copy link
Member

Choose a reason for hiding this comment

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

It can be implemented by a tool. We have some virtual tools, they are not actually commands, but easy to be abtracted for reusing. In the tool, the create method can replace create_instance. This class can be called as "Fips", and derives a "AzLinuxFips/AzLinuxV2Fips,AzLinuxV3Fips" classes as needed.

node.reboot()
azl_fips.assert_fips_disabled()

log.debug("Successfully disabled FIPS.")
Copy link
Member

Choose a reason for hiding this comment

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

It can be info level to output a successful information.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Restore it to its original status, since the environment may be reused.

"Error setting digest\r\n.*EVP_DigestInit_ex:disabled for FIPS.*", re.M
)

def assert_fips_enabled(self) -> None:
Copy link
Member

Choose a reason for hiding this comment

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

It can provide additional parameters to merge with assert_fips_disabled, like assert_status(self, is_enabled)

Copy link
Author

Choose a reason for hiding this comment

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

I considered doing that, the code for assert_status would be several

if is_enabled:
   # whatever thing for enabled
else:
   # whatever disabled thing
It felt better to have them as totally separate functions.

Do you have a strong preference here?

Copy link
Member

Choose a reason for hiding this comment

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

I prefer it, because 50%+ code are same or similar. If convert true/false to 1/0, most code is the same. So sharing logic is always better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants