Problem
handleTargetList (pkg/web/target.go:70-91) has two issues.
1. Installation token printed to stdout
ts, err := datastore.ListTargets(ctx, ds)
...
fmt.Println(ts)
fmt.Println(ts) (line 79) dumps the raw datastore.Target structs — including GitHubToken (a live GitHub Apps installation token) — to stdout on every GET /target request. The API response itself is properly sanitized via sanitizeTarget, but the debug print bypasses that. Any log aggregation collecting stdout stores valid tokens in plaintext (they expire after ~1h, but the window is real).
This looks like leftover debug code and should simply be removed.
2. Missing return after the error response
if err != nil {
logger.Logf(false, "failed to retrieve list of target: %+v", err)
outputErrorMsg(w, http.StatusInternalServerError, "datastore read error")
}
// execution continues: WriteHeader(200) is called again below
Lines 74-77: on a datastore error the handler writes a 500 but does not return, then falls through and writes a 200 header and body on the same response (http: superfluous response.WriteHeader + a bogus empty-list response to the client).
Suggested fix
- Delete the
fmt.Println(ts).
- Add
return after outputErrorMsg.
- Consider changing
GitHubToken to json:"-" in datastore.Target (pkg/datastore/interface.go) so an accidental direct serialization can never leak it structurally.
Problem
handleTargetList(pkg/web/target.go:70-91) has two issues.1. Installation token printed to stdout
fmt.Println(ts)(line 79) dumps the rawdatastore.Targetstructs — includingGitHubToken(a live GitHub Apps installation token) — to stdout on everyGET /targetrequest. The API response itself is properly sanitized viasanitizeTarget, but the debug print bypasses that. Any log aggregation collecting stdout stores valid tokens in plaintext (they expire after ~1h, but the window is real).This looks like leftover debug code and should simply be removed.
2. Missing
returnafter the error responseLines 74-77: on a datastore error the handler writes a 500 but does not
return, then falls through and writes a 200 header and body on the same response (http: superfluous response.WriteHeader+ a bogus empty-list response to the client).Suggested fix
fmt.Println(ts).returnafteroutputErrorMsg.GitHubTokentojson:"-"indatastore.Target(pkg/datastore/interface.go) so an accidental direct serialization can never leak it structurally.