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

Provide implementation for Zone11 (SPF test) #1287

Merged
merged 7 commits into from
Dec 4, 2023

Conversation

marc-vanderwal
Copy link
Contributor

Purpose

This PR introduces an implementation for Zone11, the test case for SPF policies.

Context

Changes

  • Add the implementation for the test case.
  • Provide unit tests and data.
  • Update dependencies.

How to test this PR

  • Run the unit tests. There should be no errors.

@marc-vanderwal marc-vanderwal added T-Feature Type: New feature in software or test case description A-TestCase Area: Test case specification or implementation of test case V-Major Versioning: The change gives an update of major in version. labels Sep 7, 2023
@marc-vanderwal marc-vanderwal added this to the v2023.2 milestone Sep 7, 2023
@marc-vanderwal marc-vanderwal linked an issue Sep 7, 2023 that may be closed by this pull request
@marc-vanderwal marc-vanderwal force-pushed the feature/spf-test branch 2 times, most recently from aa6361f to b67c363 Compare November 2, 2023 15:29
@marc-vanderwal
Copy link
Contributor Author

The CI failures are due to a known issue in Mail::SPF: https://rt.cpan.org/Public/Bug/Display.html?id=34768

@marc-vanderwal marc-vanderwal force-pushed the feature/spf-test branch 2 times, most recently from dafa092 to cab0ca4 Compare November 9, 2023 09:06
@marc-vanderwal
Copy link
Contributor Author

marc-vanderwal commented Nov 9, 2023

Installing Mail::SPF through the OS packages in Github Actions doesn’t work, because the package is built against the version of Perl that comes with the system, instead of the versions of Perl that we are testing with. I’m reverting to my previous solution that worked.

@marc-vanderwal marc-vanderwal force-pushed the feature/spf-test branch 3 times, most recently from 1665d7d to bc30628 Compare November 15, 2023 15:13
lib/Zonemaster/Engine/Test/Zone.pm Outdated Show resolved Hide resolved
lib/Zonemaster/Engine/Test/Zone.pm Outdated Show resolved Hide resolved
lib/Zonemaster/Engine/Test/Zone.pm Outdated Show resolved Hide resolved
lib/Zonemaster/Engine/Test/Zone.pm Outdated Show resolved Hide resolved
lib/Zonemaster/Engine/Test/Zone.pm Outdated Show resolved Hide resolved
share/profile.json Show resolved Hide resolved
share/profile.json Outdated Show resolved Hide resolved
share/profile.json Outdated Show resolved Hide resolved
t/Test-zone11.t Outdated Show resolved Hide resolved
t/profiles/Test-zone11-only.json Outdated Show resolved Hide resolved
@marc-vanderwal marc-vanderwal force-pushed the feature/spf-test branch 2 times, most recently from 543feac to ce91cf2 Compare November 16, 2023 15:09
@marc-vanderwal
Copy link
Contributor Author

I just need to address your comment on the t/Test-zone11.t to have it in line with #1297.

@marc-vanderwal
Copy link
Contributor Author

I just need to address your comment on the t/Test-zone11.t to have it in line with #1297.

That is now done.

@matsduf
Copy link
Contributor

matsduf commented Nov 27, 2023

This requires new dependencies, doesn't it? An update of the installation instructions is needed.

matsduf
matsduf previously approved these changes Nov 27, 2023
Copy link
Contributor

@matsduf matsduf left a comment

Choose a reason for hiding this comment

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

Please create a PR for updating the installation instructions before merging this.

@matsduf matsduf requested a review from tgreenx November 27, 2023 11:18
marc-vanderwal added a commit to marc-vanderwal/zonemaster that referenced this pull request Nov 28, 2023
Pull request zonemaster/zonemaster-engine#1287 adds a run-time
dependency on Mail::SPF. This comment documents the change in the
public-facing installation instructions.

Mail::SPF is not required for building Zonemaster::Engine, so the
internal documentation pertaining to the build environment does not need
to be updated.
@tgreenx
Copy link
Contributor

tgreenx commented Nov 28, 2023

Considering Marc's absence and the nature of my suggested change, I took the liberty of providing it, see commit f54b9e8. @matsduf please re-review.

@tgreenx tgreenx force-pushed the feature/spf-test branch 2 times, most recently from 36e858e to f54b9e8 Compare November 28, 2023 14:03
@tgreenx tgreenx requested review from tgreenx and matsduf November 28, 2023 14:04
tgreenx
tgreenx previously approved these changes Nov 28, 2023
marc-vanderwal and others added 7 commits November 29, 2023 17:05
Depend on Mail::SPF for validating SPF policies.
There is a long-standing packaging issue with Mail::SPF that prevents
cpanm from automatically installing it with non-root privileges. [1] It
also seems that upstream is unwilling to patch the problem.

Yet this package is very useful for checking SPF syntax. One does not
simply reimplement the same thing by oneself.

So what are our options? Fork it? Copy the code and maintain it in a
Zonemaster::Engine::SPF namespace or similar? Or work around the bug?

Fortunately, the Perl library in question is easy to find in
distribution package repositories. It’s packaged by Debian, Ubuntu,
Alpine Linux, FreeBSD at least.

However, in Github Actions, all Perl modules are install from CPAN. That
must be because the Perl module packages supplied by the OS are only
built against the version of Perl packaged by said OS, and we are
testing against multiple different versions of Perl that may be
different from the packaged one. In order to keep that consistency, the
best option is to install Mail::SPF from CPAN while adding the
workaround documented in the library’s INSTALL file.

[1]: https://rt.cpan.org/Public/Bug/Display.html?id=34768
In the continuous integration pipeline, use cpanm --sudo instead of
plain cpanm to install all Perl packages.

Doing so works around a packaging issue with Mail::SPF, and more closely
reflects the official installation procedure.
Change the format of the test declarations inside t/Test-zone11.t so
that it conforms to the format specified and agreed to in zonemaster#1297.

This is unfortunately not a lossless conversion: the old format made it
possible to specify extra checks such as “for zone
all-different-spf.zone11.xa, the Z11_DIFFERENT_SPF_POLICIES_FOUND should
be output 3 times”. Hopefully this can be brought back somehow later.

Also, for some reason, the changes in the .t file required a new test
run with ZONEMASTER_RECORD=1 set in the environment.
Document function "Zonemaster::Engine::Test::Zone::_spf_syntax_ok()"
@tgreenx
Copy link
Contributor

tgreenx commented Nov 29, 2023

This PR required some changes due to the recent merge of #1302. It is now done in commit 9471d82. I also took the opportunity to rebase on latest develop.

@marc-vanderwal
Copy link
Contributor Author

Great, thanks! This looks good to me.

@marc-vanderwal marc-vanderwal merged commit 40dcce5 into zonemaster:develop Dec 4, 2023
3 checks passed
marc-vanderwal added a commit to marc-vanderwal/zonemaster that referenced this pull request Dec 4, 2023
Pull request zonemaster/zonemaster-engine#1287 adds a run-time
dependency on Mail::SPF. This comment documents the change in the
public-facing installation instructions.

Mail::SPF is not required for building Zonemaster::Engine, so the
internal documentation pertaining to the build environment does not need
to be updated.
tgreenx added a commit to tgreenx/zonemaster-cli that referenced this pull request Dec 4, 2023
- Bumped Perl supported versions
- Added Mail::SPF dependency. Zonemaster-Engine relies on Mail::SPF and there is a bug preventing its installation from cpanm. See Zonemaster-Engine commit `3ac72b0c` and/or pull request <zonemaster/zonemaster-engine#1287> for more information on this.
tgreenx added a commit to tgreenx/zonemaster-cli that referenced this pull request Dec 4, 2023
- Bumped Perl supported versions
- Bumped distribution version
- Added Mail::SPF dependency. Zonemaster-Engine relies on Mail::SPF and there is a bug preventing its installation from cpanm. See Zonemaster-Engine commit `3ac72b0c` and/or pull request <zonemaster/zonemaster-engine#1287> for more information on this.
@matsduf matsduf added the S-ReleaseTested Status: The PR has been successfully tested in release testing label Mar 17, 2024
@matsduf
Copy link
Contributor

matsduf commented Mar 17, 2024

Release testing: Looks fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-TestCase Area: Test case specification or implementation of test case S-ReleaseTested Status: The PR has been successfully tested in release testing T-Feature Type: New feature in software or test case description V-Major Versioning: The change gives an update of major in version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing implementation for Zone11
3 participants