|
QtPass 2.0.0
Developer documentation
|
Password-store path-boundary checks. More...
#include <pathvalidator.h>
Static Public Member Functions | |
| static auto | isPathInStore (const QString &storeRoot, const QString &candidate) -> bool |
| Check that a candidate path resolves inside the password store root, after following symlinks and resolving .. components. | |
| static auto | storeRelativePath (const QString &storeRoot, const QString &candidate) -> std::optional< QString > |
Where candidate lies in the store, judged as isPathInStore() judges it. | |
| static auto | isTargetSpelled (const QString &storeRoot, const QString &path) -> bool |
Whether path is spelled through the target of a store root that is itself a link, rather than from the root as configured. | |
Password-store path-boundary checks.
Extracted from Util. Guards file/folder create, rename, and drag-drop against paths that resolve outside the configured password store.
Threat model: this catches mistakes and malformed input, such as a typed .., a pasted absolute path or a symlink that happens to point outside the store. It is not a defence against another process that can write to the store while QtPass runs: the check and the file operation that follows it are separate steps, and a symlink swapped in between them is not seen (the usual time-of-check/time-of-use gap of a path-based API). Anyone who can write to your password store can also replace its contents, so that is outside what QtPass can protect.
Definition at line 31 of file pathvalidator.h.
|
static |
Check that a candidate path resolves inside the password store root, after following symlinks and resolving .. components.
For candidates that already exist on disk the path is canonicalised via QFileInfo::canonicalFilePath() (which resolves symlinks). For candidates that do not yet exist (typical "create new file" flow) we walk up to the nearest existing ancestor, canonicalise that, then re-append the leaf components. This catches both user-typed .. escapes and symlinks pointing outside the store.
| storeRoot | Password store root (typically QtPassSettings::getPassStore()). |
| candidate | Path to validate. May be absolute or relative; relative paths are interpreted against the current working directory before resolution. |
Definition at line 13 of file pathvalidator.cpp.
|
static |
Whether path is spelled through the target of a store root that is itself a link, rather than from the root as configured.
The Pass operations take the configured spelling (see the Pass class documentation); this names the one spelling that breaks that rule while still lying in the store. Nothing is resolved below the root.
| storeRoot | Password store root, as configured. |
| path | An absolute path; a relative one is never off-rule. |
path lies under the root's canonical path but not under the root as configured, and the two differ. Definition at line 69 of file pathvalidator.cpp.
|
static |
Where candidate lies in the store, judged as isPathInStore() judges it.
The relative path comes from the same canonical pair the check uses, so a store root reached through a link and a candidate spelled through the link's target still give team, not ../../data/pass/team.
| storeRoot | Password store root. |
| candidate | Path to place, as for isPathInStore(). |
Definition at line 18 of file pathvalidator.cpp.