• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PowerDNS / pdns / 18679017918

21 Oct 2025 09:15AM UTC coverage: 69.743% (+2.0%) from 67.713%
18679017918

Pull #16307

github

web-flow
Merge ba88af487 into da98764c6
Pull Request #16307: rec: explicit disabling/enabling of tls-gnutls for full and least configs and packages

26192 of 45526 branches covered (57.53%)

Branch coverage included in aggregate %.

6 of 6 new or added lines in 1 file covered. (100.0%)

2282 existing lines in 57 files now uncovered.

86265 of 115719 relevant lines covered (74.55%)

4323875.05 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

21.88
/pdns/secpoll.cc
1
/*
2
 * This file is part of PowerDNS or dnsdist.
3
 * Copyright -- PowerDNS.COM B.V. and its contributors
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of version 2 of the GNU General Public License as
7
 * published by the Free Software Foundation.
8
 *
9
 * In addition, for the avoidance of any doubt, permission is granted to
10
 * link this program with OpenSSL and to (re)distribute the binaries
11
 * produced as the result of such linking.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
 */
22

23
#include <string>
24
#include <vector>
25
#include "dnsrecords.hh"
26
#include "pdnsexception.hh"
27
#include "misc.hh"
28
#include "secpoll.hh"
29

30
bool isReleaseVersion(const std::string &version) {
169✔
31
  return std::count(version.begin(), version.end(), '.') == 2;
169✔
32
}
169✔
33

34
static void setSecPollToUnknownOnOK(int &secPollStatus) {
169✔
35
  if (secPollStatus == 1) { // it was ok, now it is unknown
169!
UNCOV
36
    secPollStatus = 0;
×
UNCOV
37
  }
×
38
}
169✔
39

40
void processSecPoll(const int res, const std::vector<DNSRecord> &ret, int &secPollStatus, std::string &secPollMessage) {
169✔
41
  secPollMessage.clear();
169✔
42
  if (res != 0) { // not NOERROR
169!
43
    setSecPollToUnknownOnOK(secPollStatus);
169✔
44
    throw PDNSException("RCODE was " + RCode::to_s(res));
169✔
45
  }
169✔
46

UNCOV
47
  if (ret.empty()) { // empty NOERROR... wat?
×
UNCOV
48
    if (secPollStatus == 1) { // it was ok, now it is unknown
×
49
      secPollStatus = 0;
×
50
    }
×
UNCOV
51
    throw PDNSException("Had empty answer on NOERROR RCODE");
×
UNCOV
52
  }
×
53

UNCOV
54
  DNSRecord record;
×
UNCOV
55
  for (auto const &records: ret) {
×
UNCOV
56
    if (records.d_type == QType::TXT && records.d_place == DNSResourceRecord::Place::ANSWER) {
×
UNCOV
57
      record = records;
×
UNCOV
58
      break;
×
UNCOV
59
    }
×
UNCOV
60
  }
×
61

UNCOV
62
  if (record.d_name.empty()) {
×
UNCOV
63
    setSecPollToUnknownOnOK(secPollStatus);
×
UNCOV
64
    throw PDNSException("No TXT record found in response");
×
UNCOV
65
  }
×
66

UNCOV
67
  auto recordContent = getRR<TXTRecordContent>(record);
×
UNCOV
68
  if (recordContent == nullptr) {
×
69
    setSecPollToUnknownOnOK(secPollStatus);
×
70
    throw PDNSException("Could not parse TXT record content");
×
71
  }
×
UNCOV
72
  string content = recordContent->d_text;
×
73

UNCOV
74
  pair<string, string> split = splitField(unquotify(content), ' ');
×
75

UNCOV
76
  try {
×
UNCOV
77
    secPollStatus = std::stoi(split.first);
×
UNCOV
78
  } catch (const std::exception &e) {
×
UNCOV
79
    setSecPollToUnknownOnOK(secPollStatus);
×
UNCOV
80
    throw PDNSException(std::string("Could not parse status number: ") + e.what());
×
UNCOV
81
  }
×
UNCOV
82
  secPollMessage = split.second;
×
UNCOV
83
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc