From ba402fabad9ff1361b60883fac84e59bd1df25e8 Mon Sep 17 00:00:00 2001 From: Mihai Parparita Date: Sun, 30 Nov 2014 14:57:20 -0800 Subject: [PATCH] Add redaction of data displayed via the admin UI. --- app/digest.go | 19 +++++++++++++++++-- app/retrogit.go | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/digest.go b/app/digest.go index ae0d2dc..6ffb1ac 100644 --- a/app/digest.go +++ b/app/digest.go @@ -27,7 +27,6 @@ type DigestCommit struct { Message string PushDate time.Time CommitDate time.Time - RepositoryCommit *github.RepositoryCommit } func safeFormattedDate(date string) string { @@ -63,7 +62,6 @@ func newDigestCommit(commit *github.RepositoryCommit, repo *Repo, location *time Message: message, PushDate: commit.Commit.Committer.Date.In(location), CommitDate: commit.Commit.Author.Date.In(location), - RepositoryCommit: commit, } } @@ -295,3 +293,20 @@ func (digest *Digest) fetch(githubClient *github.Client) error { func (digest *Digest) Empty() bool { return len(digest.IntervalDigests) == 0 } + +func (digest *Digest) Redact() { + for _, intervalDigest := range digest.IntervalDigests { + for _, repoDigest := range intervalDigest.RepoDigests { + *repoDigest.Repo.HTMLURL = "https://redacted" + *repoDigest.Repo.FullName = "redacted/redacted" + for i := range repoDigest.Commits { + commit := &repoDigest.Commits[i] + commit.DisplaySHA = "0000000" + commit.URL = "https://redacted" + commit.Title = "Redacted" + commit.Message = "Redacted redacted redacted" + } + } + + } +} diff --git a/app/retrogit.go b/app/retrogit.go index e5c6112..6f96c32 100644 --- a/app/retrogit.go +++ b/app/retrogit.go @@ -549,6 +549,7 @@ func digestAdminHandler(w http.ResponseWriter, r *http.Request) *AppError { if err != nil { return GitHubFetchError(err, "digest") } + digest.Redact() var data = map[string]interface{}{ "Digest": digest, }