20 Commits

Author SHA1 Message Date
d844f1de04 Added starting and containing results individual sorting
Updated spec file to work on gitea releases
2025-03-25 01:32:54 +03:00
96f7a83e1e Automatic commit of package [gnome-pass-search-provider] release [1.3.2-1].
Created by command:

/usr/bin/tito tag --use-version 1.3.2
2023-11-13 04:18:41 +03:00
34e297592a New specfile 2023-11-13 04:17:17 +03:00
375feac8a0 Initialized to use tito. 2023-11-13 04:11:48 +03:00
101c833db2 Merge branch 'master' into clever-fuzz 2023-11-13 03:11:18 +03:00
bf053eda24 Added multistep pattern matching 2023-11-13 02:24:20 +03:00
522436fdfb Added alphabetic sort of passwords within directory 2023-06-20 23:42:14 +03:00
72fe6f3007 Replaced fuzzy search with exact string start match 2023-03-28 21:30:03 +03:00
6789843eeb Merge pull request #36 from electrickite/rbw-clipboard-copy
Enable field searches for rbw when using native clipboard
2022-11-04 01:07:49 +00:00
3406972e21 Enable field searches for rbw when using native clipboard 2022-11-03 17:10:04 -04:00
005a161bb1 Merge pull request #35 from electrickite/rbw-fields
Support field searches for Bitwarden/rbw
2022-10-28 01:14:13 +00:00
973ad49c33 Add support for field searches to Bitwarden/rbw 2022-10-26 20:27:33 -04:00
8a973038ab Merge pull request #33 from jnphilipp/fix-notifications
Default in getenv needs to be str not bool.
2022-10-07 09:49:06 +00:00
2ced9fe955 Default in getenv needs to be str not bool. 2022-10-02 18:26:14 +02:00
6dc332843d Merge pull request #32 from jnphilipp/fix-notification
Fix NoneType error when DISABLE_NOTIFICATIONS is not set.
2022-10-01 21:43:01 +00:00
102b7e044a Fix NoneType error. 2022-10-01 18:17:24 +02:00
92270735c5 Merge branch 'Layerex-disable-notifications' 2022-09-30 11:41:25 +02:00
e98543973a Require DISABLE_NOTIFICATIONS to be set to True, update README. 2022-09-30 11:41:00 +02:00
62b63dc3e1 Don't disable error notifications with environment variable 2022-09-28 11:16:45 +03:00
d302782073 Add support for disabling notifications with enviroment variable 2022-09-28 11:09:05 +03:00
6 changed files with 113 additions and 50 deletions

3
.tito/packages/.readme Normal file
View File

@ -0,0 +1,3 @@
the .tito/packages directory contains metadata files
named after their packages. Each file has the latest tagged
version and the project's relative directory.

View File

@ -0,0 +1 @@
1.3.2-1 ./

5
.tito/tito.props Normal file
View File

@ -0,0 +1,5 @@
[buildconfig]
builder = tito.builder.Builder
tagger = tito.tagger.VersionTagger
changelog_do_not_remove_cherrypick = 0
changelog_format = %s (%ae)

View File

@ -76,6 +76,10 @@ pin: 123456
To copy the pin start the search with `:pin` and for the username with `:user`.
## Disabling notifications
Set the `DISABLE_NOTIFICATIONS` environment variable to `True`.
# Alternative password providers
## Gopass and other pass-compatible tools

View File

@ -67,6 +67,9 @@ class SearchPassService(dbus.service.Object):
self.password_executable = getenv("PASSWORD_EXECUTABLE") or "pass"
self.password_mode = getenv("PASSWORD_MODE") or "pass"
self.clipboard_executable = getenv("CLIPBOARD_EXECUTABLE") or "wl-copy"
self.disable_notifications = (
getenv("DISABLE_NOTIFICATIONS", "false").lower() == "true"
)
@dbus.service.method(in_signature="sasu", **sbn)
def ActivateResult(self, id, terms, timestamp):
@ -102,18 +105,33 @@ class SearchPassService(dbus.service.Object):
pass
def get_bw_result_set(self, terms):
if terms[0].startswith(":"):
field = terms[0][1:]
terms = terms[1:]
else:
field = None
name = "".join(terms)
password_list = subprocess.check_output(
[self.password_executable, "list"], universal_newlines=True
).split("\n")[:-1]
results = [
results = list(filter(lambda p: p.startswith(name), password_list))[:5]
remaining = 5 - len(results)
if remaining > 0:
fuzzy_results = [
e[0]
for e in process.extract(
name, password_list, limit=5, scorer=fuzz.partial_ratio
name, password_list, limit=remaining, scorer=fuzz.token_sort_ratio
)
]
results.extend(fuzzy_results)
if field is not None:
results = [f":{field} {r}" for r in results]
return results
def get_pass_result_set(self, terms):
@ -139,51 +157,76 @@ class SearchPassService(dbus.service.Object):
path = path_join(dir_path, filename)[:-4]
password_list.append(path)
results = [
results = list(sorted(filter(lambda p: p.startswith(name), password_list)))[:5]
remaining = 5 - len(results)
if remaining > 0:
containing_results = list(
sorted(filter(lambda p: name in p, password_list))
)[:remaining]
results.extend(containing_results)
remaining = 5 - len(results)
if remaining > 0:
fuzzy_results = [
e[0]
for e in process.extract(
name, password_list, limit=5, scorer=fuzz.partial_ratio
name, password_list, limit=remaining, scorer=fuzz.token_sort_ratio
)
]
results.extend(fuzzy_results)
if field == "otp":
results = [f"otp {r}" for r in results]
elif field is not None:
results = [f":{field} {r}" for r in results]
return results
def get_value_from_output(self, output, field=None):
if field is not None:
match = re.search(
rf"^{field}:\s*(?P<value>.+?)$", output, flags=re.I | re.M
)
if match:
value = match.group("value")
else:
raise RuntimeError(
f"The field {field} was not found in the password entry."
)
else:
value = output.split("\n", 1)[0]
return value
def send_password_to_gpaste(self, base_args, name, field=None):
gpaste = self.session_bus.get_object(
"org.gnome.GPaste.Daemon", "/org/gnome/GPaste"
)
output = subprocess.check_output(base_args + [name], universal_newlines=True)
if field is not None:
match = re.search(
rf"^{field}:\s*(?P<value>.+?)$", output, flags=re.I | re.M
)
if match:
password = match.group("value")
else:
raise RuntimeError(f"The field {field} was not found in the pass file.")
else:
password = output.split("\n", 1)[0]
value = self.get_value_from_output(output, field)
try:
gpaste.AddPassword(name, password, dbus_interface="org.gnome.GPaste1")
gpaste.AddPassword(name, value, dbus_interface="org.gnome.GPaste1")
except dbus.DBusException:
gpaste.AddPassword(name, password, dbus_interface="org.gnome.GPaste2")
gpaste.AddPassword(name, value, dbus_interface="org.gnome.GPaste2")
def send_password_to_native_clipboard(self, base_args, name, field=None):
if field is not None:
raise RuntimeError("This feature requires GPaste.")
if self.password_mode == "bw":
p1 = subprocess.Popen(base_args + [name], stdout=subprocess.PIPE)
p2 = subprocess.run(self.clipboard_executable, stdin=p1.stdout)
if p1.returncode or p2.returncode:
output = subprocess.check_output(
base_args + [name], universal_newlines=True
)
value = self.get_value_from_output(output, field)
p1 = subprocess.run(self.clipboard_executable, input=value, text=True)
if p1.returncode:
raise RuntimeError(
f"Error while running rbw: got return codes: {p1.returncode} {p2.returncode}."
f"Error while running copying to clipboard: got return code: {p1.returncode}."
)
else:
if field is not None:
raise RuntimeError("This feature requires GPaste.")
result = subprocess.run(base_args + ["-c", name])
if result.returncode:
raise RuntimeError(
@ -191,17 +234,21 @@ class SearchPassService(dbus.service.Object):
)
def send_password_to_clipboard(self, name):
field = None
if self.password_mode == "bw":
base_args = [self.password_executable, "get"]
elif name.startswith("otp "):
base_args = [self.password_executable, "otp", "code"]
name = name[4:]
else:
base_args = [self.password_executable, "show"]
if name.startswith(":"):
field, name = name.split(" ", 1)
field = field[1:]
else:
field = None
if self.password_mode == "bw":
base_args = [self.password_executable, "get", "--full"]
elif name.startswith("otp "):
base_args = [self.password_executable, "otp", "code"]
name = name[4:]
field = None
else:
base_args = [self.password_executable, "show"]
try:
try:
self.send_password_to_gpaste(base_args, name, field)
@ -220,6 +267,8 @@ class SearchPassService(dbus.service.Object):
self.notify("Failed to copy password or field!", body=str(e), error=True)
def notify(self, message, body="", error=False):
if not error and self.disable_notifications:
return
try:
self.session_bus.get_object(
"org.freedesktop.Notifications", "/org/freedesktop/Notifications"

View File

@ -1,25 +1,23 @@
Name: gnome-pass-search-provider
Version: master
Release: 1
License: GPL-3.0+
Version: 1.3.3
Release: %autorelease
Summary: Gnome Shell search provider for zx2c4/pass
Url: https://github.com/jle64/gnome-pass-search-provider
Source: https://github.com/jle64/%{name}/archive/master.tar.gz
License: GPL-3.0+
Url: https://git.dm1sh.ru/dm1sh/%{name}
Source0: https://git.dm1sh.ru/dm1sh/%{name}/archive/%{version}.tar.gz
Requires: gnome-shell
Requires: pass
Requires: (pass or gopass)
Requires: python3-gobject
Requires: python3-dbus
Requires: python3-fuzzywuzzy
Requires: python3-Levenshtein
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%global debug_package %{nil}
%description
A Gnome Shell passwords search provider for zx2c4/pass (passwordstore.org) or compatibles and Bitwarden/Vaultwarden that sends passwords to clipboard (or GPaste).
%prep
%setup -q -n %{name}-%{version}
%autosetup -n %{name}
%define debug_package %{nil}
%build
@ -29,10 +27,13 @@ sed -i -e 's|LIBDIR=|LIBDIR=$RPM_BUILD_ROOT|' install.sh
./install.sh
%files
%defattr(-,root,root,-)
%doc README.md
%license LICENSE
%{_prefix}/lib/gnome-pass-search-provider/gnome-pass-search-provider.py
%{_prefix}/lib/systemd/user/org.gnome.Pass.SearchProvider.service
%{_prefix}/share/dbus-1/services/org.gnome.Pass.SearchProvider.service
%{_prefix}/share/applications/org.gnome.Pass.SearchProvider.desktop
%{_prefix}/share/gnome-shell/search-providers/org.gnome.Pass.SearchProvider.ini
%changelog
%autochangelog