[tracker/wip/carlosg/portal: 16/40] libtracker-data: Filter down updates on forbidden graphs
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/portal: 16/40] libtracker-data: Filter down updates on forbidden graphs
- Date: Sun, 12 Jul 2020 17:52:54 +0000 (UTC)
commit b66745d2cfce970cba39cca6c0a1d997be59c64b
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Jan 25 13:52:44 2020 +0100
libtracker-data: Filter down updates on forbidden graphs
Mostly for the case of insert/delete/update statements, check the current
graph can be accessed before letting updates go through.
src/libtracker-data/tracker-sparql.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
---
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index f807d5c70..c910a8fd0 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -656,6 +656,27 @@ build_properties_string (TrackerSparql *sparql,
}
}
+static gboolean
+tracker_sparql_graph_is_whitelisted (TrackerSparql *sparql,
+ const gchar *graph)
+{
+ gint i;
+
+ if (!sparql->policy.graphs)
+ return TRUE;
+
+ for (i = 0; i < sparql->policy.graphs->len; i++) {
+ const gchar *policy_graph;
+
+ policy_graph = g_ptr_array_index (sparql->policy.graphs, i);
+
+ if (g_strcmp0 (graph, policy_graph) == 0)
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static GHashTable *
tracker_sparql_get_effective_graphs (TrackerSparql *sparql)
{
@@ -1942,6 +1963,15 @@ tracker_sparql_apply_quad (TrackerSparql *sparql,
{
GError *inner_error = NULL;
+ if ((tracker_token_is_empty (&sparql->current_state.graph) &&
+ sparql->policy.filter_unnamed_graph) ||
+ (tracker_token_get_literal (&sparql->current_state.graph) &&
+ !tracker_sparql_graph_is_whitelisted (sparql, tracker_token_get_idstring
(&sparql->current_state.graph)))) {
+ _raise (CONSTRAINT, "Access to graph is disallowed",
+ tracker_token_is_empty (&sparql->current_state.graph) ? "DEFAULT" :
+ tracker_token_get_idstring (&sparql->current_state.graph));
+ }
+
switch (sparql->current_state.type) {
case TRACKER_SPARQL_TYPE_SELECT:
_add_quad (sparql,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]