Skip to content

Commit 5f528a4

Browse files
committed
Fix security issues
1 parent ef21533 commit 5f528a4

File tree

2 files changed

+55
-75
lines changed

2 files changed

+55
-75
lines changed

cls/SourceControl/Git/Utils.cls

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2933,55 +2933,4 @@ ClassMethod InDefaultBranchBasicMode() As %Boolean
29332933
quit 0
29342934
}
29352935

2936-
ClassMethod ConfigureFavoriteNamespaces(username As %String, newNamespaces As %String)
2937-
{
2938-
// Delete all the GIT favorite links for the user
2939-
&sql(DELETE FROM %SYS_Portal.Users WHERE Username = :username AND Page LIKE '%Git%')
2940-
2941-
set iterator = newNamespaces.%GetIterator()
2942-
while iterator.%GetNext(.key, .value) {
2943-
set installNamespace = value
2944-
2945-
// Insert Git link
2946-
set caption = "Git: " _ installNamespace
2947-
set link = "/isc/studio/usertemplates/gitsourcecontrol/webuidriver.csp/" _ installNamespace _ "/"
2948-
&sql(INSERT OR UPDATE INTO %SYS_Portal.Users (Username, Page, Data) VALUES (:username, :caption, :link))
2949-
2950-
// Insert Git Pull link
2951-
set caption = "Git Pull: " _ installNamespace
2952-
set link = "/isc/studio/usertemplates/gitsourcecontrol/pull.csp?$NAMESPACE=" _ installNamespace
2953-
&sql(INSERT OR UPDATE INTO %SYS_Portal.Users (Username, Page, Data) VALUES (:username, :caption, :link))
2954-
}
2955-
}
2956-
2957-
ClassMethod GetFavoriteNamespaces(ByRef favNamespaces As %DynamicArray, ByRef nonFavNamespaces As %DynamicArray)
2958-
{
2959-
set allNamespaces = ..GetContexts(1)
2960-
set iterator = allNamespaces.%GetIterator()
2961-
2962-
set username = $USERNAME
2963-
set pagePrefix = "Git:"
2964-
&sql(DECLARE FavCursor CURSOR FOR SELECT Page into :page from %SYS_Portal.Users where username = :username and page %STARTSWITH :pagePrefix)
2965-
2966-
while iterator.%GetNext(.key, .value) {
2967-
set foundFlag = 0
2968-
&sql(OPEN FavCursor)
2969-
throw:SQLCODE<0 ##class(%Exception.SQL).CreateFromSQLCODE(SQLCODE, %msg)
2970-
&sql(FETCH FavCursor)
2971-
while (SQLCODE = 0) {
2972-
set pageValue = "Git: "_value
2973-
if (page = pageValue) {
2974-
do favNamespaces.%Push(value)
2975-
set foundFlag = 1
2976-
}
2977-
&sql(FETCH FavCursor)
2978-
}
2979-
&sql(CLOSE FavCursor)
2980-
2981-
if ('foundFlag) {
2982-
do nonFavNamespaces.%Push(value)
2983-
}
2984-
}
2985-
}
2986-
29872936
}

cls/_zpkg/isc/sc/git/Favorites.cls

Lines changed: 55 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,85 @@
1-
Class %zpkg.isc.sc.git.Favorites Extends %RegisteredObject
1+
Class %zpkg.isc.sc.git.Favorites
22
{
3-
ClassMethod ConfigureFavoriteNamespaces(username As %String, newNamespaces As %String)
3+
ClassMethod ConfigureFavoriteNamespaces(username As %String, newNamespaces As %Library.DynamicObject)
44
{
5-
$$$AddAllRoleTemporary
6-
// Delete all the GIT favorite links for the user
7-
&sql(DELETE FROM %SYS_Portal.Users WHERE Username = :username AND Page LIKE '%Git%')
8-
9-
set iterator = newNamespaces.%GetIterator()
10-
while iterator.%GetNext(.key, .value) {
11-
set installNamespace = value
12-
13-
// Insert Git link
14-
set caption = "Git: " _ installNamespace
15-
set link = "/isc/studio/usertemplates/gitsourcecontrol/webuidriver.csp/" _ installNamespace _ "/"
16-
&sql(INSERT OR UPDATE INTO %SYS_Portal.Users (Username, Page, Data) VALUES (:username, :caption, :link))
17-
18-
// Insert Git Pull link
19-
set caption = "Git Pull: " _ installNamespace
20-
set link = "/isc/studio/usertemplates/gitsourcecontrol/pull.csp?$NAMESPACE=" _ installNamespace
21-
&sql(INSERT OR UPDATE INTO %SYS_Portal.Users (Username, Page, Data) VALUES (:username, :caption, :link))
5+
// Convert to $listbuild
6+
set namespaces = $lb("")
7+
for i=0:1:newNamespaces.%Size() {
8+
set namespaces = namespaces_$lb(newNamespaces.%Get(i))
9+
}
10+
// Call the private method
11+
try {
12+
do ..SetFavs(username, namespaces)
13+
} catch e {
14+
return e.AsStatus()
2215
}
16+
return $$$OK
2317
}
2418

2519
ClassMethod GetFavoriteNamespaces(ByRef favNamespaces As %DynamicArray, ByRef nonFavNamespaces As %DynamicArray)
2620
{
21+
try {
22+
set namespaces = ..GetFavs()
23+
set favNamespaces = namespaces.%Get("Favorites")
24+
set nonFavNamespaces = namespaces.%Get("NonFavorites")
25+
} catch e {
26+
return e.AsStatus()
27+
}
28+
return $$$OK
29+
}
30+
31+
ClassMethod GetFavs() As %Library.DynamicObject [Private] {
2732
$$$AddAllRoleTemporary
2833
set allNamespaces = ##class(SourceControl.Git.Utils).GetContexts(1)
29-
set iterator = allNamespaces.%GetIterator()
34+
35+
set favNamespaces = []
36+
set nonFavNamespaces = []
3037

3138
set username = $USERNAME
3239
set pagePrefix = "Git:"
3340
&sql(DECLARE FavCursor CURSOR FOR SELECT Page into :page from %SYS_Portal.Users where username = :username and page %STARTSWITH :pagePrefix)
3441

35-
while iterator.%GetNext(.key, .value) {
42+
for i=0:1:(allNamespaces.%Size() - 1) {
43+
set namespace = allNamespaces.%Get(i)
3644
set foundFlag = 0
3745
&sql(OPEN FavCursor)
3846
throw:SQLCODE<0 ##class(%Exception.SQL).CreateFromSQLCODE(SQLCODE, %msg)
3947
&sql(FETCH FavCursor)
4048
while (SQLCODE = 0) {
41-
set pageValue = "Git: "_value
49+
set pageValue = "Git: "_namespace
4250
if (page = pageValue) {
43-
do favNamespaces.%Push(value)
51+
do favNamespaces.%Push(namespace)
4452
set foundFlag = 1
4553
}
4654
&sql(FETCH FavCursor)
4755
}
4856
&sql(CLOSE FavCursor)
4957

5058
if ('foundFlag) {
51-
do nonFavNamespaces.%Push(value)
59+
do nonFavNamespaces.%Push(namespace)
60+
}
61+
}
62+
return {"Favorites": (favNamespaces), "NonFavorites": (nonFavNamespaces)}
63+
}
64+
65+
ClassMethod SetFavs(username As %String, namespaces As %List) [Private] {
66+
$$$AddAllRoleTemporary
67+
&sql(DELETE FROM %SYS_Portal.Users WHERE Username = :username AND Page LIKE '%Git%')
68+
69+
for i=1:1:$listlength(namespaces) {
70+
set namespace = $listget(namespaces, i)
71+
if (namespace '= "") {
72+
set installNamespace = namespace
73+
74+
// Insert Git link
75+
set caption = "Git: " _ installNamespace
76+
set link = "/isc/studio/usertemplates/gitsourcecontrol/webuidriver.csp/" _ installNamespace _ "/"
77+
&sql(INSERT OR UPDATE INTO %SYS_Portal.Users (Username, Page, Data) VALUES (:username, :caption, :link))
78+
79+
// Insert Git Pull link
80+
set caption = "Git Pull: " _ installNamespace
81+
set link = "/isc/studio/usertemplates/gitsourcecontrol/pull.csp?$NAMESPACE=" _ installNamespace
82+
&sql(INSERT OR UPDATE INTO %SYS_Portal.Users (Username, Page, Data) VALUES (:username, :caption, :link))
5283
}
5384
}
5485
}

0 commit comments

Comments
 (0)