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

IJHack / QtPass / 23862950363

01 Apr 2026 05:54PM UTC coverage: 20.086% (+0.004%) from 20.082%
23862950363

push

github

web-flow
Merge pull request #890 from IJHack/fix/ai-findings-10-more

fix: address 10 more AI findings across 4 files

9 of 45 new or added lines in 7 files covered. (20.0%)

4 existing lines in 4 files now uncovered.

1030 of 5128 relevant lines covered (20.09%)

7.89 hits per line

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

1.45
/src/realpass.cpp
1
// SPDX-FileCopyrightText: 2016 Anne Jan Brouwer
2
// SPDX-License-Identifier: GPL-3.0-or-later
3
#include "realpass.h"
4
#include "debughelper.h"
5
#include "qtpasssettings.h"
6
#include "util.h"
7

8
#include <QDir>
9
#include <QFileInfo>
10
#include <QRegularExpression>
11
#include <utility>
12

13
using Enums::GIT_INIT;
14
using Enums::GIT_PULL;
15
using Enums::GIT_PUSH;
16
using Enums::PASS_COPY;
17
using Enums::PASS_INIT;
18
using Enums::PASS_INSERT;
19
using Enums::PASS_MOVE;
20
using Enums::PASS_OTP_GENERATE;
21
using Enums::PASS_REMOVE;
22
using Enums::PASS_SHOW;
23

24
RealPass::RealPass() = default;
1✔
25

26
/**
27
 * @brief RealPass::GitInit pass git init wrapper
28
 */
29
void RealPass::GitInit() { executePass(GIT_INIT, {"git", "init"}); }
×
30

31
/**
32
 * @brief RealPass::GitInit pass git pull wrapper which blocks until process
33
 *                          finishes
34
 */
35
void RealPass::GitPull_b() {
×
NEW
36
  int result = Executor::executeBlocking(QtPassSettings::getPassExecutable(),
×
37
                                         {"git", "pull"});
38
  if (result != 0) {
39
#ifdef QT_DEBUG
40
    dbg() << "Git pull failed with code:" << result;
41
#endif
42
  }
UNCOV
43
}
×
44

45
/**
46
 * @brief RealPass::GitPull pass git pull wrapper
47
 */
48
void RealPass::GitPull() { executePass(GIT_PULL, {"git", "pull"}); }
×
49

50
/**
51
 * @brief RealPass::GitPush pass git push wrapper
52
 */
53
void RealPass::GitPush() { executePass(GIT_PUSH, {"git", "push"}); }
×
54

55
/**
56
 * @brief RealPass::Show pass show
57
 *
58
 * @param file      file to decrypt
59
 *
60
 * @return  if block is set, returns exit status of internal decryption
61
 * process
62
 *          otherwise returns QProcess::NormalExit
63
 */
64
void RealPass::Show(QString file) {
×
65
  executePass(PASS_SHOW, {"show", file}, "", true);
×
66
}
×
67

68
/**
69
 * @brief RealPass::OtpGenerate pass otp
70
 * @param file      file containing OTP uri
71
 */
72
void RealPass::OtpGenerate(QString file) {
×
73
  executePass(PASS_OTP_GENERATE, {"otp", file}, "", true);
×
74
}
×
75

76
/**
77
 * @brief RealPass::Insert pass insert
78
 */
79
void RealPass::Insert(QString file, QString newValue, bool overwrite) {
×
80
  QStringList args = {"insert", "-m"};
×
81
  if (overwrite) {
×
82
    args.append("-f");
×
83
  }
84
  args.append(file);
85
  executePass(PASS_INSERT, args, newValue);
×
86
}
×
87

88
/**
89
 * @brief RealPass::Remove pass remove wrapper
90
 */
91
void RealPass::Remove(QString file, bool isDir) {
×
92
  executePass(PASS_REMOVE, {"rm", (isDir ? "-rf" : "-f"), file});
×
93
}
×
94

95
/**
96
 * @brief RealPass::Init initialize pass repository
97
 *
98
 * @param path  Absolute path to new password-store
99
 * @param users list of users with ability to decrypt new password-store
100
 */
101
void RealPass::Init(QString path, const QList<UserInfo> &users) {
×
102
  // remove the passStore directory otherwise,
103
  // pass would create a passStore/passStore/dir
104
  // but you want passStore/dir
105
  QString dirWithoutPassdir =
106
      path.remove(0, QtPassSettings::getPassStore().size());
×
107
  QStringList args = {"init", "--path=" + dirWithoutPassdir};
×
108
  foreach (const UserInfo &user, users) {
×
109
    if (user.enabled) {
×
110
      args.append(user.key_id);
×
111
    }
112
  }
113
  executePass(PASS_INIT, args);
×
114
}
×
115

116
/**
117
 * @brief RealPass::Move move a file (or folder)
118
 * @param src source file or folder
119
 * @param dest destination file or folder
120
 * @param force overwrite
121
 */
122
void RealPass::Move(const QString src, const QString dest, const bool force) {
×
123
  QFileInfo srcFileInfo = QFileInfo(src);
×
124
  QFileInfo destFileInfo = QFileInfo(dest);
×
125

126
  // force mode?
127
  // pass uses always the force mode, when call from eg. QT. so we have to
128
  // check if this are to files and the user didnt want to move force
129
  if (!force && srcFileInfo.isFile() && destFileInfo.isFile()) {
×
130
    return;
131
  }
132

133
  QString passSrc = QDir(QtPassSettings::getPassStore())
×
134
                        .relativeFilePath(QDir(src).absolutePath());
×
135
  QString passDest = QDir(QtPassSettings::getPassStore())
×
136
                         .relativeFilePath(QDir(dest).absolutePath());
×
137

138
  // remove the .gpg because pass will not work
139
  if (srcFileInfo.isFile() && srcFileInfo.suffix() == "gpg") {
×
140
    passSrc.replace(Util::endsWithGpg(), "");
×
141
  }
142
  if (destFileInfo.isFile() && destFileInfo.suffix() == "gpg") {
×
143
    passDest.replace(Util::endsWithGpg(), "");
×
144
  }
145

146
  QStringList args;
×
147
  args << "mv";
×
148
  if (force) {
×
149
    args << "-f";
×
150
  }
151
  args << passSrc;
152
  args << passDest;
153
  executePass(PASS_MOVE, args);
×
154
}
×
155

156
/**
157
 * @brief RealPass::Copy copy a file (or folder)
158
 * @param src source file or folder
159
 * @param dest destination file or folder
160
 * @param force overwrite
161
 */
162
void RealPass::Copy(const QString src, const QString dest, const bool force) {
×
163
  QFileInfo srcFileInfo = QFileInfo(src);
×
164
  QFileInfo destFileInfo = QFileInfo(dest);
×
165
  // force mode?
166
  // pass uses always the force mode, when call from eg. QT. so we have to
167
  // check if this are to files and the user didnt want to move force
168
  if (!force && srcFileInfo.isFile() && destFileInfo.isFile()) {
×
169
    return;
170
  }
171

172
  QString passSrc = QDir(QtPassSettings::getPassStore())
×
173
                        .relativeFilePath(QDir(src).absolutePath());
×
174
  QString passDest = QDir(QtPassSettings::getPassStore())
×
175
                         .relativeFilePath(QDir(dest).absolutePath());
×
176

177
  // remove the .gpg because pass will not work
178
  if (srcFileInfo.isFile() && srcFileInfo.suffix() == "gpg") {
×
179
    passSrc.replace(Util::endsWithGpg(), "");
×
180
  }
181
  if (destFileInfo.isFile() && destFileInfo.suffix() == "gpg") {
×
182
    passDest.replace(Util::endsWithGpg(), "");
×
183
  }
184
  QStringList args;
×
185
  args << "cp";
×
186
  if (force) {
×
187
    args << "-f";
×
188
  }
189
  args << passSrc;
190
  args << passDest;
191
  executePass(PASS_COPY, args);
×
192
}
×
193

194
/**
195
 * @brief Wrapper for executing pass commands.
196
 * @param id Process identifier for this operation
197
 * @param args Command-line arguments for pass
198
 * @param input Input to pass to the process (typically empty)
199
 * @param readStdout Whether to capture standard output
200
 * @param readStderr Whether to capture standard error output
201
 */
202
void RealPass::executePass(PROCESS id, const QStringList &args, QString input,
×
203
                           bool readStdout, bool readStderr) {
204
  executeWrapper(id, QtPassSettings::getPassExecutable(), args,
×
205
                 std::move(input), readStdout, readStderr);
206
}
×
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