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

First part of ZONEMD support #11100

Merged
merged 16 commits into from Jan 14, 2022
Merged

First part of ZONEMD support #11100

merged 16 commits into from Jan 14, 2022

Conversation

omoerbeek
Copy link
Member

@omoerbeek omoerbeek commented Dec 15, 2021

Short description

  1. Define record type
  2. Verification according to RFC, including many failure cases and RSIG handling. Support sha384 and sha512
  3. Unit tests, including all examples from RFC and a few failure cases.
  4. Command line for pdnsutil: zonemd-verify-file

Based on POC from @Habbie, with many changes.

Things to be done I can think of (details to be decided):

For the Recursor:

  • validation of incoming zones (potentially Zone to Cache, RPZ, Auth-Zones). Those cases need to consider DNSSEC validation of ZONEMD records as well per RFC. Also config of zone should indicate if ZONEMD verification is required. For Zone to Cache and RPZ we can do that from Lua, for Auth Zones it is not immediately clear how.

For the Authoritative Server:

  • verify/insert/update/remove ZONEMD in DB
  • send ZONEMD out on AXFR.
  • verify incoming AXFR ZONEMD.

Both should be handled in separate PRs imo.

Checklist

I have:

  • read the CONTRIBUTING.md document
  • compiled this code
  • tested this code
  • included documentation (including possible behaviour changes)
  • documented the code
  • added or modified regression test(s)
  • added or modified unit test(s)

@github-actions
Copy link

github-actions bot commented Dec 15, 2021

@check-spelling-bot Report

Unrecognized words, please review:

  • zonemd
To accept these unrecognized words as correct, run the following commands

... in a clone of the git@github.com:omoerbeek/pdns.git repository
on the zonemd branch:

update_files() {
perl -e '
my $new_expect_file=".github/actions/spell-check/expect.txt";
use File::Path qw(make_path);
use File::Basename qw(dirname);
make_path (dirname($new_expect_file));
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"$patch_add"');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a)."-".$a cmp lc($b)."-".$b} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;
system("git", "add", $new_expect_file);
'
}

comment_json=$(mktemp)
curl -L -s -S \
  --header "Content-Type: application/json" \
  "https://api.github.com/repos/PowerDNS/pdns/issues/comments/994681988" > "$comment_json"
comment_body=$(mktemp)
jq -r .body < "$comment_json" > $comment_body
rm $comment_json

patch_add=$(perl -e '$/=undef;
$_=<>;
s{<details>.*}{}s;
s{^#.*}{};
s{\n##.*}{};
s{(?:^|\n)\s*\*}{}g;
s{\s+}{ }g;
print' < "$comment_body")
  
update_files
rm $comment_body
git add -u
If the flagged items do not appear to be text

If items relate to a ...

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

  • binary file.

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

pdns/sha.hh Outdated
md = EVP_sha512();
break;
default:
throw std::runtime_error("SHADigest: unsupported size");
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe use std::out_of_range?

Copy link
Member Author

@omoerbeek omoerbeek Dec 15, 2021

Choose a reason for hiding this comment

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

It reports errors that are consequence of attempt to access elements out of defined range.
So close, but not really it. std::invalid_argument fits better imo.

pdns/pdnsutil.cc Outdated Show resolved Hide resolved
pdns/sha.hh Outdated Show resolved Hide resolved
pdns/sha.hh Outdated Show resolved Hide resolved
pdns/sha.hh Outdated Show resolved Hide resolved
pdns/sha.hh Outdated Show resolved Hide resolved
pdns/sha.hh Outdated Show resolved Hide resolved
pdns/zonemd.cc Outdated Show resolved Hide resolved
Co-authored-by: Remi Gacogne <github@coredump.fr>
Copy link
Member

@chbruyand chbruyand left a comment

Choose a reason for hiding this comment

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

Didn't dive too much into zonemdVerify() as I don't know ZONEMD and found it a bit hard to read (lots of abbreviations that are lowercased/uppercased), but LGTM as it's tested and the API is clear and speaks for itself

pdns/zonemd.cc Outdated Show resolved Hide resolved
pdns/sha.hh Show resolved Hide resolved
@omoerbeek
Copy link
Member Author

Didn't dive too much into zonemdVerify() as I don't know ZONEMD and found it a bit hard to read (lots of abbreviations that are lowercased/uppercased), but LGTM as it's tested and the API is clear and speaks for itself

Good point, I'll rename some vars

Copy link
Member

@Habbie Habbie left a comment

Choose a reason for hiding this comment

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

Awesome work. I posted a few nits, but nothing major.

pdns/sha.hh Outdated Show resolved Hide resolved
{
bool operator()(const RRSetKey_t& a, const RRSetKey_t& b) const
{
// FIXME surely we can be smarter 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 believe this is my FIXME, I'll have a go at it

Copy link
Member

Choose a reason for hiding this comment

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

Ah yes, can't use std::tie because of the custom comparison function. I'll leave it for now..

pdns/zonemd.cc Outdated Show resolved Hide resolved
pdns/zonemd.cc Outdated Show resolved Hide resolved
@omoerbeek omoerbeek merged commit 2510786 into PowerDNS:master Jan 14, 2022
@omoerbeek omoerbeek deleted the zonemd branch January 14, 2022 10:48
@omoerbeek omoerbeek added this to the rec-4.7.0 milestone Feb 23, 2022
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.

None yet

5 participants