From 76469969f399b8ba97f636652ba8112523a6f787 Mon Sep 17 00:00:00 2001 From: Jakub Date: Thu, 28 Jul 2022 12:35:03 +0200 Subject: [PATCH 1/6] GODT-1741: GUI and CLI settings to change visibility of All Mail folder. --- internal/frontend/cli/frontend.go | 17 +++++++++++++++ internal/frontend/cli/system.go | 26 +++++++++++++++++++++++ internal/frontend/qml/Bridge_test.qml | 11 ++++++++++ internal/frontend/qml/GeneralSettings.qml | 13 ++++++++++++ internal/frontend/qt/qml_backend.go | 10 +++++++++ internal/frontend/types/types.go | 2 ++ 6 files changed, 79 insertions(+) diff --git a/internal/frontend/cli/frontend.go b/internal/frontend/cli/frontend.go index badad56..7cb5abf 100644 --- a/internal/frontend/cli/frontend.go +++ b/internal/frontend/cli/frontend.go @@ -137,6 +137,23 @@ func New( //nolint:funlen }) fe.AddCmd(dohCmd) + // All mail visibility commands. + allMailCmd := &ishell.Cmd{ + Name: "all-mail-visibility", + Help: "choose not to list the All Mail folder in your local client", + } + allMailCmd.AddCmd(&ishell.Cmd{ + Name: "disable", + Help: "All Mail folder will not be listed in your local client", + Func: fe.disableAllMail, + }) + allMailCmd.AddCmd(&ishell.Cmd{ + Name: "enable", + Help: "All Mail folder will be listed in your local client", + Func: fe.enableAllMail, + }) + fe.AddCmd(allMailCmd) + // Cache-On-Disk commands. codCmd := &ishell.Cmd{ Name: "local-cache", diff --git a/internal/frontend/cli/system.go b/internal/frontend/cli/system.go index 9ada04c..273a9e9 100644 --- a/internal/frontend/cli/system.go +++ b/internal/frontend/cli/system.go @@ -152,6 +152,32 @@ func (f *frontendCLI) disallowProxy(c *ishell.Context) { } } +func (f *frontendCLI) disableAllMail(c *ishell.Context) { + if !f.bridge.IsAllMailVisible() { + f.Println("All Mail folder is not listed in your local client.") + return + } + + f.Println("All Mail folder is listed in your client right now.") + + if f.yesNoQuestion("Do you want to hide All Mail folder") { + f.bridge.SetIsAllMailVisible(false) + } +} + +func (f *frontendCLI) enableAllMail(c *ishell.Context) { + if f.bridge.IsAllMailVisible() { + f.Println("All Mail folder is listed in your local client.") + return + } + + f.Println("All Mail folder is not listed in your client right now.") + + if f.yesNoQuestion("Do you want to show All Mail folder") { + f.bridge.SetIsAllMailVisible(true) + } +} + func (f *frontendCLI) enableCacheOnDisk(c *ishell.Context) { if f.settings.GetBool(settings.CacheEnabledKey) { f.Println("The local cache is already enabled.") diff --git a/internal/frontend/qml/Bridge_test.qml b/internal/frontend/qml/Bridge_test.qml index d741139..72f3c95 100644 --- a/internal/frontend/qml/Bridge_test.qml +++ b/internal/frontend/qml/Bridge_test.qml @@ -672,6 +672,10 @@ Window { Label {colorScheme: root.colorScheme; text: "DoH:"} Toggle {colorScheme: root.colorScheme; checked: root.isDoHEnabled; onClicked: root.isDoHEnabled = !root.isDoHEnabled} } + RowLayout { + Label {colorScheme: root.colorScheme; text: "All Mail disabled:"} + Toggle {colorScheme: root.colorScheme; checked: root.isAllMailDisabled; onClicked: root.isAllMailDisabled = !root.isAllMailDisabled} + } RowLayout { Label {colorScheme: root.colorScheme; text: "Ports:"} TextField { @@ -811,6 +815,13 @@ Window { root.isDoHEnabled = makeItActive } + property bool isAllMailDisabled : false + function changeIsAllMailDisabled(isDisabled){ + console.debug("-> All Mail Disabled", isDisabled, root.isAllMailDisabled) + root.isAllMailDisabled = isDisabled + } + + property bool useSSLforSMTP: false function toggleUseSSLforSMTP(makeItActive){ console.debug("-> SMTP SSL", makeItActive, root.useSSLforSMTP) diff --git a/internal/frontend/qml/GeneralSettings.qml b/internal/frontend/qml/GeneralSettings.qml index fbd5377..fb370ab 100644 --- a/internal/frontend/qml/GeneralSettings.qml +++ b/internal/frontend/qml/GeneralSettings.qml @@ -156,6 +156,19 @@ SettingsView { Layout.fillWidth: true } + SettingsItem { + id: allMail + visible: root._isAdvancedShown + colorScheme: root.colorScheme + text: qsTr("Disable All Mail") + description: qsTr("Choose not to list the All Mail folder in your local client.") + type: SettingsItem.Toggle + checked: root.backend.isAllMailDisabled + onClicked: root.backend.changeIsAllMailDisabled(!allMail.checked ) + + Layout.fillWidth: true + } + SettingsItem { id: ports visible: root._isAdvancedShown diff --git a/internal/frontend/qt/qml_backend.go b/internal/frontend/qt/qml_backend.go index 6701b7e..d0db4fe 100644 --- a/internal/frontend/qt/qml_backend.go +++ b/internal/frontend/qt/qml_backend.go @@ -155,6 +155,9 @@ type QMLBackend struct { _ func() `signal:apiCertIssue` _ func(userID string) `signal:userChanged` + + _ bool `property:"isAllMailDisabled"` + _ func(isDisabled bool) `slot:"changeIsAllMailDisabled"` } func (q *QMLBackend) setup(f *FrontendQt) { @@ -304,4 +307,11 @@ func (q *QMLBackend) setup(f *FrontendQt) { f.changeKeychain(k) }() }) + + q.SetIsAllMailDisabled(!f.bridge.IsAllMailVisible()) + q.ConnectChangeIsAllMailDisabled(func(isDisabled bool) { + f.bridge.SetIsAllMailVisible(!isDisabled) + f.qml.SetIsAllMailDisabled(isDisabled) + }) + } diff --git a/internal/frontend/types/types.go b/internal/frontend/types/types.go index 0a125ac..88051a3 100644 --- a/internal/frontend/types/types.go +++ b/internal/frontend/types/types.go @@ -92,6 +92,8 @@ type Bridger interface { DisableAutostart() error GetLastVersion() string IsFirstStart() bool + IsAllMailVisible() bool + SetIsAllMailVisible(bool) } type bridgeWrap struct { From a93ed35eee44227b7a005ad39bc95a280d80cf8b Mon Sep 17 00:00:00 2001 From: Jakub Date: Fri, 26 Aug 2022 15:01:18 +0200 Subject: [PATCH 2/6] GODT-1794: Add confirmation dialog and change wording --- internal/frontend/qml/Bridge_test.qml | 10 ++--- internal/frontend/qml/GeneralSettings.qml | 8 ++-- internal/frontend/qml/NotificationPopups.qml | 5 +++ .../qml/Notifications/Notifications.qml | 43 +++++++++++++++++++ internal/frontend/qt/qml_backend.go | 12 +++--- 5 files changed, 63 insertions(+), 15 deletions(-) diff --git a/internal/frontend/qml/Bridge_test.qml b/internal/frontend/qml/Bridge_test.qml index 72f3c95..35442b4 100644 --- a/internal/frontend/qml/Bridge_test.qml +++ b/internal/frontend/qml/Bridge_test.qml @@ -674,7 +674,7 @@ Window { } RowLayout { Label {colorScheme: root.colorScheme; text: "All Mail disabled:"} - Toggle {colorScheme: root.colorScheme; checked: root.isAllMailDisabled; onClicked: root.isAllMailDisabled = !root.isAllMailDisabled} + Toggle {colorScheme: root.colorScheme; checked: root.isAllMailVisible; onClicked: root.isAllMailVisible = !root.isAllMailVisible} } RowLayout { Label {colorScheme: root.colorScheme; text: "Ports:"} @@ -815,10 +815,10 @@ Window { root.isDoHEnabled = makeItActive } - property bool isAllMailDisabled : false - function changeIsAllMailDisabled(isDisabled){ - console.debug("-> All Mail Disabled", isDisabled, root.isAllMailDisabled) - root.isAllMailDisabled = isDisabled + property bool isAllMailVisible : true + function changeIsAllMailVisible(isVisible){ + console.debug("-> All Mail Visible", isVisible, root.isAllMailVisible) + root.isAllMailVisible = isVisible } diff --git a/internal/frontend/qml/GeneralSettings.qml b/internal/frontend/qml/GeneralSettings.qml index fb370ab..b0ea78d 100644 --- a/internal/frontend/qml/GeneralSettings.qml +++ b/internal/frontend/qml/GeneralSettings.qml @@ -160,11 +160,11 @@ SettingsView { id: allMail visible: root._isAdvancedShown colorScheme: root.colorScheme - text: qsTr("Disable All Mail") - description: qsTr("Choose not to list the All Mail folder in your local client.") + text: qsTr("Show All Mail") + description: qsTr("Choose to list the All Mail folder in your local client.") type: SettingsItem.Toggle - checked: root.backend.isAllMailDisabled - onClicked: root.backend.changeIsAllMailDisabled(!allMail.checked ) + checked: root.backend.isAllMailVisible + onClicked: root.notifications.askChangeAllMailVisibility(root.backend.isAllMailVisible) Layout.fillWidth: true } diff --git a/internal/frontend/qml/NotificationPopups.qml b/internal/frontend/qml/NotificationPopups.qml index 4c89a97..211ce85 100644 --- a/internal/frontend/qml/NotificationPopups.qml +++ b/internal/frontend/qml/NotificationPopups.qml @@ -110,6 +110,11 @@ Item { notification: root.notifications.resetBridge } + NotificationDialog { + colorScheme: root.colorScheme + notification: root.notifications.changeAllMailVisibility + } + NotificationDialog { colorScheme: root.colorScheme notification: root.notifications.deleteAccount diff --git a/internal/frontend/qml/Notifications/Notifications.qml b/internal/frontend/qml/Notifications/Notifications.qml index 980f9f1..32370fa 100644 --- a/internal/frontend/qml/Notifications/Notifications.qml +++ b/internal/frontend/qml/Notifications/Notifications.qml @@ -34,6 +34,7 @@ QtObject { signal askDisableLocalCache() signal askEnableLocalCache(var path) signal askResetBridge() + signal askChangeAllMailVisibility(var isVisibleNow) signal askDeleteAccount(var user) enum Group { @@ -72,6 +73,7 @@ QtObject { root.disableLocalCache, root.enableLocalCache, root.resetBridge, + root.changeAllMailVisibility, root.deleteAccount, root.noKeychain, root.rebuildKeychain, @@ -840,6 +842,47 @@ QtObject { ] } + property Notification changeAllMailVisibility: Notification { + title: root.changeAllMailVisibility.isVisibleNow ? + qsTr("Hide All Mail folder?") : + qsTr("Show All Mail folder?") + brief: title + icon: "./icons/ic-info-circle-filled.svg" + description: qsTr("Switching between showing and hiding the All Mail folder will require you to restart your client.") + type: Notification.NotificationType.Info + group: Notifications.Group.Configuration | Notifications.Group.Dialogs + + property var isVisibleNow + + Connections { + target: root + onAskChangeAllMailVisibility: { + root.changeAllMailVisibility.isVisibleNow = isVisibleNow + root.changeAllMailVisibility.active = true + } + } + + action: [ + Action { + id: allMail_change + text: root.changeAllMailVisibility.isVisibleNow ? + qsTr("Hide All Mail folder") : + qsTr("Show All Mail folder") + onTriggered: { + root.backend.changeIsAllMailVisible(!root.changeAllMailVisibility.isVisibleNow) + root.changeAllMailVisibility.active = false + } + }, + Action { + id: allMail_cancel + text: qsTr("Cancel") + onTriggered: { + root.changeAllMailVisibility.active = false + } + } + ] + } + property Notification deleteAccount: Notification { title: qsTr("Remove this account?") brief: title diff --git a/internal/frontend/qt/qml_backend.go b/internal/frontend/qt/qml_backend.go index d0db4fe..04d38be 100644 --- a/internal/frontend/qt/qml_backend.go +++ b/internal/frontend/qt/qml_backend.go @@ -156,8 +156,8 @@ type QMLBackend struct { _ func(userID string) `signal:userChanged` - _ bool `property:"isAllMailDisabled"` - _ func(isDisabled bool) `slot:"changeIsAllMailDisabled"` + _ bool `property:"isAllMailVisible"` + _ func(isDisabled bool) `slot:"changeIsAllMailVisible"` } func (q *QMLBackend) setup(f *FrontendQt) { @@ -308,10 +308,10 @@ func (q *QMLBackend) setup(f *FrontendQt) { }() }) - q.SetIsAllMailDisabled(!f.bridge.IsAllMailVisible()) - q.ConnectChangeIsAllMailDisabled(func(isDisabled bool) { - f.bridge.SetIsAllMailVisible(!isDisabled) - f.qml.SetIsAllMailDisabled(isDisabled) + q.SetIsAllMailVisible(f.bridge.IsAllMailVisible()) + q.ConnectChangeIsAllMailVisible(func(isVisible bool) { + f.bridge.SetIsAllMailVisible(isVisible) + f.qml.SetIsAllMailVisible(isVisible) }) } From 5b941013dea832f206ac2a4ea7038bddb0355a80 Mon Sep 17 00:00:00 2001 From: Jakub Date: Fri, 26 Aug 2022 16:42:57 +0200 Subject: [PATCH 3/6] Other: Update SSL certificate fingerprint for test --- pkg/pmapi/dialer_pinning_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/pmapi/dialer_pinning_test.go b/pkg/pmapi/dialer_pinning_test.go index 16ed95b..9ca033a 100644 --- a/pkg/pmapi/dialer_pinning_test.go +++ b/pkg/pmapi/dialer_pinning_test.go @@ -88,7 +88,7 @@ func TestTLSSignedCertTrustedPublicKey(t *testing.T) { _, dialer, _ := createClientWithPinningDialer("") copyTrustedPins(dialer.pinChecker) - dialer.pinChecker.trustedPins = append(dialer.pinChecker.trustedPins, `pin-sha256="2opdB7b5INED5jS7duIDR7dM8Er99i7trnwKuW3GMCY="`) + dialer.pinChecker.trustedPins = append(dialer.pinChecker.trustedPins, `pin-sha256="SA4v9d2YY4vX5YQOQ1qZHYTBMCTSD/sxPvyj+JL6+vI="`) _, err := dialer.DialTLS("tcp", "rsa4096.badssl.com:443") r.NoError(t, err, "expected dial to succeed because public key is known and cert is signed by CA") } From 1ec05e8a6c8067b6db5cd15eee77174994986740 Mon Sep 17 00:00:00 2001 From: Jakub Date: Fri, 26 Aug 2022 16:49:58 +0200 Subject: [PATCH 4/6] GODT-1794: CLI wording --- internal/frontend/cli/frontend.go | 8 ++++---- internal/frontend/cli/system.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/frontend/cli/frontend.go b/internal/frontend/cli/frontend.go index 7cb5abf..1105da9 100644 --- a/internal/frontend/cli/frontend.go +++ b/internal/frontend/cli/frontend.go @@ -143,14 +143,14 @@ func New( //nolint:funlen Help: "choose not to list the All Mail folder in your local client", } allMailCmd.AddCmd(&ishell.Cmd{ - Name: "disable", + Name: "hide", Help: "All Mail folder will not be listed in your local client", - Func: fe.disableAllMail, + Func: fe.hideAllMail, }) allMailCmd.AddCmd(&ishell.Cmd{ - Name: "enable", + Name: "show", Help: "All Mail folder will be listed in your local client", - Func: fe.enableAllMail, + Func: fe.showAllMail, }) fe.AddCmd(allMailCmd) diff --git a/internal/frontend/cli/system.go b/internal/frontend/cli/system.go index 273a9e9..a25b994 100644 --- a/internal/frontend/cli/system.go +++ b/internal/frontend/cli/system.go @@ -152,7 +152,7 @@ func (f *frontendCLI) disallowProxy(c *ishell.Context) { } } -func (f *frontendCLI) disableAllMail(c *ishell.Context) { +func (f *frontendCLI) hideAllMail(c *ishell.Context) { if !f.bridge.IsAllMailVisible() { f.Println("All Mail folder is not listed in your local client.") return @@ -165,7 +165,7 @@ func (f *frontendCLI) disableAllMail(c *ishell.Context) { } } -func (f *frontendCLI) enableAllMail(c *ishell.Context) { +func (f *frontendCLI) showAllMail(c *ishell.Context) { if f.bridge.IsAllMailVisible() { f.Println("All Mail folder is listed in your local client.") return From d421b5aa5ab82af93f38c112b1e05936dae5dfe1 Mon Sep 17 00:00:00 2001 From: Jakub Date: Mon, 29 Aug 2022 13:36:08 +0200 Subject: [PATCH 5/6] GODT-1833: Fix gobinsec cache. --- .gitlab-ci.yml | 6 ++++-- Makefile | 2 +- internal/api/api.go | 6 ++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4a9d080..b8e7426 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -108,7 +108,8 @@ test-integration: dependency-updates: stage: test script: - - make updates + - "echo 'NOTE: Do not run on go1.15 ( 'if...' can be removed once fully updated to go1.18)'" + - if [ 18 -le $(go version | cut -d. -f2 | cut -d " " -f1) ]; then make updates; fi # Stage: BUILD @@ -246,10 +247,11 @@ check-gobinsec: before_script: - mkdir build - tar -xzf bridge_linux_*.tgz -C build + - "echo api-key: \"${GOBINSEC_NVD_API_KEY}\" >> utils/gobinsec_conf.yml" script: - "[ ! -f ./gobinsec-cache.yml ] && wget bridgeteam.protontech.ch/bridgeteam/gobinsec-cache.yml" - cat ./gobinsec-cache.yml - - gobinsec -cache -config utils/gobinsec_conf.yml build/proton-bridge + - gobinsec -wait -cache -config utils/gobinsec_conf.yml build/proton-bridge diff --git a/Makefile b/Makefile index 289b0c6..2a21999 100644 --- a/Makefile +++ b/Makefile @@ -166,7 +166,7 @@ update-qt-docs: LINTVER:="v1.39.0" LINTSRC:="https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh" -install-dev-dependencies: install-devel-tools install-linter install-go-mod-outdated +install-dev-dependencies: install-devel-tools install-linter install-devel-tools: check-has-go go get -v github.com/golang/mock/gomock diff --git a/internal/api/api.go b/internal/api/api.go index 1a64a02..1d17a20 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -24,6 +24,7 @@ package api import ( "fmt" "net/http" + "time" "github.com/ProtonMail/proton-bridge/v2/internal/bridge" "github.com/ProtonMail/proton-bridge/v2/internal/config/settings" @@ -57,8 +58,9 @@ func (api *apiServer) ListenAndServe() { addr := api.getAddress() server := &http.Server{ - Addr: addr, - Handler: mux, + Addr: addr, + Handler: mux, + ReadHeaderTimeout: 5 * time.Second, // fix gosec G112 (vulnerability to [Slowloris](https://www.cloudflare.com/en-gb/learning/ddos/ddos-attack-tools/slowloris/) attack). } log.Info("API listening at ", addr) From bdb35f1c1dd4b67f0b2ef5be1a46076022543733 Mon Sep 17 00:00:00 2001 From: Romain LE JEUNE Date: Wed, 24 Aug 2022 15:53:30 +0200 Subject: [PATCH 6/6] GODT-1799: fix dependency link [skip-ci] --- internal/locations/locations.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/locations/locations.go b/internal/locations/locations.go index 70d54f0..61b6141 100644 --- a/internal/locations/locations.go +++ b/internal/locations/locations.go @@ -107,7 +107,7 @@ func (l *Locations) getLicenseFilePath() string { // GetDependencyLicensesLink returns link to page listing dependencies. func (l *Locations) GetDependencyLicensesLink() string { - return "https://github.com/ProtonMail/proton-bridge/v2/blob/master/COPYING_NOTES.md#dependencies" + return "https://github.com/ProtonMail/proton-bridge/blob/master/COPYING_NOTES.md#dependencies" } // ProvideSettingsPath returns a location for user settings (e.g. ~/.config//).