File: Revert-Add-Audit-feature.patch

package info (click to toggle)
secrets 12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,616 kB
  • sloc: python: 6,838; xml: 7; makefile: 4
file content (264 lines) | stat: -rw-r--r-- 10,034 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
From: =?utf-8?q?Jeremy_B=C3=ADcha?= <jbicha@debian.org>
Date: Thu, 6 Nov 2025 13:38:35 -0500
Subject: Revert "Add Audit feature"

This reverts commit d084c625ed1d41cd394c6f4f52c7406a75c7c130.

This requires python3-pyhibp which is not yet in Debian
---
 data/gtk/database_settings_dialog.ui         |  70 --------------
 gsecrets/widgets/database_settings_dialog.py | 138 ---------------------------
 2 files changed, 208 deletions(-)

diff --git a/data/gtk/database_settings_dialog.ui b/data/gtk/database_settings_dialog.ui
index 9d407d5..ed45fb5 100644
--- a/data/gtk/database_settings_dialog.ui
+++ b/data/gtk/database_settings_dialog.ui
@@ -212,75 +212,5 @@
         </child>
       </object>
     </child>
-    <child>
-      <object class="AdwPreferencesPage">
-        <property name="name">report_page</property>
-        <property name="title" translatable="yes">Audit</property>
-        <property name="icon_name">find-location-symbolic</property>
-        <child>
-          <object class="AdwPreferencesGroup" id="statistic_group">
-            <property name="title" translatable="yes">Statistics</property>
-            <child>
-              <object class="AdwActionRow" id="unique_passwords_row">
-                <property name="title" translatable="yes">Unique Passwords</property>
-                <style>
-                  <class name="property"/>
-                  <class name="numeric"/>
-                </style>
-              </object>
-            </child>
-            <child>
-              <object class="AdwActionRow" id="reused_passwords_row">
-                <property name="title" translatable="yes">Reused Passwords</property>
-                <style>
-                  <class name="property"/>
-                  <class name="numeric"/>
-                </style>
-              </object>
-            </child>
-          </object>
-        </child>
-        <child>
-          <object class="AdwPreferencesGroup" id="weak_password_group">
-            <property name="title" translatable="yes">Weak Passwords</property>
-          </object>
-        </child>
-        <child>
-          <object class="AdwPreferencesGroup" id="hibp_group">
-            <property name="title" translatable="yes">Check passwords for online breaches</property>
-            <property name="description" translatable="yes">Ask online whether your passwords have been hacked. The passwords won't be sent online! The following passwords have been leaked:</property>
-            <property name="header-suffix">
-              <object class="GtkStack" id="hibp_stack">
-                <child>
-                  <object class="GtkStackPage">
-                    <property name="name">button</property>
-                    <property name="child">
-                      <object class="GtkButton" id="hibp_refresh_button">
-                        <property name="icon-name">view-refresh-symbolic</property>
-                        <property name="valign">center</property>
-                        <signal name="clicked" handler="on_hibp_refresh_clicked"/>
-                        <style>
-                          <class name="flat"/>
-                        </style>
-                      </object>
-                    </property>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkStackPage">
-                    <property name="name">spinner</property>
-                    <property name="child">
-                      <object class="AdwSpinner" id="hibp_spinner">
-                        <property name="valign">center</property>
-                      </object>
-                    </property>
-                  </object>
-                </child>
-              </object>
-             </property>
-          </object>
-        </child>
-      </object>
-    </child>
   </template>
 </interface>
diff --git a/gsecrets/widgets/database_settings_dialog.py b/gsecrets/widgets/database_settings_dialog.py
index 6e1a813..b81a994 100644
--- a/gsecrets/widgets/database_settings_dialog.py
+++ b/gsecrets/widgets/database_settings_dialog.py
@@ -7,12 +7,8 @@ import typing
 from gettext import gettext as _
 from pathlib import Path, PurePath
 
-import pyhibp
-import requests
 from gi.repository import Adw, Gio, GLib, GObject, Gtk
-from pyhibp import pwnedpasswords as pw
 
-from gsecrets.password_generator import strength
 from gsecrets.utils import (
     compare_passwords,
     format_time,
@@ -23,10 +19,6 @@ if typing.TYPE_CHECKING:
     from gsecrets.provider.base_provider import BaseProvider
 
 
-WEAK = 0.5
-MEDIUM = 1.5
-
-
 @Gtk.Template(resource_path="/org/gnome/World/Secrets/gtk/database_settings_dialog.ui")
 class DatabaseSettingsDialog(Adw.PreferencesDialog):
     # pylint: disable=too-many-instance-attributes
@@ -62,13 +54,6 @@ class DatabaseSettingsDialog(Adw.PreferencesDialog):
     current_password_entry = Gtk.Template.Child()
     provider_group = Gtk.Template.Child()
     banner = Gtk.Template.Child()
-    unique_passwords_row = Gtk.Template.Child()
-    reused_passwords_row = Gtk.Template.Child()
-    weak_password_group = Gtk.Template.Child()
-    hibp_group = Gtk.Template.Child()
-    hibp_stack = Gtk.Template.Child()
-    hibp_spinner = Gtk.Template.Child()
-    hibp_refresh_button = Gtk.Template.Child()
 
     confirm_password_entry = Gtk.Template.Child()
     new_password_entry = Gtk.Template.Child()
@@ -103,129 +88,6 @@ class DatabaseSettingsDialog(Adw.PreferencesDialog):
                 self.signals.append((show_id, key_provider))
                 self.signals.append((hide_id, key_provider))
 
-        self._fill_audit()
-
-    def _fill_audit(self):
-        passwords = []
-        weak_passwords_found = False
-
-        for entry in self.database_manager.db.find_entries():
-            if entry.password:
-                passwords.append(entry.password)
-
-                pwd_strength = strength(entry.password)
-                if pwd_strength < MEDIUM:
-                    weak_passwords_found = True
-
-                    row = Adw.ActionRow()
-                    if entry.title:
-                        row.set_title(entry.title)
-                    if entry.username:
-                        row.set_subtitle(entry.username)
-
-                    score = Gtk.Label()
-                    if pwd_strength < WEAK:
-                        score.set_label(_("Insecure"))
-                    else:
-                        score.set_label(_("Weak"))
-
-                    row.add_suffix(score)
-                    self.weak_password_group.add(row)
-
-        if not weak_passwords_found:
-            row = Adw.ActionRow()
-            row.set_title(_("No weak passwords found"))
-            self.weak_password_group.add(row)
-
-        # Statistics
-        reused_dict = {
-            pwd: passwords.count(pwd) for pwd in passwords if passwords.count(pwd) > 1
-        }
-        self.reused_passwords_row.set_subtitle(str(len(reused_dict)))
-
-        unique_dict = {
-            pwd: passwords.count(pwd) for pwd in passwords if passwords.count(pwd) == 1
-        }
-        self.unique_passwords_row.set_subtitle(str(len(unique_dict)))
-
-        thread = threading.Thread(target=self.check_network_access)
-        thread.daemon = True
-        thread.start()
-
-        self.hibp_stack.set_visible_child_name("button")
-
-    def check_network_access(self):
-        reachable = True
-        status_code_ok = True
-
-        try:
-            check_url = requests.get("https://haveibeenpwned.com/", timeout=3)
-        except requests.exceptions.RequestException:
-            reachable = False
-        else:
-            status_code_ok = check_url.status_code == requests.codes.ok
-
-        GLib.idle_add(self.update_hibp_ui, reachable, status_code_ok)
-
-    def update_hibp_ui(self, reachable, status_code_ok):
-        if not reachable:
-            self.hibp_refresh_button.set_sensitive(False)
-
-            row = Adw.ActionRow()
-            row.set_title("No Network Access Configured")
-            row.set_subtitle("Add --share=network to your Flatpak manifest")
-            self.hibp_group.add(row)
-            return
-
-        self.hibp_refresh_button.set_sensitive(status_code_ok)
-
-    @Gtk.Template.Callback()
-    def on_hibp_refresh_clicked(self, _entry: Gtk.Entry) -> None:
-        self.hibp_stack.set_visible_child_name("spinner")
-        self._hibp_refresh_async(self._on_hibp_refresh)
-
-    def _hibp_refresh_async(self, callback: Gio.AsyncReadyCallback) -> None:
-        def lookup(task, _source_object, _task_data, _cancellable):
-            rows = []
-
-            for entry in self.database_manager.db.find_entries():
-                pyhibp.set_user_agent(ua="Secrets")
-                if entry.password:
-                    resp = pw.is_password_breached(password=entry.password)
-                    if resp:
-                        row = Adw.ActionRow()
-                        if title := entry.title:
-                            row.set_title(title)
-
-                        if username := entry.username:
-                            row.set_subtitle(username)
-
-                        rows.append(row)
-
-            task.return_value(rows)
-
-        task = Gio.Task.new(self, None, callback)
-        task.run_in_thread(lookup)
-
-    def _hibp_refresh_finish(self, result):
-        return result.propagate_value()
-
-    def _on_hibp_refresh(
-        self,
-        _dialog: DatabaseSettingsDialog,
-        result: Gio.AsyncResult,
-    ) -> None:
-        self.hibp_stack.set_visible(False)
-        _success, rows = self._hibp_refresh_finish(result)
-
-        if rows:
-            for row in rows:
-                self.hibp_group.add(row)
-        else:
-            row = Adw.ActionRow()
-            row.set_title(_("No records found"))
-            self.hibp_group.add(row)
-
     def do_closed(self):
         for signal_id, obj in self.signals:
             obj.disconnect(signal_id)