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

mendersoftware / mender / 2314337760

03 Feb 2026 07:39PM UTC coverage: 75.808% (-0.1%) from 75.944%
2314337760

push

gitlab-ci

web-flow
Merge pull request #1893 from mendersoftware/cherry-5.0.x-master

[Cherry 5.0.x]: fix: add Host header to proxy HTTP CONNECT request

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

402 existing lines in 16 files now uncovered.

7508 of 9904 relevant lines covered (75.81%)

13703.53 hits per line

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

71.43
/src/common/path/path.cpp
1
// Copyright 2025 Northern.tech AS
2
//
3
//    Licensed under the Apache License, Version 2.0 (the "License");
4
//    you may not use this file except in compliance with the License.
5
//    You may obtain a copy of the License at
6
//
7
//        http://www.apache.org/licenses/LICENSE-2.0
8
//
9
//    Unless required by applicable law or agreed to in writing, software
10
//    distributed under the License is distributed on an "AS IS" BASIS,
11
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//    See the License for the specific language governing permissions and
13
//    limitations under the License.
14

15
#include <common/path.hpp>
16

17
#include <filesystem>
18
#include <string>
19
#include <unordered_set>
20

21
#include <common/error.hpp>
22

23
namespace mender {
24
namespace common {
25
namespace path {
26

27
using namespace std;
28

29
expected::ExpectedBool IsWithinOrEqual(const string &check_path, const string &target_dir) {
1,419✔
30
        auto exp_canonical_check_path = WeaklyCanonical(check_path);
1,419✔
31
        if (!exp_canonical_check_path.has_value()) {
1,419✔
32
                return expected::unexpected(exp_canonical_check_path.error().WithContext(
×
UNCOV
33
                        "Error creating canonical path, path to check: '" + check_path));
×
34
        }
35

36
        auto exp_canonical_target_dir = WeaklyCanonical(target_dir);
1,419✔
37
        if (!exp_canonical_target_dir.has_value()) {
1,419✔
UNCOV
38
                return expected::unexpected(exp_canonical_target_dir.error().WithContext(
×
UNCOV
39
                        "Error creating canonical path, target directory: '" + target_dir));
×
40
        }
41

42
        auto canonical_check_path = exp_canonical_check_path.value();
1,419✔
43
        auto canonical_target_dir = exp_canonical_target_dir.value();
1,419✔
44

45
        // Terminate both with "/", otherwise we could mistakenly say that
46
        // 1. /test/testabc in contained within /test/test
47
        // 2. /test/test in not equal to /test/test/
48
        if (canonical_check_path.back() != '/') {
1,419✔
49
                canonical_check_path += '/';
50
        }
51
        if (canonical_target_dir.back() != '/') {
1,419✔
52
                canonical_target_dir += '/';
53
        }
54

55
        if (canonical_check_path.rfind(canonical_target_dir, 0) == 0) {
1,419✔
56
                return true;
57
        }
58
        return false;
59
}
60

61
} // namespace path
62
} // namespace common
63
} // namespace mender
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

© 2026 Coveralls, Inc