3#ifndef SRC_IMITATEPASS_H_
4#define SRC_IMITATEPASS_H_
7#include "simpletransaction.h"
9class QRegularExpression;
29 friend class tst_util;
62 auto signGpgIdFile(
const QString &gpgIdFile,
const QStringList &signingKeys)
71 void gitAddGpgId(
const QString &gpgIdFile,
const QString &gpgIdSigFile,
72 bool addFile,
bool addSigFile);
81 QStringList &gpgId) -> bool;
100 const QStringList &recipients) -> bool;
109 bool force) -> QString;
125 void gitCommit(
const QString &file,
const QString &msg);
136 QString input = QString(),
bool readStdout =
true,
137 bool readStderr =
true);
147 QString input = QString(),
bool readStdout =
true,
148 bool readStderr =
true);
165 : m_transaction(trans), m_result(result) {
166 m_transaction->transactionStart();
182 void finished(
int id,
int exitCode,
const QString &out,
183 const QString &err)
override;
195 QString input,
bool readStdout =
true,
196 bool readStderr =
true)
override;
231 void Show(QString file)
override;
243 void Insert(QString file, QString newValue,
bool overwrite =
false)
override;
249 void Remove(QString file,
bool isDir =
false)
override;
255 void Init(QString path,
const QList<UserInfo> &users)
override;
281 void Move(
const QString src,
const QString dest,
282 const bool force =
false)
override;
289 void Copy(
const QString src,
const QString dest,
290 const bool force =
false)
override;
301 void Grep(QString pattern,
bool caseInsensitive =
false)
override;
305 QList<QThread *> m_grepThreads;
307 static auto grepMatchFile(
const QStringList &env,
const QString &gpgExe,
308 const QString &filePath,
309 const QRegularExpression &rx) -> QStringList;
310 static auto grepScanStore(
const QStringList &env,
const QString &gpgExe,
311 const QString &storeDir,
312 const QRegularExpression &rx)
313 -> QList<QPair<QString, QStringList>>;
~transactionHelper()
End transaction on destruction.
transactionHelper(simpleTransaction *trans, PROCESS result)
Start transaction.
auto createBackupCommit() -> bool
Create git backup commit before re-encryption.
void OtpGenerate(QString file) override
Generate OTP.
void GitInit() override
Initialize Git repository.
void executeGpg(PROCESS id, const QStringList &args, QString input=QString(), bool readStdout=true, bool readStderr=true)
Execute GPG command.
void GitPull_b() override
Pull with rebase.
~ImitatePass() override
Destructor.
auto checkSigningKeys(const QStringList &signingKeys) -> bool
Check if signing keys are valid.
ImitatePass()
Construct ImitatePass instance.
auto reencryptSingleFile(const QString &fileName, const QStringList &recipients) -> bool
Re-encrypt single file with new recipients.
auto verifyGpgIdFile(const QString &file) -> bool
Verify .gpg-id file exists and is valid.
void executeGit(PROCESS id, const QStringList &args, QString input=QString(), bool readStdout=true, bool readStderr=true)
Execute git command.
void Init(QString path, const QList< UserInfo > &users) override
Initialize store.
void Grep(QString pattern, bool caseInsensitive=false) override
Search all password content by GPG-decrypting each .gpg file.
auto verifyGpgIdForDir(const QString &file, QStringList &gpgIdFilesVerified, QStringList &gpgId) -> bool
Verify .gpg-id file for a directory.
void Insert(QString file, QString newValue, bool overwrite=false) override
Insert new password.
auto removeDir(const QString &dirName) -> bool
Remove directory recursively.
void executeMoveGit(const QString &src, const QString &destFile, bool force)
Execute git move operation.
void Move(const QString src, const QString dest, const bool force=false) override
Move password file.
void Copy(const QString src, const QString dest, const bool force=false) override
Copy password file.
void endReencryptPath()
Emitted after finishing re-encryption.
void finished(int id, int exitCode, const QString &out, const QString &err) override
Handle process completion.
void executeWrapper(PROCESS id, const QString &app, const QStringList &args, QString input, bool readStdout=true, bool readStderr=true) override
Execute command wrapper.
auto signGpgIdFile(const QString &gpgIdFile, const QStringList &signingKeys) -> bool
Sign .gpg-id file with signing keys.
void Remove(QString file, bool isDir=false) override
Remove password.
void GitPull() override
Pull from remote.
void Show(QString file) override
Show decrypted password.
auto resolveMoveDestination(const QString &src, const QString &dest, bool force) -> QString
Resolve destination for move operation.
void GitPush() override
Push to remote.
void writeGpgIdFile(const QString &gpgIdFile, const QList< UserInfo > &users)
Write recipients to .gpg-id file.
void gitAddGpgId(const QString &gpgIdFile, const QString &gpgIdSigFile, bool addFile, bool addSigFile)
Add .gpg-id to git staging.
void startReencryptPath()
Emitted before starting re-encryption.
auto getKeysFromFile(const QString &fileName) -> QStringList
Read recipients from file.
void reencryptPath(const QString &dir)
Re-encrypt entire directory.
void gitCommit(const QString &file, const QString &msg)
Commit changes to git.
Enums::PROCESS PROCESS
Alias for Enums::PROCESS used throughout this class.
Pass()
Construct a Pass instance.
simpleTransaction()
Construct a simpleTransaction in its initial idle state.