Skip to content

Commit

Permalink
fix: filter Authorization header from preheat log (#2817)
Browse files Browse the repository at this point in the history
Signed-off-by: bannykh <[email protected]>
  • Loading branch information
pbannykh authored Oct 30, 2023
1 parent 18e90ce commit 898c7e9
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion scheduler/job/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (j *job) preheat(ctx context.Context, req string) error {
taskID := idgen.TaskIDV1(preheat.URL, urlMeta)
log := logger.WithTask(taskID, preheat.URL)
log.Infof("preheat %s headers: %#v, tag: %s, range: %s, filter: %s, digest: %s",
preheat.URL, urlMeta.Header, urlMeta.Tag, urlMeta.Range, urlMeta.Filter, urlMeta.Digest)
preheat.URL, filterHeaders(urlMeta.Header, log.IsDebug()), urlMeta.Tag, urlMeta.Range, urlMeta.Filter, urlMeta.Digest)
stream, err := j.resource.SeedPeer().Client().ObtainSeeds(ctx, &cdnsystemv1.SeedRequest{
TaskId: taskID,
Url: preheat.URL,
Expand Down Expand Up @@ -227,3 +227,14 @@ func (j *job) syncPeers() (string, error) {

return internaljob.MarshalResponse(hosts)
}

// filterHeaders filters Authorization header if debugging is not enabled
func filterHeaders(urlHeader map[string]string, isDebug bool) map[string]string {
filteredHeaders := make(map[string]string)
for k, v := range urlHeader {
if isDebug || k != headers.Authorization {
filteredHeaders[k] = v
}
}
return filteredHeaders
}

0 comments on commit 898c7e9

Please sign in to comment.