diff options
author | zeripath <art27@cantab.net> | 2021-04-05 22:38:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-05 17:38:31 -0400 |
commit | 04196b7658d70a1dee22a25aeb26e3d1587c316f (patch) | |
tree | 9095331975714251797154d069ca01ead6f60999 /vendor | |
parent | e10d028b039af5d63ef29f4c33fb04029da3d5a8 (diff) | |
download | gitea-04196b7658d70a1dee22a25aeb26e3d1587c316f.tar.gz gitea-04196b7658d70a1dee22a25aeb26e3d1587c316f.zip |
Update to bluemonday-1.0.6 (#15294)
Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'vendor')
-rw-r--r-- | vendor/github.com/aymerick/douceur/parser/parser.go (renamed from vendor/github.com/chris-ramon/douceur/parser/parser.go) | 0 | ||||
-rw-r--r-- | vendor/github.com/chris-ramon/douceur/LICENSE | 22 | ||||
-rw-r--r-- | vendor/github.com/microcosm-cc/bluemonday/SECURITY.md | 15 | ||||
-rw-r--r-- | vendor/github.com/microcosm-cc/bluemonday/go.mod | 7 | ||||
-rw-r--r-- | vendor/github.com/microcosm-cc/bluemonday/go.sum | 11 | ||||
-rw-r--r-- | vendor/github.com/microcosm-cc/bluemonday/handlers.go | 1 | ||||
-rw-r--r-- | vendor/github.com/microcosm-cc/bluemonday/policy.go | 43 | ||||
-rw-r--r-- | vendor/github.com/microcosm-cc/bluemonday/sanitize.go | 52 | ||||
-rw-r--r-- | vendor/golang.org/x/net/internal/socket/rawconn.go | 33 | ||||
-rw-r--r-- | vendor/modules.txt | 8 |
10 files changed, 133 insertions, 59 deletions
diff --git a/vendor/github.com/chris-ramon/douceur/parser/parser.go b/vendor/github.com/aymerick/douceur/parser/parser.go index 6c4917ccf9..6c4917ccf9 100644 --- a/vendor/github.com/chris-ramon/douceur/parser/parser.go +++ b/vendor/github.com/aymerick/douceur/parser/parser.go diff --git a/vendor/github.com/chris-ramon/douceur/LICENSE b/vendor/github.com/chris-ramon/douceur/LICENSE deleted file mode 100644 index 6ce87cd374..0000000000 --- a/vendor/github.com/chris-ramon/douceur/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 Aymerick JEHANNE - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - diff --git a/vendor/github.com/microcosm-cc/bluemonday/SECURITY.md b/vendor/github.com/microcosm-cc/bluemonday/SECURITY.md new file mode 100644 index 0000000000..a344e7c050 --- /dev/null +++ b/vendor/github.com/microcosm-cc/bluemonday/SECURITY.md @@ -0,0 +1,15 @@ +# Security Policy + +## Supported Versions + +Latest tag and tip are supported. + +Older tags remain present but changes result in new tags and are not back ported... please verify any issue against the latest tag and tip. + +## Reporting a Vulnerability + +Email: <bluemonday@buro9.com> + +Bluemonday is pure OSS and not maintained by a company. As such there is no bug bounty program but security issues will be taken seriously and resolved as soon as possible. + +The maintainer lives in the United Kingdom and whilst the email is monitored expect a reply or ACK when the maintainer is awake. diff --git a/vendor/github.com/microcosm-cc/bluemonday/go.mod b/vendor/github.com/microcosm-cc/bluemonday/go.mod index 47b521a75b..0ff3d77b03 100644 --- a/vendor/github.com/microcosm-cc/bluemonday/go.mod +++ b/vendor/github.com/microcosm-cc/bluemonday/go.mod @@ -1,10 +1,9 @@ module github.com/microcosm-cc/bluemonday -go 1.9 +go 1.16 require ( - github.com/aymerick/douceur v0.2.0 // indirect - github.com/chris-ramon/douceur v0.2.0 + github.com/aymerick/douceur v0.2.0 github.com/gorilla/css v1.0.0 // indirect - golang.org/x/net v0.0.0-20181220203305-927f97764cc3 + golang.org/x/net v0.0.0-20210331212208-0fccb6fa2b5c ) diff --git a/vendor/github.com/microcosm-cc/bluemonday/go.sum b/vendor/github.com/microcosm-cc/bluemonday/go.sum index 8c34e7a404..7955d9eb02 100644 --- a/vendor/github.com/microcosm-cc/bluemonday/go.sum +++ b/vendor/github.com/microcosm-cc/bluemonday/go.sum @@ -1,8 +1,11 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk= github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= -github.com/chris-ramon/douceur v0.2.0 h1:IDMEdxlEUUBYBKE4z/mJnFyVXox+MjuEVDJNN27glkU= -github.com/chris-ramon/douceur v0.2.0/go.mod h1:wDW5xjJdeoMm1mRt4sD4c/LbF/mWdEpRXQKjTR8nIBE= github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY= github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c= -golang.org/x/net v0.0.0-20181220203305-927f97764cc3 h1:eH6Eip3UpmR+yM/qI9Ijluzb1bNv/cAU/n+6l8tRSis= -golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20210331212208-0fccb6fa2b5c h1:KHUzaHIpjWVlVVNh65G3hhuj3KB1HnjY6Cq5cTvRQT8= +golang.org/x/net v0.0.0-20210331212208-0fccb6fa2b5c/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/vendor/github.com/microcosm-cc/bluemonday/handlers.go b/vendor/github.com/microcosm-cc/bluemonday/handlers.go index 1ef4c8acd0..9753d6e952 100644 --- a/vendor/github.com/microcosm-cc/bluemonday/handlers.go +++ b/vendor/github.com/microcosm-cc/bluemonday/handlers.go @@ -26,6 +26,7 @@ // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + package bluemonday import ( diff --git a/vendor/github.com/microcosm-cc/bluemonday/policy.go b/vendor/github.com/microcosm-cc/bluemonday/policy.go index 739d302c30..9c7e662fc2 100644 --- a/vendor/github.com/microcosm-cc/bluemonday/policy.go +++ b/vendor/github.com/microcosm-cc/bluemonday/policy.go @@ -69,6 +69,9 @@ type Policy struct { // Will skip for href="/foo" or href="foo" requireNoReferrerFullyQualifiedLinks bool + // When true, add crossorigin="anonymous" to HTML audio, img, link, script, and video tags + requireCrossOriginAnonymous bool + // When true add target="_blank" to fully qualified links // Will add for href="http://foo" // Will skip for href="/foo" or href="foo" @@ -433,24 +436,24 @@ func (spb *stylePolicyBuilder) OnElements(elements ...string) *Policy { // and return the updated policy func (spb *stylePolicyBuilder) OnElementsMatching(regex *regexp.Regexp) *Policy { - for _, attr := range spb.propertyNames { + for _, attr := range spb.propertyNames { - if _, ok := spb.p.elsMatchingAndStyles[regex]; !ok { - spb.p.elsMatchingAndStyles[regex] = make(map[string]stylePolicy) - } + if _, ok := spb.p.elsMatchingAndStyles[regex]; !ok { + spb.p.elsMatchingAndStyles[regex] = make(map[string]stylePolicy) + } - sp := stylePolicy{} - if spb.handler != nil { - sp.handler = spb.handler - } else if len(spb.enum) > 0 { - sp.enum = spb.enum - } else if spb.regexp != nil { - sp.regexp = spb.regexp - } else { - sp.handler = getDefaultHandler(attr) - } - spb.p.elsMatchingAndStyles[regex][attr] = sp + sp := stylePolicy{} + if spb.handler != nil { + sp.handler = spb.handler + } else if len(spb.enum) > 0 { + sp.enum = spb.enum + } else if spb.regexp != nil { + sp.regexp = spb.regexp + } else { + sp.handler = getDefaultHandler(attr) } + spb.p.elsMatchingAndStyles[regex][attr] = sp + } return spb.p } @@ -558,6 +561,16 @@ func (p *Policy) RequireNoReferrerOnFullyQualifiedLinks(require bool) *Policy { return p } +// RequireCrossOriginAnonymous will result in all audio, img, link, script, and +// video tags having a crossorigin="anonymous" added to them if one does not +// already exist +func (p *Policy) RequireCrossOriginAnonymous(require bool) *Policy { + + p.requireCrossOriginAnonymous = require + + return p +} + // AddTargetBlankToFullyQualifiedLinks will result in all a, area and link tags // that point to a non-local destination (i.e. starts with a protocol and has a // host) having a target="_blank" added to them if one does not already exist diff --git a/vendor/github.com/microcosm-cc/bluemonday/sanitize.go b/vendor/github.com/microcosm-cc/bluemonday/sanitize.go index a58333aa65..99559bbabe 100644 --- a/vendor/github.com/microcosm-cc/bluemonday/sanitize.go +++ b/vendor/github.com/microcosm-cc/bluemonday/sanitize.go @@ -39,7 +39,7 @@ import ( "golang.org/x/net/html" - cssparser "github.com/chris-ramon/douceur/parser" + "github.com/aymerick/douceur/parser" ) var ( @@ -286,7 +286,7 @@ func (p *Policy) sanitize(r io.Reader) *bytes.Buffer { case html.StartTagToken: - mostRecentlyStartedToken = strings.ToLower(token.Data) + mostRecentlyStartedToken = normaliseElementName(token.Data) aps, ok := p.elsAndAttrs[token.Data] if !ok { @@ -329,7 +329,7 @@ func (p *Policy) sanitize(r io.Reader) *bytes.Buffer { case html.EndTagToken: - if mostRecentlyStartedToken == strings.ToLower(token.Data) { + if mostRecentlyStartedToken == normaliseElementName(token.Data) { mostRecentlyStartedToken = "" } @@ -407,11 +407,11 @@ func (p *Policy) sanitize(r io.Reader) *bytes.Buffer { if !skipElementContent { switch mostRecentlyStartedToken { - case "script": + case `script`: // not encouraged, but if a policy allows JavaScript we // should not HTML escape it as that would break the output buff.WriteString(token.Data) - case "style": + case `style`: // not encouraged, but if a policy allows CSS styles we // should not HTML escape it as that would break the output buff.WriteString(token.Data) @@ -721,6 +721,26 @@ func (p *Policy) sanitizeAttrs( } } + if p.requireCrossOriginAnonymous && len(cleanAttrs) > 0 { + switch elementName { + case "audio", "img", "link", "script", "video": + var crossOriginFound bool + for _, htmlAttr := range cleanAttrs { + if htmlAttr.Key == "crossorigin" { + crossOriginFound = true + htmlAttr.Val = "anonymous" + } + } + + if !crossOriginFound { + crossOrigin := html.Attribute{} + crossOrigin.Key = "crossorigin" + crossOrigin.Val = "anonymous" + cleanAttrs = append(cleanAttrs, crossOrigin) + } + } + } + return cleanAttrs } @@ -744,7 +764,7 @@ func (p *Policy) sanitizeStyles(attr html.Attribute, elementName string) html.At if len(attr.Val) > 0 && attr.Val[len(attr.Val)-1] != ';' { attr.Val = attr.Val + ";" } - decs, err := cssparser.ParseDeclarations(attr.Val) + decs, err := parser.ParseDeclarations(attr.Val) if err != nil { attr.Val = "" return attr @@ -944,3 +964,23 @@ func (p *Policy) matchRegex(elementName string) (map[string]attrPolicy, bool) { } return aps, matched } + + +// normaliseElementName takes a HTML element like <script> which is user input +// and returns a lower case version of it that is immune to UTF-8 to ASCII +// conversion tricks (like the use of upper case cyrillic i scrÄ°pt which a +// strings.ToLower would convert to script). Instead this func will preserve +// all non-ASCII as their escaped equivalent, i.e. \u0130 which reveals the +// characters when lower cased +func normaliseElementName(str string) string { + // that useful QuoteToASCII put quote marks at the start and end + // so those are trimmed off + return strings.TrimSuffix( + strings.TrimPrefix( + strings.ToLower( + strconv.QuoteToASCII(str), + ), + `"`), + `"`, + ) +}
\ No newline at end of file diff --git a/vendor/golang.org/x/net/internal/socket/rawconn.go b/vendor/golang.org/x/net/internal/socket/rawconn.go index b07b890050..87e81071c1 100644 --- a/vendor/golang.org/x/net/internal/socket/rawconn.go +++ b/vendor/golang.org/x/net/internal/socket/rawconn.go @@ -17,18 +17,45 @@ type Conn struct { c syscall.RawConn } +// tcpConn is an interface implemented by net.TCPConn. +// It can be used for interface assertions to check if a net.Conn is a TCP connection. +type tcpConn interface { + SyscallConn() (syscall.RawConn, error) + SetLinger(int) error +} + +var _ tcpConn = (*net.TCPConn)(nil) + +// udpConn is an interface implemented by net.UDPConn. +// It can be used for interface assertions to check if a net.Conn is a UDP connection. +type udpConn interface { + SyscallConn() (syscall.RawConn, error) + ReadMsgUDP(b, oob []byte) (n, oobn, flags int, addr *net.UDPAddr, err error) +} + +var _ udpConn = (*net.UDPConn)(nil) + +// ipConn is an interface implemented by net.IPConn. +// It can be used for interface assertions to check if a net.Conn is an IP connection. +type ipConn interface { + SyscallConn() (syscall.RawConn, error) + ReadMsgIP(b, oob []byte) (n, oobn, flags int, addr *net.IPAddr, err error) +} + +var _ ipConn = (*net.IPConn)(nil) + // NewConn returns a new raw connection. func NewConn(c net.Conn) (*Conn, error) { var err error var cc Conn switch c := c.(type) { - case *net.TCPConn: + case tcpConn: cc.network = "tcp" cc.c, err = c.SyscallConn() - case *net.UDPConn: + case udpConn: cc.network = "udp" cc.c, err = c.SyscallConn() - case *net.IPConn: + case ipConn: cc.network = "ip" cc.c, err = c.SyscallConn() default: diff --git a/vendor/modules.txt b/vendor/modules.txt index a0111a24a0..e0509e0a28 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -92,6 +92,7 @@ github.com/anmitsu/go-shlex github.com/asaskevich/govalidator # github.com/aymerick/douceur v0.2.0 github.com/aymerick/douceur/css +github.com/aymerick/douceur/parser # github.com/beorn7/perks v1.0.1 github.com/beorn7/perks/quantile # github.com/blevesearch/bleve/v2 v2.0.2 @@ -178,8 +179,6 @@ github.com/cespare/xxhash/v2 # github.com/chi-middleware/proxy v1.1.1 ## explicit github.com/chi-middleware/proxy -# github.com/chris-ramon/douceur v0.2.0 -github.com/chris-ramon/douceur/parser # github.com/couchbase/go-couchbase v0.0.0-20210224140812-5740cd35f448 ## explicit github.com/couchbase/go-couchbase @@ -597,7 +596,7 @@ github.com/mholt/acmez/acme # github.com/mholt/archiver/v3 v3.5.0 ## explicit github.com/mholt/archiver/v3 -# github.com/microcosm-cc/bluemonday v1.0.5 => github.com/lunny/bluemonday v1.0.5-0.20201227154428-ca34796141e8 +# github.com/microcosm-cc/bluemonday v1.0.6 ## explicit github.com/microcosm-cc/bluemonday # github.com/miekg/dns v1.1.40 @@ -891,7 +890,7 @@ golang.org/x/crypto/ssh/knownhosts # golang.org/x/mod v0.4.1 golang.org/x/mod/module golang.org/x/mod/semver -# golang.org/x/net v0.0.0-20210331212208-0fccb6fa2b5c +# golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 ## explicit golang.org/x/net/bpf golang.org/x/net/context @@ -1065,4 +1064,3 @@ xorm.io/xorm/names xorm.io/xorm/schemas xorm.io/xorm/tags # github.com/hashicorp/go-version => github.com/6543/go-version v1.2.4 -# github.com/microcosm-cc/bluemonday => github.com/lunny/bluemonday v1.0.5-0.20201227154428-ca34796141e8 |