Skip to content
This repository was archived by the owner on Mar 11, 2021. It is now read-only.

Commit 2661cf8

Browse files
authored
Provide join lock down (#2211)
This includes an extra-condition in the `ON` part of the table `JOINS` for areas, codebases and iterations to only join those tables filtered by their space ID. I'm not sure though if this really fixes the problem (see #2210 (comment)). ## TODO As of yesterday's (07.08.2018) discussion with @aslakknutsen we did experiments and found that in order to keep the rows in the search small, we have to establish a condition on the final SQL `WHERE` clause that limits the selection to work items from a particular space. At the moment, the current `/api/search` endpoint is so generic that it doesn't require a limitation by space on the root of the `WHERE` clause. That's why @aslakknutsen and I agreed to create a search endpoint under `/api/spaces/<SPACE-UUID>/search` in order to automatically add the space ID to the query condition. This will be implemented in another PR and is tracked in openshiftio/openshift.io#4124 See #2210.
1 parent 18d2d47 commit 2661cf8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

workitem/expression_compiler.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,21 +125,21 @@ var DefaultTableJoins = func() TableJoinMap {
125125
"iteration": {
126126
TableName: "iterations",
127127
TableAlias: "iter",
128-
On: JoinOnJSONField(SystemIteration, "iter.id"),
128+
On: JoinOnJSONField(SystemIteration, "iter.id") + " AND " + Column("iter", "space_id") + "=" + Column(WorkItemStorage{}.TableName(), "space_id"),
129129
PrefixActivators: []string{"iteration."},
130130
AllowedColumns: []string{"name", "created_at"},
131131
},
132132
"area": {
133133
TableName: "areas",
134134
TableAlias: "ar",
135-
On: JoinOnJSONField(SystemArea, "ar.id"),
135+
On: JoinOnJSONField(SystemArea, "ar.id") + " AND " + Column("ar", "space_id") + "=" + Column(WorkItemStorage{}.TableName(), "space_id"),
136136
PrefixActivators: []string{"area."},
137137
AllowedColumns: []string{"name"},
138138
},
139139
"codebase": {
140140
TableName: "codebases",
141141
TableAlias: "cb",
142-
On: JoinOnJSONField(SystemCodebase, "cb.id"),
142+
On: JoinOnJSONField(SystemCodebase, "cb.id") + " AND " + Column("cb", "space_id") + "=" + Column(WorkItemStorage{}.TableName(), "space_id"),
143143
PrefixActivators: []string{"codebase."},
144144
AllowedColumns: []string{"url"},
145145
},

0 commit comments

Comments
 (0)