Skip to content

Commit

Permalink
enhance: sanitize events from response
Browse files Browse the repository at this point in the history
  • Loading branch information
plyr4 committed Jan 2, 2025
1 parent 2d6555c commit a08ac8b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions api/build/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,10 @@ func GetStatus(c *gin.Context) {

l.Debug("reading status for build")

// sanitize fields for the unauthenticated response
if b.Repo != nil {
b.Repo.StatusSanitize()
}

c.JSON(http.StatusOK, b)
}
3 changes: 3 additions & 0 deletions api/repo/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,8 @@ func GetStatus(c *gin.Context) {

l.Debug("reading status for repo")

// sanitize fields for the unauthenticated response
r.StatusSanitize()

c.JSON(http.StatusOK, r)
}
6 changes: 6 additions & 0 deletions api/types/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -723,3 +723,9 @@ func (r *Repo) String() string {
r.GetInstallID(),
)
}

// StatusSanitize removes sensitive information before producing a "status".
func (r *Repo) StatusSanitize() {
// remove allowed events
r.AllowEvents = nil
}

0 comments on commit a08ac8b

Please sign in to comment.