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
Added support for specifying/limiting content-checksums used by Pulp. #894
Conversation
|
Attached issue: https://pulp.plan.io/issues/5216 |
b556eac
to
1e04525
Compare
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.
Thank you for letting me get a very early look on this brill PR.
Running it in the FIPS environment exposed at least one more location where a not allowed hash algorithm is used: pulpcore/app/files.py
1e04525
to
432a759
Compare
Concur - see changes in files.py with latest repush |
432a759
to
f69103e
Compare
|
This code looks great to me. Impressive turnaround time on this. Question: would it be possible to test this out by defining |
|
I can confirm, this peachy PR is passing the |
e3a560c
to
aaf90be
Compare
@daviddavis , I have...no insight here. I've done a lot of local testing by setting in /etc/pulp/settings.py. |
You would add that to the plugins template_config and regenerate the travis directory. Like here: https://github.com/pulp/pulpcore/blob/master/template_config.yml#L30 |
aaf90be
to
dfe790d
Compare
pulpcore/app/models/content.py
Outdated
| # All available digest fields ordered by algorithm strength. | ||
| _DIGEST_FIELDS = [] | ||
| for alg in ("sha512", "sha384", "sha256", "sha224", "sha1", "md5"): | ||
| if alg in settings.ALLOWED_CONTENT_CHECKSUMS: | ||
| _DIGEST_FIELDS.append(alg) | ||
|
|
||
| # All available digest fields ordered by relative frequency | ||
| # (Better average-case performance in some algorithms with fallback) | ||
| _COMMON_DIGEST_FIELDS = [] | ||
| for alg in ("sha256", "sha512", "sha384", "sha224", "sha1", "md5"): | ||
| if alg in settings.ALLOWED_CONTENT_CHECKSUMS: | ||
| _COMMON_DIGEST_FIELDS.append(alg) | ||
|
|
||
| # Available, reliable digest fields ordered by algorithm strength. | ||
| _RELIABLE_DIGEST_FIELDS = [] | ||
| for alg in ("sha512", "sha384", "sha256"): | ||
| if alg in settings.ALLOWED_CONTENT_CHECKSUMS: | ||
| _RELIABLE_DIGEST_FIELDS.append(alg) | ||
|
|
||
| # Digest-fields that are NOT ALLOWED | ||
| _FORBIDDEN_DIGESTS = set(ALL_KNOWN_CONTENT_CHECKSUMS).difference( | ||
| set(settings.ALLOWED_CONTENT_CHECKSUMS) | ||
| ) |
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.
ty for all this.
| @@ -2,6 +2,8 @@ | |||
|
|
|||
| import mock | |||
| from pulpcore.app.serializers import ArtifactSerializer | |||
| from pulpcore.app import models | |||
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 test suite is expected to be run from a third party box and may not have pulpcore packages installed on it, or if they are, they may not be configured the same way. In those environments this import will fail or return incorrect data.
To resolve this, I think do two things:
- Have the test suite expect that
ALLOWED_CONTENT_CHECKSUMS = {"sha1", "sha224", "sha256", "sha384", "sha512"}. This is the same approach used by the import/export tests which require the user to set settings to specific values for the test suite to pass. - Have travis fulfill that requirement by adding in the var here:
Line 78 in ab3e4eb
pulp_settings: {"allowed_export_paths": ["/tmp"], "allowed_import_paths": ["/tmp"]}
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.
This last thing would need to go into the plugins template_config.yaml to survive regenerating the ci files.
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.
Also i just realize that this is a unit test. And i fail to see why it should be ok to import ArtifactSerializer but not Artifact.
Is there any context missing?
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.
Updated template_config.yml and regen'd. Turns out you cannot use sets and dynaconf together; tweaked ALLOWED_CONTENT_CHECKSUMS to be a list, explicitly used a set() around it wherever I needed to use difference/intersection.
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.
Also, yes, as noted by @mdellweg , these are unit-tests not functional-tests, so it's ok to rely on being able to import directly (as they all do)
dfe790d
to
d84d46c
Compare
And done! |
5f9e459
to
7cee76f
Compare
|
I was finally (sort of) able to pass the functional testsuite of pulpcore (pagination fails due to remaining repos from earlier tests of the same run) in fips environment. |
|
@ggainey is there a functional test that can assert that a sync'd content unit does not have 'md5' set? |
I only have unit-tests in this commit. Hm. |
I think you could likely extend this test to check on the md5 aspects of things pretty easily. https://github.com/pulp/pulpcore/blob/master/pulpcore/tests/functional/api/test_crd_artifacts.py#L52-L57 wdyt? |
7cee76f
to
ef13b38
Compare
Fine idea - added testing for "did you get md5 back from a valid upload?" and a new test for "trying to upload while specifying md5 as the checksum should fail" (both assuming md5 is not present in ALLOWED_CONTENT_CHECKSUMS) |
|
I'm LGTM once the |
ef13b38
to
53b2440
Compare
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.
Thank you for this very excellent piece of work. I really appreciate how you brought this together so quickly. 👍 🥇 🚀
settings.ALLOWED_CONTENT_CHECKSUMS now drives the other checksum-related fields of Artifact (DIGEST_FIELDS, COMMON_DIGEST_FIELDS, RELIABLE_DIGEST_FIELDS) closes #5216
53b2440
to
542714b
Compare
settings.ALLOWED_CONTENT_CHECKSUMS now drives the other checksum-related
fields of Artifact (DIGEST_FIELDS, COMMON_DIGEST_FIELDS, RELIABLE_DIGEST_FIELDS)
closes #5216