Skip to content

Replace umockdev with vfido for passkey testing#237

Draft
ikerexxe wants to merge 6 commits intoSSSD:masterfrom
ikerexxe:test-passkey-vfido
Draft

Replace umockdev with vfido for passkey testing#237
ikerexxe wants to merge 6 commits intoSSSD:masterfrom
ikerexxe:test-passkey-vfido

Conversation

@ikerexxe
Copy link
Contributor

Migrate the passkey testing infrastructure from umockdev to vfido, providing a more robust and reliable solution for passkey authentication testing. The migration includes updating client feature detection to support vfido's requirements, refactoring authentication utilities for improved integration, and updating the documentation to reflect the new vfido usage patterns. These changes enhance the overall passkey testing experience while maintaining backward compatibility where applicable.

Update `vfido_passkey_add_register()` to return the passkey mapping,
just as `umockdev_passkey_add_register()` does

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Fix authentication routing bug that prevented vfido from being used
correctly

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
PASSKEY_FALLBACK_TO_PASSWORD requires a PIN, even though this might be
an empty or wrong PIN. Fix this by grouping PASSKEY_FALLBACK_TO_PASSWORD
with PIN requiring auth methods.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Previous implementation for the bash code was a little bit confusing and
didn't make much sense from the high-level perspective.

Refactored the function to follow phases, some of them are mandatory for
all methods, other are only required for some of the methods.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
`vfido` feature needs `vhci_hcd` kernel module to be loaded to work,
thus adding a check there

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
The virtual FIDO2 authenticator has been replaced by vfido, thus update
the documentation

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request migrates the passkey testing infrastructure to use vfido instead of umockdev. This change provides a more reliable and maintainable solution for testing passkey authentication. The update includes necessary code modifications and documentation updates to ensure a smooth transition and maintain backward compatibility where possible.

Highlights

  • Migration: Migrated passkey testing infrastructure from umockdev to vfido for a more robust solution.
  • Feature Detection: Updated client feature detection to support vfido requirements.
  • Refactoring: Refactored authentication utilities for improved integration with vfido.
  • Documentation: Updated documentation to reflect the new vfido usage patterns.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • docs/guides/testing-passkey.rst
    • Updated documentation to reflect the migration from umockdev to vfido for passkey testing, including system requirements and usage examples.
  • sssd_test_framework/hosts/client.py
    • Modified client feature detection to accurately identify vfido support by checking for the vhci_hcd kernel module and the vfido.py executable.
  • sssd_test_framework/roles/ipa.py
    • Corrected the return value processing in run_expect to retrieve the correct output line.
  • sssd_test_framework/utils/authentication.py
    • Refactored passkey authentication utilities to use vfido instead of umockdev, including updates to handle PIN prompts and device touch simulation.
Activity
  • Migration of passkey testing infrastructure from umockdev to vfido.
  • Updating client feature detection to support vfido requirements.
  • Refactoring authentication utilities for improved integration.
  • Updating documentation to reflect the new vfido usage patterns.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request migrates the passkey testing infrastructure from umockdev to vfido, which is a more modern and robust solution. The changes are well-structured, covering documentation, feature detection, and the authentication utilities themselves. I've identified a few areas for improvement, mainly around documentation consistency and simplifying some of the expect scripts for better readability and maintenance.

time.sleep(1)

return result.stdout_lines[-1].strip()
return result.stdout_lines[-2].strip()

Choose a reason for hiding this comment

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

high

The output of the ipa command includes a summary line after the passkey mapping. Accessing the second to last line (-2) is fragile. A more robust approach would be to iterate through the output lines and find the one that starts with Passkey mapping:. This avoids issues if the ipa command's output format changes in the future.

        for line in result.stdout_lines:
            if line.strip().startswith("Passkey mapping:"):
                return line.strip()

        raise AssertionError("Passkey mapping not found in ipa command output")

) -> tuple[int, int, str, str]:
"""wrapper for passkey_with_output methods"""
if "virt_type" in kwargs and kwargs["virt_type"] == "vfido":
del kwargs["virt_type"]

Choose a reason for hiding this comment

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

high

Deleting virt_type from kwargs modifies the dictionary that was passed in by the caller. This can lead to unexpected side effects if the caller reuses the kwargs dictionary. It's safer to create a copy of the dictionary before modifying it.

Suggested change
del kwargs["virt_type"]
kwargs_copy = kwargs.copy()
del kwargs_copy["virt_type"]

"""wrapper for passkey_with_output methods"""
if "virt_type" in kwargs and kwargs["virt_type"] == "vfido":
del kwargs["virt_type"]
return self.vfido_passkey_with_output(**kwargs)

Choose a reason for hiding this comment

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

high

To avoid the side effect of modifying the original kwargs dictionary, you should pass the modified copy to the vfido_passkey_with_output method.

Suggested change
return self.vfido_passkey_with_output(**kwargs)
return self.vfido_passkey_with_output(**kwargs_copy)

Comment on lines +431 to 432
del kwargs["virt_type"]
return self.vfido_passkey(**kwargs)

Choose a reason for hiding this comment

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

high

Similar to the passkey_with_output method, deleting virt_type from kwargs here can cause unexpected side effects. It's better to work with a copy of the dictionary to ensure the caller's dictionary remains unchanged.

Suggested change
del kwargs["virt_type"]
return self.vfido_passkey(**kwargs)
kwargs_copy = kwargs.copy()
del kwargs_copy["virt_type"]
return self.vfido_passkey(**kwargs_copy)

sudo modprobe vhci-hcd

# Verify the module is loaded
lsmod | grep vhci

Choose a reason for hiding this comment

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

medium

For consistency with the feature detection logic in sssd_test_framework/hosts/client.py, it would be better to grep for vhci_hcd instead of just vhci. This makes the verification step more specific and aligned with the actual kernel module name.

Suggested change
lsmod | grep vhci
lsmod | grep vhci_hcd

Comment on lines 791 to 794
expect {{
-i $ID_su -re "Authentication failure" {{exitmsg "Authentication failure" 1}}
-i $ID_su eof {{exitmsg "Passkey authentication successful" 0}}
-i $ID_su timeout {{exitmsg "Unexpected output" 213}}
-i $ID_touch eof {{}}
-i $ID_touch timeout {{}}
}}

Choose a reason for hiding this comment

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

medium

The expect block for ID_touch can be simplified. Since you're just waiting for the vfido_touch process to finish and don't care about its output, a single expect eof is sufficient. This makes the script slightly cleaner.

Suggested change
expect {{
-i $ID_su -re "Authentication failure" {{exitmsg "Authentication failure" 1}}
-i $ID_su eof {{exitmsg "Passkey authentication successful" 0}}
-i $ID_su timeout {{exitmsg "Unexpected output" 213}}
-i $ID_touch eof {{}}
-i $ID_touch timeout {{}}
}}
expect -i $ID_touch eof

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.

1 participant