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

IJHack / QtPass / 43475275928

13 Nov 2026 05:41PM UTC coverage: 92.709% (-0.02%) from 92.727%
43475275928

push

github

web-flow
coverage: let lcov ignore inconsistent data on system headers (#2136)

lcov 2.x on the CI runner (gcc 15 headers) fails the coverage job with
"lcov: ERROR: (inconsistent) ...: function ... is not hit but line ... has
a non-zero hit count" on files outside the project (e.g. /usr/include/c++/15
and Qt headers), aborting lcov_prepare before coverage of src/ is produced.

The captures already pass "--ignore-errors unused"; add "inconsistent" the
same way to the capture, extract and combine steps. Only the consistency
check on data that is filtered out anyway (-e src/*) is bypassed; src/
coverage is unchanged.

Signed-off-by: Anne Jan Brouwer <brouwer@annejan.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>

10452 of 11274 relevant lines covered (92.71%)

402.92 hits per line

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

93.33
/src/pathvalidator.cpp
1
// SPDX-FileCopyrightText: 2014 Anne Jan Brouwer
2
// SPDX-License-Identifier: GPL-3.0-or-later
3

4
/**
5
 * @class PathValidator
6
 * @brief Password-store path-boundary checks implementation.
7
 *
8
 * @see pathvalidator.h
9
 */
10

11
#include "pathvalidator.h"
12
#include <QDir>
13
#include <QFileInfo>
14
#include <QStringList>
15

16
auto PathValidator::isPathInStore(const QString &storeRoot,
68 ✔
17
                                  const QString &candidate) -> bool {
18
  return storeRelativePath(storeRoot, candidate).has_value();
68 ✔
19
}
20

21
auto PathValidator::storeRelativePath(const QString &storeRoot,
122 ✔
22
                                      const QString &candidate)
23
    -> std::optional<QString> {
24
  if (storeRoot.isEmpty() || candidate.isEmpty()) {
122 ✔
25
    return std::nullopt;
3 ✔
26
  }
27
  const QString rootCanon = QDir(storeRoot).canonicalPath();
119 ✔
28
  if (rootCanon.isEmpty()) {
119 ✔
29
    return std::nullopt;
1 ✔
30
  }
31

32
  QString resolved;
118 ✔
33
  const QFileInfo fi(QDir::cleanPath(QFileInfo(candidate).absoluteFilePath()));
236 ✔
34
  if (fi.exists()) {
118 ✔
35
    resolved = fi.canonicalFilePath();
134 ✔
36
  } else {
37
    // Walk up to the nearest existing ancestor so we can canonicalise it
38
    // (resolves any symlinks on the way to the store root), then re-append
39
    // the leaf components below that ancestor.
40
    QDir parent = fi.dir();
51 ✔
41
    QStringList tail;
51 ✔
42
    tail.prepend(fi.fileName());
51 ✔
43
    while (!parent.exists()) {
59 ✔
44
      tail.prepend(parent.dirName());
8 ✔
45
      // The filesystem root always exists, so the loop terminates there
46
      // before cdUp() can fail; this guard is defensive against a
47
      // pathological QDir that can neither exist nor ascend.
48
      if (!parent.cdUp()) {
8 ✔
49
        return std::nullopt;
×
50
      }
51
    }
52
    const QString parentCanon = parent.canonicalPath();
51 ✔
53
    if (parentCanon.isEmpty()) {
51 ✔
54
      return std::nullopt;
×
55
    }
56
    resolved = QDir::cleanPath(parentCanon + QLatin1Char('/') +
102 ✔
57
                               tail.join(QLatin1Char('/')));
102 ✔
58
  }
51 ✔
59

60
  if (resolved.isEmpty()) {
118 ✔
61
    return std::nullopt;
×
62
  }
63
  if (resolved == rootCanon) {
118 ✔
64
    return QString();
31 ✔
65
  }
66
  if (!resolved.startsWith(rootCanon + QLatin1Char('/'))) {
174 ✔
67
    return std::nullopt;
22 ✔
68
  }
69
  return resolved.mid(rootCanon.size() + 1);
130 ✔
70
}
118 ✔
71

72
auto PathValidator::isTargetSpelled(const QString &storeRoot,
284 ✔
73
                                    const QString &path) -> bool {
74
  if (storeRoot.isEmpty() || !QDir::isAbsolutePath(path)) {
568 ✔
75
    return false;
2 ✔
76
  }
77
#ifdef Q_OS_WIN
78
  constexpr auto cs = Qt::CaseInsensitive;
79
#else
80
  constexpr auto cs = Qt::CaseSensitive;
81
#endif
82
  const QString root = QDir::cleanPath(storeRoot);
282 ✔
83
  const QString canonical = QDir(root).canonicalPath();
282 ✔
84
  if (canonical.isEmpty() || canonical.compare(root, cs) == 0) {
282 ✔
85
    return false;
275 ✔
86
  }
87
  const auto atOrUnder = [cs](const QString &p, const QString &dir) {
12 ✔
88
    const QString prefix =
89
        dir.endsWith(QLatin1Char('/')) ? dir : dir + QLatin1Char('/');
12 ✔
90
    return p.compare(dir, cs) == 0 || p.startsWith(prefix, cs);
24 ✔
91
  };
92
  const QString cleaned = QDir::cleanPath(path);
7 ✔
93
  return !atOrUnder(cleaned, root) && atOrUnder(cleaned, canonical);
7 ✔
94
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc