sonatype-nexus-community / nancy

A tool to check for vulnerabilities in your Golang dependencies, powered by Sonatype OSS Index
Apache License 2.0
564 stars 74 forks source link

Exit purge #137

Closed bhamail closed 4 years ago

bhamail commented 4 years ago

Minimize places where we call os.Exit(), in preparation for conversion to using Cobra #134

I think this is ready for review.

I was a little concerned about the CI build failing in the logger_test.go. Seemed to be an unrelated change. Rerunning the CI build and it just passed. Boggle. We should keep an eye out in case this is a heisenbug.

BTW, we may have a decision point regarding "--command, -flag" syntax in the near future.

Fixes #78

cc @bhamail / @DarthHater

DarthHater commented 4 years ago

I'm sure that you still are cranking, but when I run ./nancy iq I get a SIGSEGV: (after usage).

$ ./nancy iq
Usage:
        go list -m all | nancy iq [options]

Options:
  -application string
        Specify application ID for request
  -max-retries int
        Specify maximum number of tries to poll Nexus IQ Server (default 300)
  -server-url string
        Specify Nexus IQ Server URL/port (default "http://localhost:8070")
  -stage string
        Specify stage for application (default "develop")
  -token string
        Specify Nexus IQ token/password for request (default "admin123")
  -user string
        Specify Nexus IQ username for request (default "admin")
  -v    Set log level to Info
  -vv
        Set log level to Debug
  -vvv
        Set log level to Trace
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x14fc90f]

goroutine 1 [running]:
github.com/sonatype-nexus-community/nancy/customerrors.ErrorExit.Error(0x0, 0x0, 0x0, 0x0, 0x2, 0xc000213710, 0xc0001a3a18)
        /go/src/github.com/sonatype-nexus-community/nancy/customerrors/error.go:30 +0x3f
github.com/sirupsen/logrus.(*JSONFormatter).Format(0xc000110040, 0xc0002209a0, 0x10703d2, 0x2, 0x0, 0x1056779, 0xc0001a3d78)
        /go/pkg/mod/github.com/sirupsen/logrus@v1.5.0/json_formatter.go:67 +0x1cd
github.com/sirupsen/logrus.(*Entry).write(0xc0002209a0)
        /go/pkg/mod/github.com/sirupsen/logrus@v1.5.0/entry.go:277 +0x7c
github.com/sirupsen/logrus.Entry.log(0xc00013e070, 0xc000213710, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /go/pkg/mod/github.com/sirupsen/logrus@v1.5.0/entry.go:253 +0x1c2
github.com/sirupsen/logrus.(*Entry).Log(0xc000220930, 0x2, 0xc0001a3f58, 0x1, 0x1)
        /go/pkg/mod/github.com/sirupsen/logrus@v1.5.0/entry.go:289 +0xeb
github.com/sirupsen/logrus.(*Entry).Error(...)
        /go/pkg/mod/github.com/sirupsen/logrus@v1.5.0/entry.go:318
main.main()
        /go/src/github.com/sonatype-nexus-community/nancy/main.go:64 +0x20b
zendern commented 4 years ago

I'm sure that you still are cranking, but when I run ./nancy iq I get a SIGSEGV: (after usage).

$ ./nancy iq
Usage:
        go list -m all | nancy iq [options]

Options:
  -application string
        Specify application ID for request
  -max-retries int
        Specify maximum number of tries to poll Nexus IQ Server (default 300)
  -server-url string
        Specify Nexus IQ Server URL/port (default "http://localhost:8070")
  -stage string
        Specify stage for application (default "develop")
  -token string
        Specify Nexus IQ token/password for request (default "admin123")
  -user string
        Specify Nexus IQ username for request (default "admin")
  -v    Set log level to Info
  -vv
        Set log level to Debug
  -vvv
        Set log level to Trace
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x14fc90f]

goroutine 1 [running]:
github.com/sonatype-nexus-community/nancy/customerrors.ErrorExit.Error(0x0, 0x0, 0x0, 0x0, 0x2, 0xc000213710, 0xc0001a3a18)
        /go/src/github.com/sonatype-nexus-community/nancy/customerrors/error.go:30 +0x3f
github.com/sirupsen/logrus.(*JSONFormatter).Format(0xc000110040, 0xc0002209a0, 0x10703d2, 0x2, 0x0, 0x1056779, 0xc0001a3d78)
        /go/pkg/mod/github.com/sirupsen/logrus@v1.5.0/json_formatter.go:67 +0x1cd
github.com/sirupsen/logrus.(*Entry).write(0xc0002209a0)
        /go/pkg/mod/github.com/sirupsen/logrus@v1.5.0/entry.go:277 +0x7c
github.com/sirupsen/logrus.Entry.log(0xc00013e070, 0xc000213710, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /go/pkg/mod/github.com/sirupsen/logrus@v1.5.0/entry.go:253 +0x1c2
github.com/sirupsen/logrus.(*Entry).Log(0xc000220930, 0x2, 0xc0001a3f58, 0x1, 0x1)
        /go/pkg/mod/github.com/sirupsen/logrus@v1.5.0/entry.go:289 +0xeb
github.com/sirupsen/logrus.(*Entry).Error(...)
        /go/pkg/mod/github.com/sirupsen/logrus@v1.5.0/entry.go:318
main.main()
        /go/src/github.com/sonatype-nexus-community/nancy/main.go:64 +0x20b

re: this Hopefully Jeffry will NOT look at this over the weekend. 😄 @bhamail I believe the answer is yeah not going to happen 😝

bhamail commented 4 years ago

re: this Hopefully Jeffry will NOT look at this over the weekend. 😄 @bhamail I believe the answer is yeah not going to happen 😝

The was a snowballs chance.... ;)

Fix issue with nil Err object causing seg fault: 24f46c0

bhamail commented 4 years ago

no objections, and some implicit approval, so merging this puppy in a bit.

bhamail commented 4 years ago

CAPS LOCK FRIDAY!