Skip to content

Commit

Permalink
fix: removed new lines in debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
mgyorke committed May 23, 2024
1 parent a328961 commit 2248f70
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
16 changes: 8 additions & 8 deletions cliv2/internal/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (p *WrapperProxy) checkBasicCredentials(user, password string) bool {
func (p *WrapperProxy) HandleConnect(req string, ctx *goproxy.ProxyCtx) (*goproxy.ConnectAction, string) {
basic := auth.BasicConnect("", p.checkBasicCredentials)
action, str := basic.HandleConnect(req, ctx)
p.DebugLogger.Println("HandleConnect - basic authentication result: ", action, str)
p.DebugLogger.Print("HandleConnect - basic authentication result: ", action, str)

if action == goproxy.OkConnect {
action, str = goproxy.AlwaysMitm.HandleConnect(req, ctx)
Expand All @@ -183,15 +183,15 @@ func (p *WrapperProxy) Start() error {

p.httpServer = proxyServer

p.DebugLogger.Println("starting proxy")
p.DebugLogger.Print("starting proxy")
address := "127.0.0.1:0"
l, err := net.Listen("tcp", address)
if err != nil {
return err
}

p.port = l.Addr().(*net.TCPAddr).Port
p.DebugLogger.Println("Wrapper proxy is listening on port: ", p.port)
p.DebugLogger.Print("Wrapper proxy is listening on port: ", p.port)

go func() {
_ = p.httpServer.Serve(l) // this blocks until the server stops and gives you an error which can be ignored
Expand All @@ -213,13 +213,13 @@ func (p *WrapperProxy) Stop() {
func (p *WrapperProxy) Close() {
p.Stop()

p.DebugLogger.Println("deleting temp cert file:", p.CertificateLocation)
p.DebugLogger.Print("deleting temp cert file:", p.CertificateLocation)
err := os.Remove(p.CertificateLocation)
if err != nil {
p.DebugLogger.Println("failed to delete cert file")
p.DebugLogger.Println(err)
p.DebugLogger.Print("failed to delete cert file")
p.DebugLogger.Print(err)
} else {
p.DebugLogger.Println("deleted temp cert file:", p.CertificateLocation)
p.DebugLogger.Print("deleted temp cert file:", p.CertificateLocation)
}
}

Expand All @@ -242,7 +242,7 @@ func setCAFromBytes(certPEMBlock []byte, keyPEMBlock []byte) error {
func (p *WrapperProxy) SetUpstreamProxyAuthentication(mechanism httpauth.AuthenticationMechanism) {
if mechanism != p.authMechanism {
p.authMechanism = mechanism
p.DebugLogger.Printf("Enabled Proxy Authentication Mechanism: %s\n", httpauth.StringFromAuthenticationMechanism(p.authMechanism))
p.DebugLogger.Printf("Enabled Proxy Authentication Mechanism: %s", httpauth.StringFromAuthenticationMechanism(p.authMechanism))
}

if httpauth.IsSupportedMechanism(p.authMechanism) { // since Negotiate is not covered by the go http stack, we skip its proxy handling and inject a custom Handling via the DialContext
Expand Down
12 changes: 6 additions & 6 deletions cliv2/pkg/basic_workflows/legacycli.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ func legacycliWorkflow(
proxyAuthenticationMechanism := httpauth.AuthenticationMechanismFromString(proxyAuthenticationMechanismString)
analyticsDisabled := config.GetBool(configuration.ANALYTICS_DISABLED)

debugLogger.Println("Arguments:", args)
debugLogger.Println("Use StdIO:", useStdIo)
debugLogger.Println("Working directory:", workingDirectory)
debugLogger.Print("Arguments:", args)
debugLogger.Print("Use StdIO:", useStdIo)
debugLogger.Print("Working directory:", workingDirectory)

// init cli object
var cli *cliv2.CLI
Expand Down Expand Up @@ -109,9 +109,9 @@ func legacycliWorkflow(
if _, ok := envMap[constants.SNYK_OAUTH_ACCESS_TOKEN_ENV]; !ok {
env := []string{constants.SNYK_OAUTH_ACCESS_TOKEN_ENV + "=randomtoken"}
cli.AppendEnvironmentVariables(env)
debugLogger.Println("Authentication: Oauth token handling delegated to Extensible CLI.")
debugLogger.Print("Authentication: Oauth token handling delegated to Extensible CLI.")
} else {
debugLogger.Println("Authentication: Using oauth token from Environment Variable.")
debugLogger.Print("Authentication: Using oauth token from Environment Variable.")
}
}
}
Expand Down Expand Up @@ -161,7 +161,7 @@ func legacycliWorkflow(
errWriter.Flush()

if isDebug {
debugLogger.Println(errBuffer.String())
debugLogger.Print(errBuffer.String())
}

contentType := "text/plain"
Expand Down

0 comments on commit 2248f70

Please sign in to comment.