Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silence logs #18

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions internal/gateways/ebizkaia.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"crypto/tls"
"errors"
"fmt"
"os"
"slices"

"github.com/go-resty/resty/v2"
Expand Down Expand Up @@ -52,18 +53,17 @@
func newEbizkaia(env Environment, tlsConfig *tls.Config) *EBizkaiaConn {
c := new(EBizkaiaConn)
c.client = resty.New()

switch env {
case EnvironmentProduction:
c.client = c.client.SetBaseURL(eBizkaiaProductionBaseURL)
c.client.SetDebug(true)
tlsConfig.InsecureSkipVerify = true
c.client.SetBaseURL(eBizkaiaProductionBaseURL)
default:
c.client = c.client.SetBaseURL(eBizkaiaTestingBaseURL)
c.client.SetDebug(true)
tlsConfig.InsecureSkipVerify = true
c.client.SetBaseURL(eBizkaiaTestingBaseURL)
}

tlsConfig.InsecureSkipVerify = true

Check failure

Code scanning / CodeQL

Disabled TLS certificate check High

InsecureSkipVerify should not be used in production code.

Copilot Autofix AI 20 days ago

To fix the problem, we need to ensure that InsecureSkipVerify is not set to true in production environments. Instead, we should configure the TLS settings properly to trust the necessary certificates. This can be achieved by conditionally setting InsecureSkipVerify based on the environment.

  1. Modify the newEbizkaia function to only set InsecureSkipVerify to true in non-production environments.
  2. Ensure that the TLS configuration is properly set up to trust the required certificates in production.
Suggested changeset 1
internal/gateways/ebizkaia.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/internal/gateways/ebizkaia.go b/internal/gateways/ebizkaia.go
--- a/internal/gateways/ebizkaia.go
+++ b/internal/gateways/ebizkaia.go
@@ -63,3 +63,5 @@
 
-	tlsConfig.InsecureSkipVerify = true
+	if env != EnvironmentProduction {
+		tlsConfig.InsecureSkipVerify = true
+	}
 	c.client.SetTLSClientConfig(tlsConfig)
EOF
@@ -63,3 +63,5 @@

tlsConfig.InsecureSkipVerify = true
if env != EnvironmentProduction {
tlsConfig.InsecureSkipVerify = true
}
c.client.SetTLSClientConfig(tlsConfig)
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
c.client.SetTLSClientConfig(tlsConfig)
c.client.SetDebug(os.Getenv("DEBUG") == "true")

return c
}
Expand Down
Loading