Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #198 from vania-pooh/master
Browse files Browse the repository at this point in the history
Removing credentials from /quota data (fixes #193)
  • Loading branch information
aandryashin authored May 9, 2018
2 parents 32ddcee + ac826b3 commit 1e94fba
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
15 changes: 14 additions & 1 deletion proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,20 @@ func quotaInfo(w http.ResponseWriter, r *http.Request) {
log.Printf("[%d] [-] [QUOTA_INFO_REQUESTED] [%s] [%s] [-] [-] [-] [-] [-]\n", id, user, remote)
browsers := quota[user]
w.Header().Set("Content-Type", "application/json")
// NOTE: intentionally not removing username \ password fields from returned XML to not complicate things (can be done later if needed)
for i := 0; i < len(browsers.Browsers); i++ {
browser := &browsers.Browsers[i]
for j := 0; j < len(browser.Versions); j++ {
version := &browser.Versions[j]
for k := 0; k < len(version.Regions); k++ {
region := &version.Regions[k]
for l := 0; l < len(region.Hosts); l++ {
host := &region.Hosts[l]
host.Username = ""
host.Password = ""
}
}
}
}
json.NewEncoder(w).Encode(browsers.Browsers)
}

Expand Down
14 changes: 11 additions & 3 deletions proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ func TestGetQuotaInfoUnauthorized(t *testing.T) {
func TestGetQuotaInfo(t *testing.T) {
test.Lock()
defer test.Unlock()

browsers := Browsers{Browsers: []Browser{
{Name: "browser", DefaultVersion: "1.0", Versions: []Version{
{Number: "1.0", Regions: []Region{
Expand All @@ -190,7 +189,16 @@ func TestGetQuotaInfo(t *testing.T) {
var fetchedBrowsers []Browser
err = json.NewDecoder(rsp.Body).Decode(&fetchedBrowsers)
AssertThat(t, err, Is{nil})
AssertThat(t, fetchedBrowsers, EqualTo{browsers.Browsers})

browsersWithoutCredentials := []Browser{
{Name: "browser", DefaultVersion: "1.0", Versions: []Version{
{Number: "1.0", Regions: []Region{
{Hosts: Hosts{
Host{Name: "example.com", Port: 4444, Count: 1, Username: "", Password: ""},
}},
}},
}}}
AssertThat(t, fetchedBrowsers, EqualTo{browsersWithoutCredentials})
}

func TestProxyScreenVNCProtocol(t *testing.T) {
Expand Down Expand Up @@ -1453,4 +1461,4 @@ func TestFileExists(t *testing.T) {
f, err := ioutil.TempFile(tmpDir, "testfile")
AssertThat(t, err, Is{nil})
AssertThat(t, fileExists(f.Name()), Is{true})
}
}

0 comments on commit 1e94fba

Please sign in to comment.