In internal/vault/vault.go, the NumSecrets() method counts secrets by looking for non-directory files (excluding current) directly under each secret's directory:
However, the actual directory structure of a secret is:
secrets.d/<name>/
current (file - version pointer)
versions/ (directory)
20240101.001/ (directory with actual data)
The only direct children of a secret directory are current (excluded by the filter) and versions (excluded by !vFile.IsDir()). This means the condition is never true and NumSecrets() always returns 0.
Impact
UnlockersRemove uses NumSecrets() to check if removing the last unlocker is safe. Since it always returns 0, users can always remove the last unlocker without --force, even when secrets exist.
The info command may show incorrect secret counts.
Fix
Should check if the versions subdirectory contains entries, or simply check for the existence of the current file.
## Bug
In `internal/vault/vault.go`, the `NumSecrets()` method counts secrets by looking for non-directory files (excluding `current`) directly under each secret's directory:
```go
for _, vFile := range versionFiles {
if !vFile.IsDir() && vFile.Name() != "current" {
count++
break
}
}
```
However, the actual directory structure of a secret is:
```
secrets.d/<name>/
current (file - version pointer)
versions/ (directory)
20240101.001/ (directory with actual data)
```
The only direct children of a secret directory are `current` (excluded by the filter) and `versions` (excluded by `!vFile.IsDir()`). This means the condition is **never true** and `NumSecrets()` always returns 0.
## Impact
- `UnlockersRemove` uses `NumSecrets()` to check if removing the last unlocker is safe. Since it always returns 0, users can always remove the last unlocker without `--force`, even when secrets exist.
- The `info` command may show incorrect secret counts.
## Fix
Should check if the `versions` subdirectory contains entries, or simply check for the existence of the `current` file.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Bug
In
internal/vault/vault.go, theNumSecrets()method counts secrets by looking for non-directory files (excludingcurrent) directly under each secret's directory:However, the actual directory structure of a secret is:
The only direct children of a secret directory are
current(excluded by the filter) andversions(excluded by!vFile.IsDir()). This means the condition is never true andNumSecrets()always returns 0.Impact
UnlockersRemoveusesNumSecrets()to check if removing the last unlocker is safe. Since it always returns 0, users can always remove the last unlocker without--force, even when secrets exist.infocommand may show incorrect secret counts.Fix
Should check if the
versionssubdirectory contains entries, or simply check for the existence of thecurrentfile.