italia/publiccode-parser-go

Segmentation fault when remote-base-url is not a repo

Closed this issue · 0 comments

The crawler crashes when -remote-base-url points to a host with an expired TLS certificate: is not a repo

$ docker run -i italia/publiccode-parser-go -export /dev/stdout -remote-base-url https://expired.badssl.com/ /dev/stdin < publiccode.yml

2020/09/24 14:55:00 Warning: go-vcsurl failed to detect repo for https://expired.badssl.com/
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x4e7eea]

goroutine 1 [running]:
net/url.(*URL).String(0x0, 0x30, 0xc00040f850)
	/usr/local/go/src/net/url/url.go:813 +0x4a
github.com/italia/publiccode-parser-go.(*Parser).decodeString(0xc0003d0380, 0xc00056194b, 0x3, 0xc000cfd020, 0x28, 0x0, 0x0)
	/go/src/keys.go:86 +0x269b
github.com/italia/publiccode-parser-go.(*Parser).decoderec(0xc0003d0380, 0x0, 0x0, 0xc000067890, 0x0, 0xc0003d8000, 0x301e)
	/go/src/parser.go:150 +0xe52
github.com/italia/publiccode-parser-go.(*Parser).Parse(0xc0003d0380, 0xc0003d8000, 0x301e, 0x3e00, 0x3e00, 0x0)
	/go/src/parser.go:75 +0x234
github.com/italia/publiccode-parser-go.(*Parser).ParseFile(0xc0003d0380, 0x7ffe57c7bf19, 0xa, 0x0, 0x0)
	/go/src/parser.go:92 +0x88
main.main()
	/go/src/pcvalidate/pcvalidate.go:73 +0x412
$ docker run -i italia/publiccode-parser-go -export /dev/stdout -remote-base-url https://github.com/italia /dev/stdin < publiccode.yml
2020/09/24 15:01:04 Warning: go-vcsurl failed to detect repo for https://github.com/italia
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x4e7eea]

goroutine 1 [running]:
net/url.(*URL).String(0x0, 0x30, 0xc000439850)
	/usr/local/go/src/net/url/url.go:813 +0x4a
github.com/italia/publiccode-parser-go.(*Parser).decodeString(0xc0003fc380, 0xc000560dab, 0x3, 0xc00059f170, 0x28, 0x0, 0x0)
	/go/src/keys.go:86 +0x269b
github.com/italia/publiccode-parser-go.(*Parser).decoderec(0xc0003fc380, 0x0, 0x0, 0xc000067890, 0x0, 0xc000404000, 0x301e)
	/go/src/parser.go:150 +0xe52
github.com/italia/publiccode-parser-go.(*Parser).Parse(0xc0003fc380, 0xc000404000, 0x301e, 0x3e00, 0x3e00, 0x0)
	/go/src/parser.go:75 +0x234
github.com/italia/publiccode-parser-go.(*Parser).ParseFile(0xc0003fc380, 0x7ffdde266f19, 0xa, 0x0, 0x0)
	/go/src/parser.go:92 +0x88
main.main()
	/go/src/pcvalidate/pcvalidate.go:73 +0x412