Skip to content

Fix GPG ID lookup and remove hardcoded test credentials#2274

Draft
Copilot wants to merge 8 commits intomainfrom
copilot/fix-issue-2263
Draft

Fix GPG ID lookup and remove hardcoded test credentials#2274
Copilot wants to merge 8 commits intomainfrom
copilot/fix-issue-2263

Conversation

Copy link

Copilot AI commented Feb 27, 2026

GetGpgId was doing a top-down EnumerateFiles(StoreRoot, ".gpg-id") walk, which returns an arbitrary .gpg-id when multiple subdirectories have distinct GPG identities. GNU Pass resolves GPG identity by walking up from the credential file to the store root, using the nearest .gpg-id.

Changes

  • GpgPassCredentialStore.GetGpgId: Renamed to accept credentialFullPath; walks up the directory tree stopping at StoreRoot, returning the first .gpg-id found closest to the credential.
  • SerializeCredential: Passes credential.FullPath to GetGpgId.
  • Test credentials: Replaced hardcoded "letmein123" strings in new tests with Guid.NewGuid().ToString("N") to avoid triggering secret scanning.
  • New tests: GnuPassCredentialStore_ReadWriteDelete_GpgIdInSubdirectory and GnuPassCredentialStore_WriteCredential_MultipleGpgIds_UsesNearestGpgId cover subdirectory .gpg-id lookup and correct identity selection when sibling subdirs have distinct GPG IDs.
// Before: top-down, picks first found anywhere under StoreRoot
foreach (string gpgIdPath in FileSystem.EnumerateFiles(StoreRoot, ".gpg-id")) { ... }

// After: walk up from credential to StoreRoot, pick nearest
string dir = Path.GetDirectoryName(credentialFullPath);
while (dir != null)
{
    string gpgIdPath = Path.Combine(dir, ".gpg-id");
    if (FileSystem.FileExists(gpgIdPath)) { /* return it */ }
    if (FileSystem.IsSamePath(dir, StoreRoot)) break;
    dir = Path.GetDirectoryName(dir);
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • av-build-tel-api-v1.avaloniaui.net
    • Triggering command: /usr/share/dotnet/dotnet dotnet exec --runtimeconfig /home/REDACTED/.nuget/packages/avalonia.buildservices/0.0.29/tools/netstandard2.0/runtimeconfig.json /home/REDACTED/.nuget/packages/avalonia.buildservices/0.0.29/tools/netstandard2.0/Avalonia.BuildServices.Collector.dll (dns block)
  • www.apple.com
    • Triggering command: /opt/hostedtoolcache/CodeQL/2.24.2/x64/codeql/tools/linux64/java/bin/java /opt/hostedtoolcache/CodeQL/2.24.2/x64/codeql/tools/linux64/java/bin/java -jar /opt/hostedtoolcache/CodeQL/2.24.2/x64/codeql/xml/tools/xml-extractor.jar --fileList=/tmp/codeql-scratch-693b39a03efbe893/dbs/csharp/working/files-to-index16171894119560313535.list --sourceArchiveDir=/tmp/codeql-scratch-693b39a03efbe893/dbs/csharp/src --outputDir=/tmp/codeql-scratch-693b39a03efbe893/dbs/csharp/trap/csharp r.Mac/Installer.Mac.csproj (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…2263)

Co-authored-by: marekzmyslowski <1062877+marekzmyslowski@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue 2263 in the codebase Fix pass credential store: support .gpg-id in subdirectories Feb 27, 2026
…teFiles

Co-authored-by: marekzmyslowski <1062877+marekzmyslowski@users.noreply.github.com>
Copilot AI and others added 3 commits February 27, 2026 15:44
Co-authored-by: marekzmyslowski <1062877+marekzmyslowski@users.noreply.github.com>
… in GetGpgId

Co-authored-by: marekzmyslowski <1062877+marekzmyslowski@users.noreply.github.com>
Copilot AI changed the title Fix pass credential store: support .gpg-id in subdirectories Remove credentialPath parameter from GetGpgId, use StoreRoot Feb 27, 2026
// Search for a .gpg-id file anywhere under the store root.
// This handles configurations where .gpg-id is in a subdirectory
// (e.g., a git submodule) rather than the store root itself.
foreach (string gpgIdPath in FileSystem.EnumerateFiles(StoreRoot, ".gpg-id"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect. This is going to do a top-down walk from the StoreRoot looking for any .gpg-id file.

We should instead be searching UP from the full credential path looking for the closest .gpg-id. Otherwise doing the top-down walk could result in us picking an incorrect GPG identity for the given credential.

We must align the behaviour with GNU Pass.

…behaviour

Co-authored-by: marekzmyslowski <1062877+marekzmyslowski@users.noreply.github.com>
Copilot AI changed the title Remove credentialPath parameter from GetGpgId, use StoreRoot Fix GetGpgId: walk up from credential path to StoreRoot to match GNU Pass behaviour Mar 3, 2026
…asswords

Co-authored-by: marekzmyslowski <1062877+marekzmyslowski@users.noreply.github.com>
Copilot AI changed the title Fix GetGpgId: walk up from credential path to StoreRoot to match GNU Pass behaviour Fix GPG ID lookup and remove hardcoded test credentials Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants