Procházet zdrojové kódy

Add sensitive headers (#3429)

* Add HeaderWithSensitiveCase methods to respect casing

* Update webhook.go
tags/v1.4.0-rc1
Antoine GIRARD před 6 roky
rodič
revize
b3fd94c13d
2 změnil soubory, kde provedl 8 přidání a 2 odebrání
  1. 2
    2
      models/webhook.go
  2. 6
    0
      modules/httplib/httplib.go

+ 2
- 2
models/webhook.go Zobrazit soubor

Header("X-Gitea-Event", string(t.EventType)). Header("X-Gitea-Event", string(t.EventType)).
Header("X-Gogs-Delivery", t.UUID). Header("X-Gogs-Delivery", t.UUID).
Header("X-Gogs-Event", string(t.EventType)). Header("X-Gogs-Event", string(t.EventType)).
Header("X-GitHub-Delivery", t.UUID).
Header("X-GitHub-Event", string(t.EventType)).
HeaderWithSensitiveCase("X-GitHub-Delivery", t.UUID).
HeaderWithSensitiveCase("X-GitHub-Event", string(t.EventType)).
SetTLSClientConfig(&tls.Config{InsecureSkipVerify: setting.Webhook.SkipTLSVerify}) SetTLSClientConfig(&tls.Config{InsecureSkipVerify: setting.Webhook.SkipTLSVerify})


switch t.ContentType { switch t.ContentType {

+ 6
- 0
modules/httplib/httplib.go Zobrazit soubor

return r return r
} }


// HeaderWithSensitiveCase add header item in request and keep the case of the header key.
func (r *Request) HeaderWithSensitiveCase(key, value string) *Request {
r.req.Header[key] = []string{value}
return r
}

// Headers returns headers in request. // Headers returns headers in request.
func (r *Request) Headers() http.Header { func (r *Request) Headers() http.Header {
return r.req.Header return r.req.Header

Načítá se…
Zrušit
Uložit