Skip to content

Non read-only webUI git operations lock session #388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Modifications to local repo files are now synced with IRIS (#153)
- Menu items names are properly translated from internal name in VSCode, Management Portal (#372)
- Now has proper locking behavior in `##class(SourceControl.Git.WebUIDriver).HandleRequest()`(#385)
- Git operations from the WebUI now don't unlock the session if they aren't read-only

## [2.3.1] - 2024-04-30

Expand Down
1 change: 1 addition & 0 deletions cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ Method DeleteFile(item As %String) As %Status
}

}

1 change: 1 addition & 0 deletions cls/SourceControl/Git/Settings.cls
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,4 @@ Method OnAfterConfigure() As %Boolean
}

}

7 changes: 6 additions & 1 deletion cls/SourceControl/Git/WebUIDriver.cls
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Class SourceControl.Git.WebUIDriver

ClassMethod HandleRequest(pagePath As %String, InternalName As %String = "", Output handled As %Boolean = 0, Output %data As %Stream.Object)
{
do %session.Unlock()
// Make sure we capture any stray output
set buffer = ##class(SourceControl.Git.Util.Buffer).%New()
do buffer.BeginCaptureOutput()
Expand All @@ -13,6 +12,7 @@ ClassMethod HandleRequest(pagePath As %String, InternalName As %String = "", Out
#dim %request as %CSP.Request
set pathStart = $piece(pagePath,"/",2)
if pathStart = "api" {
do %session.Unlock()
set handled = 1
set %data = ##class(%Stream.FileCharacter).%New()
if $extract(pagePath,6,*) = "userinfo" {
Expand Down Expand Up @@ -42,6 +42,7 @@ ClassMethod HandleRequest(pagePath As %String, InternalName As %String = "", Out
SimpleHTTPRequestHandler.do_GET(self)
*/
if (pathStart = "git") {
do %session.Unlock()
if $piece(pagePath,"/",3) = "cat-file" {
set blob = $piece(pagePath,"/",4)
set name = $Piece(pagePath,"/",*)
Expand Down Expand Up @@ -107,6 +108,10 @@ ClassMethod HandleRequest(pagePath As %String, InternalName As %String = "", Out
}
set readOnlyCommands = $listbuild("branch","tag","log","ls-files","ls-tree","show","status","diff")
set baseCommand = $Piece(args(1)," ")

if $listfind(readOnlyCommands,baseCommand) {
do %session.Unlock()
}

set gitArgs($increment(gitArgs)) = "color.ui=true"

Expand Down
4 changes: 3 additions & 1 deletion csp/webuidriver.csp
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@
} catch e {
// ignore; may occur on platform versions without the above properties
}
do %session.Unlock()


// Serve static content when appropriate.
// index.html
if (url = %base) || (url = $Extract(%base,1,*-1)) {
do %session.Unlock()
do %request.Set("FILE","/isc/studio/usertemplates/gitsourcecontrol/index.html")
set %stream = 1
quit 1
}
// other static resources
if $Match(url,"^(.*/img/.*|.*\.(js|map|html|css|woff|woff2))$") {
do %session.Unlock()
do %request.Set("FILE","/isc/studio/usertemplates/gitsourcecontrol/"_$Piece(url,%base,2,*))
kill %base
set %stream = 1
Expand Down
Loading