-
Notifications
You must be signed in to change notification settings - Fork 2
fix(gpg): agent forwarding #790
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
Changes from all commits
22dcb89
7b56cc1
c73c7dd
bcdba35
3de4fb5
65136f6
d15fb03
806cc89
298c6f2
39c032a
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 |
|---|---|---|
|
|
@@ -22,6 +22,8 @@ import ( | |
| const ( | ||
| osWindows = "windows" | ||
|
|
||
| gpgTestKeyFingerprint = "07F681B9FD6C3411F679BFD1F51769DB572DDD3F" | ||
|
|
||
|
Comment on lines
+25
to
+26
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 | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Description: Check whether a static private key fixture is committed to the repo.
fd -i 'gpg-private' tests/ssh/testdataRepository: devsy-org/devsy Length of output: 259 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf 'Repo files count: '
git ls-files | wc -l
printf '\nCandidate ssh.go files:\n'
fd -i '^ssh\.go$|testdata$|gpg-private' . || true
printf '\nMatch gpg-private/fingerprint/gpg-forwarding:\n'
rg -n "gpg-private|gpg-forwarding|gpgTestKeyFingerprint|ImportGpgKey" . || trueRepository: devsy-org/devsy Length of output: 2428 Don’t commit the GPG test private key fixture.
🧰 Tools🪛 Betterleaks (1.6.1)[high] 25-25: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||
| envSSHAuthSock = "SSH_AUTH_SOCK" | ||
|
|
||
| sshOptStrictHostKeyCheckingNo = "StrictHostKeyChecking=no" | ||
|
|
@@ -120,6 +122,43 @@ var _ = ginkgo.Describe("devsy ssh test suite", ginkgo.Label("ssh"), ginkgo.Orde | |
| }, | ||
| ) | ||
|
|
||
| ginkgo.It( | ||
| "should expose the host GPG secret key in the container via agent forwarding", | ||
| ginkgo.Label("gpg"), | ||
| ginkgo.SpecTimeout(framework.TimeoutModerate()), | ||
| func(ctx ginkgo.SpecContext) { | ||
| if runtime.GOOS == osWindows { | ||
| ginkgo.Skip("skipping on windows") | ||
| } | ||
|
|
||
| tempDir, err := framework.CopyToTempDir("tests/ssh/testdata/gpg-forwarding") | ||
| framework.ExpectNoError(err) | ||
|
|
||
| f := framework.NewDefaultFramework(initialDir + "/bin") | ||
| _ = f.DevsyProviderAdd(ctx, "docker") | ||
| err = f.DevsyProviderUse(ctx, "docker") | ||
| framework.ExpectNoError(err) | ||
|
|
||
| ginkgo.DeferCleanup(func(cleanupCtx context.Context) { | ||
| _ = f.DevsyWorkspaceDelete(cleanupCtx, tempDir) | ||
| framework.CleanupTempDir(initialDir, tempDir) | ||
| }) | ||
|
|
||
| ginkgo.GinkgoT().Setenv("GNUPGHOME", ginkgo.GinkgoT().TempDir()) | ||
| framework.ExpectNoError( | ||
| framework.ImportGpgKey(filepath.Join(tempDir, "gpg-private.key")), | ||
| ) | ||
|
|
||
| err = f.DevsyUp(ctx, tempDir, names.Flag(names.SSHGPGForwarding)) | ||
| framework.ExpectNoError(err) | ||
|
|
||
| sshCtx, cancelSSH := context.WithDeadline(ctx, time.Now().Add(30*time.Second)) | ||
| defer cancelSSH() | ||
| err = f.DevsySSHGpgSecretKeyForwarded(sshCtx, tempDir, gpgTestKeyFingerprint) | ||
| framework.ExpectNoError(err) | ||
| }, | ||
| ) | ||
|
|
||
| ginkgo.It( | ||
| "should set up git SSH signature helper and sign a commit", | ||
| ginkgo.SpecTimeout(framework.TimeoutLong()), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| { "image": "ghcr.io/devsy-org/test-images/base:ubuntu" } | ||
| { "image": "ghcr.io/devsy-org/test-images/base:ubuntu", "remoteUser": "vscode" } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| { | ||
| "name": "Go", | ||
| "image": "ghcr.io/devsy-org/test-images/go:1" | ||
| "image": "ghcr.io/devsy-org/test-images/go:1", | ||
| "remoteUser": "vscode" | ||
| } |
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 | 🔴 Critical | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: devsy-org/devsy
Length of output: 153
🏁 Script executed:
Repository: devsy-org/devsy
Length of output: 3381
🏁 Script executed:
Repository: devsy-org/devsy
Length of output: 16493
Reverse-forward mapping order is correct for GPG forwarding.
ParsePortSpecassigns a 2-part stringA:Btomapping.Host.Address = Aandmapping.Container.Address = B, so the currentgpg.ContainerSocketPath+":"+gpgExtraSocketPathwould bindHost = /tmp/S.gpg-agentandContainer = detected host socket path, which is the wrong direction. Keep the suggested orderinggpgExtraSocketPath+":"+gpg.ContainerSocketPathif this is still present.🤖 Prompt for AI Agents