genuinetools / audit

For auditing what collaborators, hooks, and deploy keys you have added on all your GitHub repositories.
MIT License
336 stars 27 forks source link

Possibly doesn't work with large responses? #17

Open tboerger opened 5 years ago

tboerger commented 5 years ago

If I try to run audit for the owncloud GitHub org it results in an seg fault because of an invalid memory address or nil pointer dereference issue. That's what I get from audit:

# audit -d --orgs owncloud
DEBU[0000] Getting current user...
DEBU[0000] current user is tboerger
DEBU[0000] Setting affiliations to OWNER,COLLABORATOR,ORGANIZATION_MEMBER
DEBU[0000] Getting repositories for org owncloud...
DEBU[0000] Executing GraphQL query to fetch repos under org owncloud
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x126ac1d]

goroutine 1 [running]:
main.(*GQLClient).Execute(0xc0000dfdb0, 0xc000458800, 0x71c, 0xc0004bcbd0, 0x1295a00, 0xc00041a7d0, 0x12922c0, 0xc000473920, 0x0, 0x0)
    /Users/thomas/Golang/src/github.com/genuinetools/audit/graphql.go:83 +0x43d
main.getRepositories(0x137a280, 0xc0000b6040, 0xc000128000, 0xc0000dfdb0, 0xc0004bcba0, 0x3, 0x3, 0x0, 0x0, 0x7ffeefbfe988, ...)
    /Users/thomas/Golang/src/github.com/genuinetools/audit/main.go:179 +0x32e
main.main.func2(0x137a280, 0xc0000b6040, 0xc0000120f0, 0x0, 0x0, 0x0, 0x0)
    /Users/thomas/Golang/src/github.com/genuinetools/audit/main.go:135 +0x826
github.com/genuinetools/audit/vendor/github.com/genuinetools/pkg/cli.(*Program).run(0xc000112000, 0x137a340, 0xc0000beb70, 0xc0000120c0, 0x4, 0x4, 0x10ad9fd, 0x13134b4)
    /Users/thomas/Golang/src/github.com/genuinetools/audit/vendor/github.com/genuinetools/pkg/cli/cli.go:179 +0x253
github.com/genuinetools/audit/vendor/github.com/genuinetools/pkg/cli.(*Program).Run(0xc000112000)
    /Users/thomas/Golang/src/github.com/genuinetools/audit/vendor/github.com/genuinetools/pkg/cli/cli.go:89 +0x61
main.main()
    /Users/thomas/Golang/src/github.com/genuinetools/audit/main.go:153 +0x3f2

After that I tried to find more information, I moved the errors parsing above the data parsing, and found this error message via Printf:

Something went wrong while executing your query. This may be the result of a timeout, or it could be a GitHub bug. Please include `E7C0:116E:271B82:432CFE:5D78ACF1` when reporting this issue.

So far for my debugging, but I have no idea how this issue could be resolved. Maybe somebody of you got an idea?

issue-label-bot[bot] commented 5 years ago

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.98. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

ryjones commented 5 years ago

@tboerger The issue is near line 72 here: https://github.com/genuinetools/audit/blob/c6b2f066cbf97c64deba9eaeba76b7c2f7fcb8c5/graphql.go#L72

the issue is the response object returns contains a "502 Bad Gateway" Status and a 502 StatusCode, but the err is void.

Screen Shot 2019-09-15 at 10 35 35 AM

I suspect this is a bug in how net handles this case. I set up a debugging environment but I couldn't get the breakpoint to fire and I stopped digging in

ryjones commented 5 years ago

@shahidhk opinons? is this a bug in graphql.go, or in the underlying code?

tboerger commented 5 years ago

I can audit all my other orgs, but especially the one I want to fix and cleanup doesn't work. Hopefully you can fix this issue :)