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

Re-enables paxtest in testinfra #5848

Merged
merged 1 commit into from
Mar 31, 2021

Conversation

conorsch
Copy link
Contributor

@conorsch conorsch commented Mar 5, 2021

Status

Ready for review

Description of Changes

Fixes #1039

These tests were skipped because we weren't installing paxtest by
default. Let's just install it as part of the test run. Removes
the skip-in-prod marker, so that these checks can be used as part of QA
on hardware. Updates the logic to be distro-specific.

Testing

CI should be passing on both platforms.
Try to run against hardware, or at least prodVMs, via the ./securedrop-admin verify workflow.
Are we OK with installing paxtest automatically via tests? I'd think so, given that we do it manually as part of QA anyway.

Deployment

Mostly QA, so developer-focused. Technically if an Admin runs ./securedrop-admin verify, the remote state will change because paxtest will be installed now. That's acceptable, IMO, since otherwise the paxtest checks would have been skipped.

Checklist

@conorsch conorsch requested review from zenmonkeykstop and rmol March 5, 2021 19:13
@conorsch conorsch requested review from emkll and kushaldas as code owners March 5, 2021 19:13
@zenmonkeykstop
Copy link
Contributor

In the spirit of "leave no trace," the script wrapping pytest (devops/scripts/run_prod_testinfra) has a cleanup trap function - could stick some apt removes in there.

@eloquence
Copy link
Member

Seemed to work as expected in #5609 (comment), agree that it'd be nice to automatically uninstall paxtest in the cleanup function after it's done.

@emkll emkll assigned emkll and unassigned emkll Mar 17, 2021
@conorsch conorsch force-pushed the 1039-paxtest-checks-in-testinfra branch from 62a7fa7 to b7e051c Compare March 17, 2021 21:59
@conorsch
Copy link
Contributor Author

Rebased on latest develop. I added a commit to clean up the package afterwards. Didn't use the bash trap, since that required futzing with Ansible outside of our wrappers within the Tails environment. Instead, I just used a try/finally block in the test itself. End result is the same: after test run, regardless of whether the paxtest failed or not, the package will be removed.

Ready for re-review.

@conorsch conorsch force-pushed the 1039-paxtest-checks-in-testinfra branch from b7e051c to 3f0bd46 Compare March 22, 2021 20:57
@eloquence
Copy link
Member

(Kicking CI)

@conorsch conorsch force-pushed the 1039-paxtest-checks-in-testinfra branch from 3f0bd46 to 6ddc535 Compare March 23, 2021 23:51
@conorsch
Copy link
Contributor Author

Rebased on top of latest develop, to satisfy CI.

@zenmonkeykstop zenmonkeykstop self-assigned this Mar 24, 2021
@zenmonkeykstop
Copy link
Contributor

Fails on a fresh install, as the apt cache has not been updated with universe. After the first run of apt-get update, paxtest is available as an option, and the tests pass.

if not host.exists("/usr/bin/paxtest"):
warnings.warn("Installing paxtest to run kernel tests")
with host.sudo():
host.run("apt-get install -y paxtest")
Copy link
Contributor

Choose a reason for hiding this comment

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

Assumes that paxtest is available via apt - which may not be the case until apt-get update has run at least once on the host. Running apt get update && apt-get install -y paxtest would work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added!

@conorsch conorsch force-pushed the 1039-paxtest-checks-in-testinfra branch from 6ddc535 to 1630a05 Compare March 29, 2021 15:32
Copy link
Contributor

@zenmonkeykstop zenmonkeykstop left a comment

Choose a reason for hiding this comment

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

One final tweak needed to remove the paxtest package post-run...

paxtest_results.split('\n')):
print(paxtest_diff)
assert paxtest_results == paxtest_expected
finally:
Copy link
Contributor

Choose a reason for hiding this comment

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

Paxtest isn't removed in this finally clause, it needs sudo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! Fixed.

These tests were skipped because we weren't installing paxtest by
default. Let's just install it as part of the test run. Removes
the skip-in-prod marker, so that these checks can be used as part of QA
on hardware. Updates the logic to be distro-specific.

Removes paxtest after test run

We don't install it by default, and it's only useful in QA, so let's
have the test-only dependency automatically cleaned up after install.
@conorsch conorsch force-pushed the 1039-paxtest-checks-in-testinfra branch from 1630a05 to 14ea71e Compare March 30, 2021 15:09
@zenmonkeykstop zenmonkeykstop merged commit 577c278 into develop Mar 31, 2021
@zenmonkeykstop zenmonkeykstop deleted the 1039-paxtest-checks-in-testinfra branch March 31, 2021 14:59
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.

Use paxtest for validating grsecurity config
4 participants