mirror of
https://github.com/samsonjs/retrogit.git
synced 2026-03-25 09:25:49 +00:00
Add redaction of data displayed via the admin UI.
This commit is contained in:
parent
63070da7fb
commit
ba402fabad
2 changed files with 18 additions and 2 deletions
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue