-
Notifications
You must be signed in to change notification settings - Fork 357
chore(test): Avoid printing test-credentials #1282
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,7 @@ type Repo struct { | |
| repoName string | ||
|
|
||
| cloneDir *os.Root | ||
| transport Transport | ||
| clonedOver Transport | ||
| } | ||
|
|
||
| // GetRepoHttpURL returns the HTTPS clone URL reachable from inside the cluster. | ||
|
|
@@ -54,10 +54,10 @@ func (r Repo) getRepoSshURLLocal() string { | |
| return fmt.Sprintf("ssh://%s@127.0.0.1:%d/%s/%s.git", giteaSSHLogin, r.server.localSSHPort, r.server.httpUsername, r.repoName) | ||
| } | ||
|
|
||
| func (r *Repo) Clone(t Transport) (cleanup func(), err error) { | ||
| r.transport = t | ||
| func (r *Repo) Clone(transport Transport) (cleanup func(), err error) { | ||
| r.clonedOver = transport | ||
|
|
||
| if t == TransportSSH { | ||
| if transport == TransportSSH { | ||
| if _, err := r.server.getSSHKeyFile(); err != nil { | ||
| return nil, err | ||
| } | ||
|
|
@@ -80,11 +80,11 @@ func (r *Repo) Clone(t Transport) (cleanup func(), err error) { | |
| } | ||
|
|
||
| cloneURL := r.getRepoSshURLLocal() | ||
| if t == TransportHTTPS { | ||
| if transport == TransportHTTPS { | ||
| cloneURL = r.getRepoHttpURLWithCredentials() | ||
| } | ||
|
|
||
| GinkgoWriter.Println("Cloning repo:", cloneURL) | ||
| GinkgoWriter.Println("Cloning repo %q over %s", r.repoName, transport) | ||
|
|
||
| out, err := r.git("clone", cloneURL, ".") | ||
| if err != nil { | ||
|
|
@@ -149,7 +149,7 @@ func (r *Repo) git(args ...string) (string, error) { | |
|
|
||
| cmd := exec.Command("git", args...) // #nosec G204 // Binary is specified by literal | ||
| cmd.Dir = r.cloneDir.Name() | ||
| if r.transport == TransportHTTPS { | ||
| if r.clonedOver == TransportHTTPS { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift 🧩 Analysis chain🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
file="test/openshift/e2e/ginkgo/fixture/gitserver/repo.go"
rg -n -C 6 'getRepoHttpURLWithCredentials|httpPassword|TransportHTTPS|GIT_SSL_NO_VERIFY|GIT_SSL_CAINFO' "$file"
rg -n -C 4 'certificate|CAINFO|TLS|HTTPS|httpPassword' test/openshift/e2e/ginkgo/fixture/gitserver --glob '*.go'Repository: redhat-developer/gitops-operator Length of output: 20783 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
sed -n '1,175p' test/openshift/e2e/ginkgo/fixture/gitserver/repo.go
sed -n '1,125p' test/openshift/e2e/ginkgo/fixture/gitserver/certs.go
sed -n '100,175p;300,335p;400,440p' test/openshift/e2e/ginkgo/fixture/gitserver/server.go
sed -n '325,355p;435,462p' test/openshift/e2e/ginkgo/parallel/1-141_source_hydrator.goRepository: redhat-developer/gitops-operator Length of output: 13927 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
rg -n -C 3 'GetCACert|GIT_SSL_NO_VERIFY|httpRepoURLPrefix|git config|http\.ssl|sslCAInfo|SSL_CAINFO|ca\.crt|CABundle' \
test/openshift/e2e/ginkgo/fixture/gitserver test/openshift/e2e/ginkgo/parallelRepository: redhat-developer/gitops-operator Length of output: 5839 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
sed -n '1,175p' test/openshift/e2e/ginkgo/fixture/gitserver/repo.go
sed -n '1,125p' test/openshift/e2e/ginkgo/fixture/gitserver/certs.go
sed -n '100,175p;300,335p;400,440p' test/openshift/e2e/ginkgo/fixture/gitserver/server.go
sed -n '325,355p;435,462p' test/openshift/e2e/ginkgo/parallel/1-141_source_hydrator.go
printf '\n--- TLS/Git configuration references ---\n'
rg -n -C 3 'GetCACert|GIT_SSL_NO_VERIFY|httpRepoURLPrefix|git config|http\.ssl|sslCAInfo|SSL_CAINFO|ca\.crt|CABundle' \
test/openshift/e2e/ginkgo/fixture/gitserver test/openshift/e2e/ginkgo/parallelRepository: redhat-developer/gitops-operator Length of output: 19638 Security Misconfiguration (CWE-295): Improper Certificate Validation Reachability: Internal · Exploitability: Difficult Do not disable certificate verification for credentialed HTTPS Git commands.
🤖 Prompt for AI Agents |
||
| cmd.Env = append(os.Environ(), "GIT_SSL_NO_VERIFY=true") | ||
| } else { | ||
| sshKeyFile, err := r.server.getSSHKeyFile() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: redhat-developer/gitops-operator
Length of output: 2577
🏁 Script executed:
Repository: redhat-developer/gitops-operator
Length of output: 12218
🌐 Web query:
github.com/onsi/ginkgo/v2 v2.32.0 GinkgoWriter Println implementation💡 Result:
In Ginkgo v2, the GinkgoWriter.Println(a...any) method is a convenience function that provides an equivalent implementation to calling fmt.Fprintln(GinkgoWriter, a...) [1][2][3]. By design, GinkgoWriter buffers output captured during the execution of a test [4][3]. This output is only emitted to standard output if the test fails, unless the test suite is running in verbose mode (using the ginkgo -v flag), in which case the output is streamed in real-time [4][5][3]. Key characteristics of this implementation include: Convenience: It serves as a wrapper around the standard library fmt.Fprintln function, specifically targeting the GinkgoWriter instance [2][3]. Buffering and Emission: It adheres to the established behavior of GinkgoWriter: Standard execution: Output is captured and suppressed unless a failure occurs [4][3]. Verbose execution (ginkgo -v): Output is immediately streamed to stdout [4][3]. Tee functionality: Any data written via Println is also immediately forwarded to any writers registered via the GinkgoWriter.TeeTo(writer) method, regardless of the test's pass/fail status [1][2][3].
Citations:
Use
Printffor the formatted clone log.GinkgoWriter.Printlndelegates tofmt.Fprintln, so it prints%qand%sliterally. UseGinkgoWriter.Printf("Cloning repo %q over %s\n", r.repoName, transport)or pass separate arguments toPrintln.🤖 Prompt for AI Agents