Commit graph

27 commits

Author SHA1 Message Date
patzielinski
cbf0620915
Merge pull request #1525 from PratGit1606/deps/bump-all-with-gitsign
Deps/bump all with gitsign
2026-08-18 15:46:15 +00:00
Pat Zielinski
7540d208cf deps: Bump gitsign
Signed-off-by: Pat Zielinski <git@patzielinski.com>
Signed-off-by: PratGit1606 <prathamgithub16@gmail.com>
2026-08-17 15:16:10 -07:00
Paulo Gomes
68873bd844
rsl, tuf: stricter validation for entry and metadata fields
Reject line breaks in RSL entry ref names and upstream repository fields
on write. Restrict Person custom metadata keys to a conservative
character set.

Assisted-by: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Paulo Gomes <paulo@entire.io>
2026-08-13 23:13:11 +01:00
Paulo Gomes
69f306d2eb
test: add fuzz tests for decoding paths
Cover githash, RSL packet splitting, DSSE base64, TUF metadata
(root/delegations/hooks/enums), sets, GPG key loading, sigstore
bool decoding, and reference authorization validation.

Signed-off-by: Paulo Gomes <paulo@entire.io>
2026-08-05 09:04:32 +01:00
Paulo Gomes
4a53c1b214
refactor: standardize on githash.Hash
Signed-off-by: Paulo Gomes <paulo@entire.io>
2026-08-03 21:27:52 +01:00
Paulo Gomes
9e269f46fb
Introduce gitstore.Storer and make gittuf's core dependency-light
Restructure storage so gittuf verification can run over backends other
than the git binary (e.g. go-git):

- pkg/githash: concrete Git object hash, stdlib-only.
  gitinterface.Hash aliases it.
- pkg/gitstore: the single Storer interface (24 methods) that all
  storage consumers program against, plus the shared
  ErrReferenceNotFound sentinel. *gitinterface.Repository satisfies it
  structurally (compile-time asserted). Also defines ConfigKey, the
  canonical type for the Git config settings gittuf reads.
- pkg/rsl (from internal/rsl): entry model, codec, and readers over
  gitstore.Storer; zero gitinterface/sigstore dependencies. rsl.Hash
  aliases githash.Hash; nil is the unset-Hash sentinel and IsZero
  matches nil and empty as well as both format zeros (no
  object-format-unaware ZeroHash). Entry commits (empty tree on the
  RSL ref) are owned by the package; no storer adapter.
- internal/signerverifier/gitobject: verifies commit/tag signatures
  over (payload, signature) bytes, Rekor URL as an option. The storage
  half is Repository.GetObjectSignature. Removes sigstore, cosign, and
  gitsign from gitinterface's dependency tree.
- internal/propagation: propagation workflow, moved off pkg/rsl's
  public API (its tuf directive types are internal).
- internal/{attestations,cache,policy}: storage via gitstore.Storer;
  tree writing via WriteTree(blobs, subtrees).

Breaking changes to pkg/gitinterface: Repository.VerifySignature and
the verification sentinels are removed (use gitobject.Verify);
ErrReferenceNotFound now aliases gitstore's. Repository.GetGitConfig
(which returned the whole config map) is replaced by
LookupConfig(gitstore.ConfigKey), returning a single setting's value.
Policy resolves the Rekor override from git config once per
verification and extracts signed payloads once per object instead of
per key attempt.

Assisted-by: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Paulo Gomes <paulo@entire.io>
2026-08-03 21:27:49 +01:00
Paulo Gomes
47e4b5258c
gitinterface: ignore refs/replace/ in git invocations
Signed-off-by: Paulo Gomes <paulo@entire.io>
2026-07-24 09:51:15 +01:00
Pat Zielinski
30a8de0d5c
pkg: Fix gitinterface test
Signed-off-by: Pat Zielinski <git@patzielinski.com>
2026-07-23 16:33:40 -04:00
Aditya Sirish A Yelgundhalli
7c69da80d4
Merge pull request #1463 from git-pkgs/gitinterface-no-chdir
pkg/gitinterface: remove os.Chdir; set cmd.Dir on the executor instead
2026-07-23 12:53:49 -04:00
Aditya Sirish A Yelgundhalli
1ded25b6fb
Merge pull request #1462 from git-pkgs/detect-dot-git-bare
pkg/gitinterface: open go-git with DetectDotGit:false
2026-07-23 12:50:27 -04:00
Paulo Gomes
ce6f2bc29e
Block use of extensions.compatObjectFormat
Signed-off-by: Paulo Gomes <paulo@entire.io>
2026-07-16 23:03:24 +01:00
Paulo Gomes
5f5f5508e3
feat(sha256): support SHA-256 object format
Make gittuf hash-algorithm aware so it operates on SHA-256 repositories:

- gitinterface.Repository detects its object format (via
  `git rev-parse --show-object-format`) and exposes GetObjectFormat and a
  per-repo ZeroHash. GetReference returns the format-appropriate zero hash
  so ref updates to new refs succeed in SHA-256 repositories.
- Commit and tag signing/verification use the `gpgsig-sha256` header for
  SHA-256 objects (go-git's SignatureSHA256), matching Git's behavior. The
  verification field is chosen by the object's OID length. Fixes verify-ref
  failing on Git-signed SHA-256 RSL entries.
- git-remote-gittuf negotiates object-format from the repository instead of
  hardcoding sha1, and uses the repo-appropriate zero hash for ref tips.
- Test helpers can create SHA-256 repositories; gitinterface, rsl, policy,
  and experimental/gittuf suites now run under both formats, plus an
  end-to-end Git-signed record+verify test.

Assisted-by: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: Paulo Gomes <paulo@entire.io>
2026-07-16 23:03:18 +01:00
Andrew Nesbitt
ac08370b1e
pkg/gitinterface: isolate TestCanSign from host git config
TestCanSign/explicit_ssh,_no_key sets gpg.format=ssh in a temp repo and
expects CanSign() to fail because no user.signingkey is set. On a host
with user.signingkey in ~/.gitconfig, the temp repo inherits the key via
scoped config and the test passes CanSign() unexpectedly.

The existing comment at the top of TestCanSign acknowledges this and
skips the assertion as a result. Point GIT_CONFIG_GLOBAL and
GIT_CONFIG_SYSTEM at /dev/null for the duration of the test instead, so
all subtests can run regardless of the host's signing config.

Signed-off-by: Andrew Nesbitt <andrewnez@gmail.com>
2026-06-29 17:14:01 +01:00
Andrew Nesbitt
12ab1b37ac
pkg/gitinterface: remove os.Chdir; set cmd.Dir on the executor instead
LoadRepository did os.Chdir(repositoryPath) to run 'git rev-parse
--git-dir', and Status/RestoreWorktree/tree-restore did the same to run
worktree-relative commands. os.Chdir is process-global; concurrent
LoadRepository calls for different paths could each resolve the wrong
gitDirPath.

Adds executor.withDir(dir) which sets cmd.Dir. LoadRepository now runs
'git rev-parse --absolute-git-dir' with cmd.Dir set to the repository
path (and EvalSymlinks the result to match prior behaviour). The
worktree commands use withDir(worktree).

TestLoadRepositoryConcurrent runs 20 pairs of LoadRepository for two
distinct repos in parallel under -race and asserts each gets its own
gitDirPath.

Signed-off-by: Andrew Nesbitt <andrewnez@gmail.com>
2026-06-29 17:13:31 +01:00
Andrew Nesbitt
bf84dfd79a
pkg/gitinterface: open go-git with DetectDotGit:false
GetGoGitRepository was passing DetectDotGit:true to PlainOpenWithOptions
on a path that is already the resolved git directory (set from
'git rev-parse --git-dir' in LoadRepository). With detect on, go-git
looks for a .git entry inside that path; a bare repository has none, so
it returns ErrRepositoryNotExists and every caller (verifyCommitSignature,
tag verification) fails on bare repos.

DetectDotGit:false treats the path as the git dir directly and opens
both bare and working-tree layouts.

Adds tests covering GetGoGitRepository on bare repos including the
forge-conventional <name>.git layout.

Signed-off-by: Andrew Nesbitt <andrewnez@gmail.com>
2026-06-29 17:03:13 +01:00
Aditya Sirish
5d04217a50
Bump go-git to v6
Signed-off-by: Aditya Sirish <aditya@saky.in>
2026-06-17 20:39:04 -04:00
Aaravanand00
952d23c39a test: add parent resolution test for merge commits
Signed-off-by: Aaravanand00 <aaravanand5749@gmail.com>
2026-06-16 22:49:29 +05:30
Pat Zielinski
ee20d8f008
pkg: Increase testing coverage
Signed-off-by: Pat Zielinski <git@patzielinski.com>
2026-06-11 12:16:43 -04:00
Pat Zielinski
1f8cf912cc
pkg: Drop support for Git versions older than v2.38.0
Signed-off-by: Pat Zielinski <git@patzielinski.com>
2026-06-10 09:56:56 -04:00
patzielinski
df5896f666
Merge pull request #1305 from dawgdevv/improve-gitinterface-coverage-v2
pkg/gitinterface: Add tests for uncovered error paths and edge cases
2026-05-05 16:31:13 +00:00
dawgdevv
da5b8916e3 pkg/gitinterface: Remove unnecessary error return from createTestTrees
Signed-off-by: dawgdevv <nraj02415@gmail.com>
2026-05-01 23:50:02 +05:30
dawgdevv
3e835940ee pkg/gitinterface: Add and refactor tests for coverage
This commit adds tests for uncovered error paths and edge cases in
pkg/gitinterface, and refactors existing tests for clarity:

- Add error path tests for CheckAndSetReference, SetReference,
  DeleteReference, RefSpec, CanSign, VerifySignature,
  TagUsingSpecificKey, GetAllFilesInTree, EnsureIsCommit,
  GetTagTarget, ensureIsTag, and other helpers
- Inline error-case test functions into parent tests using t.Run
  subtests for better organization
- Extract inline byte slices into named variables for readability
- Simplify temp directory usage where subdirectories are unnecessary
- Remove redundant parser-level error tests
- Format files with gofmt

Signed-off-by: dawgdevv <nraj02415@gmail.com>
2026-04-30 02:47:33 +05:30
patzielinski
39fa8da311
Merge pull request #1273 from ayuxsh009/fix/status-rename-parser
fix(gitinterface): parse renamed entries in status output
2026-04-29 20:24:55 +00:00
ayuxsh009
bfda5df850 fix: parse rename status
Signed-off-by: ayuxsh009 <1raj.aayush@gmail.com>
2026-04-30 01:41:16 +05:30
dawgdevv
8374150f3f test: improve pkg/gitinterface coverage from 69.4% to 76.2%
This PR adds focused tests for error paths and edge cases across
pkg/gitinterface, raising coverage from 69.4% to 76.2%.
Files changed:
- references_test.go: TestAbsoluteReference with branch/tag/custom/ref lookups
- tag_test.go: TestEnsureIsTag, error paths for GetTagTarget and verifyTagSignature
- commit_test.go: TestEnsureIsCommit, error paths for commit inspection helpers
- object_test.go: Error paths for GetObjectType and GetObjectSize
- blob_test.go: Error path for ReadBlob with non-blob object
- status_test.go: Tests for Status errors and StatusCode helpers
- sync_test.go: Tests for WithFetchDepth, CreateRemote, push/fetch errors
- config_test.go: Error path for SetGitConfig
- utils_test.go: TestResetDueToError
Closes #1244

Signed-off-by: dawgdevv <nraj02415@gmail.com>
2026-04-25 02:44:19 +05:30
Pat Zielinski
40efdc8fbd
sigstore: Drop support for online verification
Co-authored-by: Horiodino <holiodin@gmail.com>
Co-authored-by: Aditya Sirish <aditya@saky.in>
Signed-off-by: Pat Zielinski <git@patzielinski.com>
2026-02-19 12:39:22 -05:00
Pat Zielinski
f649b141d3
pkg: Move gitinterface to pkg
Signed-off-by: Pat Zielinski <git@patzielinski.com>
2026-01-16 14:03:36 -05:00