[epiphany/mcatanzaro/#1721: 1/2] Disable all Safe Browsing code at build time




commit ebcf7dbe751de8b4f455c266e40d5f64d8966172
Author: Michael Catanzaro <mcatanzaro redhat com>
Date:   Tue Mar 22 16:18:19 2022 -0500

    Disable all Safe Browsing code at build time
    
    Currently we have a runtime check to disable creation of the
    EphyGSBService if the API key is not provided at build time. I think
    that is sufficient, but since this code should be unusable if API key is
    not provided, let's not build it at all for some extra assurance that it
    won't run.
    
    Related: #1721

 embed/ephy-embed-shell.c             | 6 ++++++
 embed/ephy-embed-shell.h             | 2 ++
 embed/ephy-web-view.c                | 4 ++++
 lib/safe-browsing/ephy-gsb-service.c | 8 ++++----
 lib/safe-browsing/ephy-gsb-service.h | 4 ++++
 lib/safe-browsing/ephy-gsb-storage.c | 4 ++++
 lib/safe-browsing/ephy-gsb-storage.h | 4 ++++
 lib/safe-browsing/ephy-gsb-utils.c   | 4 ++++
 lib/safe-browsing/ephy-gsb-utils.h   | 4 ++++
 src/ephy-window.c                    | 4 ++++
 10 files changed, 40 insertions(+), 4 deletions(-)
---
diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c
index 99d1fb0ef..ede477261 100644
--- a/embed/ephy-embed-shell.c
+++ b/embed/ephy-embed-shell.c
@@ -55,7 +55,9 @@
 typedef struct {
   WebKitWebContext *web_context;
   EphyHistoryService *global_history_service;
+#if ENABLE_GSB
   EphyGSBService *global_gsb_service;
+#endif
   EphyEncodings *encodings;
   GtkPageSetup *page_setup;
   GtkPrintSettings *print_settings;
@@ -192,7 +194,9 @@ ephy_embed_shell_dispose (GObject *object)
   g_clear_object (&priv->page_setup);
   g_clear_object (&priv->print_settings);
   g_clear_object (&priv->global_history_service);
+#if ENABLE_GSB
   g_clear_object (&priv->global_gsb_service);
+#endif
   g_clear_object (&priv->about_handler);
   g_clear_object (&priv->reader_handler);
   g_clear_object (&priv->source_handler);
@@ -637,6 +641,7 @@ ephy_embed_shell_get_global_history_service (EphyEmbedShell *shell)
   return priv->global_history_service;
 }
 
+#if ENABLE_GSB
 /**
  * ephy_embed_shell_get_global_gsb_service:
  * @shell: the #EphyEmbedShell
@@ -660,6 +665,7 @@ ephy_embed_shell_get_global_gsb_service (EphyEmbedShell *shell)
 
   return priv->global_gsb_service;
 }
+#endif
 
 /**
  * ephy_embed_shell_get_encodings:
diff --git a/embed/ephy-embed-shell.h b/embed/ephy-embed-shell.h
index 9464d42d4..9abbab0fd 100644
--- a/embed/ephy-embed-shell.h
+++ b/embed/ephy-embed-shell.h
@@ -64,7 +64,9 @@ const char        *ephy_embed_shell_get_guid                   (EphyEmbedShell
 WebKitWebContext  *ephy_embed_shell_get_web_context            (EphyEmbedShell   *shell);
 EphyHistoryService
                   *ephy_embed_shell_get_global_history_service (EphyEmbedShell   *shell);
+#if ENABLE_GSB
 EphyGSBService    *ephy_embed_shell_get_global_gsb_service     (EphyEmbedShell   *shell);
+#endif
 EphyEncodings     *ephy_embed_shell_get_encodings              (EphyEmbedShell   *shell);
 void               ephy_embed_shell_restored_window            (EphyEmbedShell   *shell);
 void               ephy_embed_shell_set_page_setup             (EphyEmbedShell   *shell,
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index d8521a012..f27948961 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -2098,6 +2098,7 @@ format_tls_error_page (EphyWebView  *view,
   *style = "danger";
 }
 
+#if ENABLE_GSB
 static void
 format_unsafe_browsing_error_page (EphyWebView  *view,
                                    const char   *origin,
@@ -2185,6 +2186,7 @@ format_unsafe_browsing_error_page (EphyWebView  *view,
   *icon_name = "security-high-symbolic.svg";
   *style = "danger";
 }
+#endif
 
 static void
 format_no_such_file_error_page (EphyWebView  *view,
@@ -2355,6 +2357,7 @@ ephy_web_view_load_error_page (EphyWebView          *view,
                              &icon_name,
                              &style);
       break;
+#if ENABLE_GSB
     case EPHY_WEB_VIEW_ERROR_UNSAFE_BROWSING:
       format_unsafe_browsing_error_page (view,
                                          origin,
@@ -2372,6 +2375,7 @@ ephy_web_view_load_error_page (EphyWebView          *view,
                                          &icon_name,
                                          &style);
       break;
+#endif
     case EPHY_WEB_VIEW_ERROR_NO_SUCH_FILE:
       format_no_such_file_error_page (view,
                                       &page_title,
diff --git a/lib/safe-browsing/ephy-gsb-service.c b/lib/safe-browsing/ephy-gsb-service.c
index 97086038f..3b62b50fb 100644
--- a/lib/safe-browsing/ephy-gsb-service.c
+++ b/lib/safe-browsing/ephy-gsb-service.c
@@ -21,6 +21,8 @@
 #include "config.h"
 #include "ephy-gsb-service.h"
 
+#if ENABLE_GSB
+
 #include "ephy-debug.h"
 #include "ephy-gsb-storage.h"
 #include "ephy-user-agent.h"
@@ -536,7 +538,6 @@ EphyGSBService *
 ephy_gsb_service_new (const char *api_key,
                       const char *db_path)
 {
-#if ENABLE_GSB
   EphyGSBService *service;
   EphyGSBStorage *storage;
 
@@ -548,9 +549,6 @@ ephy_gsb_service_new (const char *api_key,
   g_object_unref (storage);
 
   return service;
-#else
-  return NULL;
-#endif
 }
 
 typedef struct {
@@ -888,3 +886,5 @@ ephy_gsb_service_verify_url_finish (EphyGSBService *self,
 
   return g_task_propagate_pointer (G_TASK (result), NULL);
 }
+
+#endif /* ENABLE_GSB */
diff --git a/lib/safe-browsing/ephy-gsb-service.h b/lib/safe-browsing/ephy-gsb-service.h
index decb73a51..662732d02 100644
--- a/lib/safe-browsing/ephy-gsb-service.h
+++ b/lib/safe-browsing/ephy-gsb-service.h
@@ -20,6 +20,8 @@
 
 #pragma once
 
+#if ENABLE_GSB
+
 #include <gio/gio.h>
 #include <glib-object.h>
 
@@ -39,3 +41,5 @@ GList          *ephy_gsb_service_verify_url_finish  (EphyGSBService  *self,
                                                      GAsyncResult    *result);
 
 G_END_DECLS
+
+#endif /* ENABLE_GSB */
diff --git a/lib/safe-browsing/ephy-gsb-storage.c b/lib/safe-browsing/ephy-gsb-storage.c
index 768091e8c..61382579b 100644
--- a/lib/safe-browsing/ephy-gsb-storage.c
+++ b/lib/safe-browsing/ephy-gsb-storage.c
@@ -21,6 +21,8 @@
 #include "config.h"
 #include "ephy-gsb-storage.h"
 
+#if ENABLE_GSB
+
 #include "ephy-debug.h"
 #include "ephy-sqlite-connection.h"
 
@@ -1712,3 +1714,5 @@ ephy_gsb_storage_update_hash_prefix_expiration (EphyGSBStorage *self,
 
   g_object_unref (statement);
 }
+
+#endif /* ENABLE_GSB */
diff --git a/lib/safe-browsing/ephy-gsb-storage.h b/lib/safe-browsing/ephy-gsb-storage.h
index ed41a7e23..83570c4bf 100644
--- a/lib/safe-browsing/ephy-gsb-storage.h
+++ b/lib/safe-browsing/ephy-gsb-storage.h
@@ -20,6 +20,8 @@
 
 #pragma once
 
+#if ENABLE_GSB
+
 #include "ephy-gsb-utils.h"
 
 #include <glib-object.h>
@@ -66,3 +68,5 @@ void            ephy_gsb_storage_update_hash_prefix_expiration  (EphyGSBStorage
                                                                  gint64          duration);
 
 G_END_DECLS
+
+#endif /* ENABLE_GSB */
diff --git a/lib/safe-browsing/ephy-gsb-utils.c b/lib/safe-browsing/ephy-gsb-utils.c
index cb66f969d..d8f5229b6 100644
--- a/lib/safe-browsing/ephy-gsb-utils.c
+++ b/lib/safe-browsing/ephy-gsb-utils.c
@@ -21,6 +21,8 @@
 #include "config.h"
 #include "ephy-gsb-utils.h"
 
+#if ENABLE_GSB
+
 #include "ephy-debug.h"
 #include "ephy-string.h"
 #include "ephy-uri-helpers.h"
@@ -917,3 +919,5 @@ ephy_gsb_utils_hash_has_prefix (GBytes *hash,
 
   return TRUE;
 }
+
+#endif /* ENABLE_GSB */
diff --git a/lib/safe-browsing/ephy-gsb-utils.h b/lib/safe-browsing/ephy-gsb-utils.h
index cfeb75dd8..b8e63bdf4 100644
--- a/lib/safe-browsing/ephy-gsb-utils.h
+++ b/lib/safe-browsing/ephy-gsb-utils.h
@@ -20,6 +20,8 @@
 
 #pragma once
 
+#if ENABLE_GSB
+
 #include <glib.h>
 #include <json-glib/json-glib.h>
 
@@ -96,3 +98,5 @@ gboolean                 ephy_gsb_utils_hash_has_prefix           (GBytes *hash,
                                                                    GBytes *prefix);
 
 G_END_DECLS
+
+#endif /* ENABLE_GSB */
diff --git a/src/ephy-window.c b/src/ephy-window.c
index baaa19614..952921046 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -2224,6 +2224,7 @@ decide_navigation_policy (WebKitWebView            *web_view,
   return accept_navigation_policy_decision (window, decision, uri);
 }
 
+#if ENABLE_GSB
 static void
 verify_url_cb (EphyGSBService     *service,
                GAsyncResult       *result,
@@ -2250,6 +2251,7 @@ verify_url_cb (EphyGSBService     *service,
 
   verify_url_async_data_free (data);
 }
+#endif
 
 static gboolean
 decide_navigation (EphyWindow               *window,
@@ -2258,6 +2260,7 @@ decide_navigation (EphyWindow               *window,
                    WebKitPolicyDecisionType  decision_type,
                    const char               *request_uri)
 {
+#if ENABLE_GSB
   EphyGSBService *service;
 
   if (g_settings_get_boolean (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_ENABLE_SAFE_BROWSING)) {
@@ -2278,6 +2281,7 @@ decide_navigation (EphyWindow               *window,
       return TRUE;
     }
   }
+#endif
 
   return decide_navigation_policy (web_view, decision, decision_type, window);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]