Add redaction of data displayed via the admin UI.

This commit is contained in:
Mihai Parparita 2014-11-30 14:57:20 -08:00
parent 63070da7fb
commit ba402fabad
2 changed files with 18 additions and 2 deletions

View file

@ -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"
}
}
}
}

View file

@ -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,
}