Commit graph

138 commits

Author SHA1 Message Date
Pat Zielinski
07c87fa656 gitinterface: Add utilities helpful for gittuf hooks
Signed-off-by: Pat Zielinski <70954403+patzielinski@users.noreply.github.com>
Co-authored-by: Jamal Cao <jamaltheodds@gmail.com>
2025-03-06 23:18:09 -05:00
Aditya Sirish A Yelgundhalli
3639e23219
*: Add gittuf sync
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2025-02-20 17:56:07 -05:00
Aditya Sirish A Yelgundhalli
692f95930d
gitinterface: Support fetching single object
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2025-02-20 13:41:27 -05:00
Aditya Sirish A Yelgundhalli
4719129e24
gitinterface: Add GetObjectType
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2025-02-20 12:15:45 -05:00
Aditya Sirish A Yelgundhalli
23b3282539
gitinterface: Add subtree workflow
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2025-02-04 16:48:38 -05:00
Aditya Sirish A Yelgundhalli
779ad12f1f
gitinterface: Add support for setting symref
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2025-02-04 15:11:58 -05:00
Aditya Sirish A Yelgundhalli
6f76045ff2
gitinterface: Add support for file statuses
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2025-02-04 13:05:30 -05:00
Aditya Sirish A Yelgundhalli
7700ca07be
gitinterface: Add IsBare() to repository
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2025-02-04 11:36:39 -05:00
Aditya Sirish A Yelgundhalli
2923704fa0
gitinterface: Support bare clones
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2025-02-04 11:18:02 -05:00
Horiodino
3d0be301a4
added Discard to clear the changes currently staged
Signed-off-by: Horiodino <holiodin@gmail.com>

updated Docs

Signed-off-by: Horiodino <holiodin@gmail.com>
2025-02-03 14:56:17 +05:30
Aditya Sirish
79efbf235f
gitinterface: Support types for tree entries
Signed-off-by: Aditya Sirish <aditya@saky.in>
2025-02-02 14:07:34 -05:00
Aditya Sirish
3236696c98
*: Extend TreeBuilder to reuse existing trees
If an intermediate tree already exists and we know this ahead of time,
we should use it without recreating it with all of its contents resolved
and written recursively. This commit adds support for such cases and
renames TreeBuilder's APIs to generalize away from accepting blob IDs
only.

Signed-off-by: Aditya Sirish <aditya@saky.in>
2025-02-02 12:06:18 -05:00
Aditya Sirish
a1d2f339e4
gitinterface: Add repository.HasObject
Signed-off-by: Aditya Sirish <aditya@saky.in>
2025-02-01 18:20:39 -05:00
Aditya Sirish A Yelgundhalli
464c50d552
gitinterface: Add APIs for inspecting trees
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2025-01-31 13:14:35 -05:00
Pat Zielinski
6cf9823f2e gitinterface: Add TestRepositoryCommitUsingSpecificKey
Co-authored-by: Raghava Gatadi <raghava.gtd@gmail.com>
Signed-off-by: Pat Zielinski <70954403+patzielinski@users.noreply.github.com>
2025-01-15 16:00:10 -05:00
Aditya Sirish A Yelgundhalli
807dddf43a
gitinterface: Use rev-parse instead of show
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-12-12 13:25:36 -05:00
Aditya Sirish A Yelgundhalli
7e55828f7f
*: Add verify-mergeable
This commit enables checking if a change in a feature ref can be merged into
the target ref. Significantly, this API returns true if the policy can be met
when the merge is performed by an authorized person.

Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-11-21 13:52:22 -05:00
Aditya Sirish A Yelgundhalli
87f2f96b40
gitinterface: Support ff merge in GetMergeTree
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-10-29 22:37:29 -04:00
Aditya Sirish A Yelgundhalli
a3fedc1524
sigstore: Add support for private sigstore instances
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-10-16 15:14:38 -04:00
Aditya Sirish A Yelgundhalli
2f0be5c46f
*: Refactor TUF
This is a massive commit that isn't easy to split up, my apologies to
reviewers. Here's everything that's happening.

First, the base tuf package now includes interfaces for RootMetadata,
TargetsMetadata, Rule, and Principal. The first two are self-explanatory. Rule
represents some protection rule, currently matched by the Delegation schema,
while Principal defines a new take on who a trusted party is. Existing schemas
have been moved into a v01 subpackage. v01 also includes a Key type based on
signerverifier.SSLibKey which implements the Principal interface. This means
that expectations elsewhere (such as in repository and policy) re a principal
can be met by existing policy metadata.

Second, with most of the policy metadata manipulations having moved to the tuf
package, this commit drops them from the policy package as they were thin
wrappers. While we originally kept them around for the purposes of migrating
versions when a repository must move from the old metadata schema to a newer
one, it doesn't make sense to implement this in every individual manipulation
function.

Finally, the rest of the packages that handle keys (for adding to metadata or
for signing / verifying) have been updated to use either
signerverifier.SSLibKey directly or the new Principal interface, depending on
what the purpose is. For now, the idea is to continue using the
signerverifier.SSLibKey representation of a key itself for the signature
verification flows, though we may eventually move that into gittuf rather than
rely on go-securesystemslib. Note that some of the transitions have been
included in this commit for compatibility reasons, and subsequent PRs will
update that. For example, the GitHub app pull request approval attestation must
be updated to not use tufv01.Key objects to represent approvers.

Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-10-15 12:58:44 -04:00
Aditya Sirish A Yelgundhalli
f7dd00b7bd
*: Remove use of signerverifier dispatcher
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-10-09 12:59:32 -04:00
Aditya Sirish A Yelgundhalli
9ed0c936d4
*: Use signerverifier/ssh for git signing / verifying
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-10-09 11:08:45 -04:00
Aditya Sirish
95f2077c6b
Merge pull request #549 from Yasho-Bapat/test-coverage
increasing policy.go test coverage
2024-09-28 12:31:15 -04:00
Aditya Sirish
dd1d8b2f46
*: Fix newlines
Signed-off-by: Aditya Sirish <aditya@saky.in>
2024-09-28 12:28:41 -04:00
Pat Zielinski
d571facb8d *: Add copyright notice to code files
Signed-off-by: Pat Zielinski <70954403+patzielinski@users.noreply.github.com>
2024-09-27 15:28:12 -04:00
Aditya Sirish
929e0d162d
*: Automatically reconcile local RSL with remote updates
This commit adds ReconcileLocalRSLWithRemote, which checks the local RSL
against the specified remote and reconciles the local RSL if needed. If
the local RSL doesn't exist or is strictly behind the remote RSL, then
the local RSL is updated to match the remote RSL. If the local RSL is
ahead of the remote RSL, nothing is updated. Finally, if the local and
remote RSLs have diverged, then the local only RSL entries are reapplied
over the latest entries in the remote if the local only RSL entries and
remote only entries are for different Git references.

Signed-off-by: Aditya Sirish <aditya@saky.in>
2024-09-25 14:02:59 -04:00
yashobapat
2d0d65ca08 reuse err fix (minor)
Signed-off-by: yashobapat <f20210006@goa.bits-pilani.ac.in>
2024-09-24 15:05:16 -04:00
yashobapat
318b293816 verify commit sig
Signed-off-by: yashobapat <f20210006@goa.bits-pilani.ac.in>
2024-09-24 15:01:22 -04:00
yashobapat
21ff68c9a3 fix linting
Signed-off-by: yashobapat <f20210006@goa.bits-pilani.ac.in>
2024-09-24 14:32:17 -04:00
Yasho-Bapat
b3aba609d9 increase policy/policy.go and gitinterface/commit.go test coverage, fix linting
Signed-off-by: yashobapat <f20210006@goa.bits-pilani.ac.in>
2024-09-24 14:32:01 -04:00
Aditya Sirish
886b0ffe3c
*: Use non-gittuf transport remote to check RSL
When checking the status of the remote RSL against the local RSL, we
must not use the transport, as that will also update the local RSL (in
addition to the remote tracker). With this commit, a separate temporary
remote is created and used.

Signed-off-by: Aditya Sirish <aditya@saky.in>
2024-09-11 11:48:49 -04:00
Aditya Sirish A Yelgundhalli
6474c5284f
*: Replace deprecated methods to identify signing config
The old methods are replaced by a simpler CanSign method needed in cmd as a
pre-run check.

Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-08-15 15:42:12 -04:00
Aditya Sirish A Yelgundhalli
e9514f31bb
*: Add GetMergeTree tests
Also addresses some required changes to tests hitting GetMergeTree via older
Git versions. This is because we use checkout to compute merge tree in those
cases, and we need to ensure that in the test, the worktree modified is that of
the temporary repository rather than the gittuf repository itself.

Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
Co-authored-by: Pat Zielinski <70954403+patzielinski@users.noreply.github.com>
2024-08-08 13:37:12 -04:00
Pat Zielinski
0d4cfa3ea2 gitinterface: Add workaround for legacy merge-tree command
Signed-off-by: Pat Zielinski <70954403+patzielinski@users.noreply.github.com>
2024-08-07 12:45:17 -04:00
Aditya Sirish A Yelgundhalli
baae9ae1c9
gitinterface: Use trivial merge flow for merge-tree
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-07-18 17:29:21 -04:00
Aditya Sirish A Yelgundhalli
f6ca551b96
gitinterface: Drop use of --format in git ls-tree
This allows us to support Git < 2.36, needed for users still on Ubuntu 22.04.

Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-07-18 16:55:23 -04:00
Aditya Sirish A Yelgundhalli
fe6d1d343a
*: Drop old gitinterface APIs
This commit also renames ReplacementTreeBuilder to TreeBuilder.

Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-07-01 10:21:25 -04:00
Aditya Sirish
bd5baa2e32 *: Use rewritten gitinterface
Signed-off-by: Aditya Sirish <aditya@saky.in>
2024-06-21 10:36:16 -04:00
patzielinski
0cff7df8db
Merge pull request #436 from gittuf/ssh-cli
Wire up ssh-keygen signer to CLI
2024-06-18 16:24:56 +00:00
Aditya Sirish A Yelgundhalli
576ba3bc0e *: Adds SSH support to verification APIs
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-06-18 12:14:49 -04:00
Pat Zielinski
741efb2c40 gitinterface: log_test nit
Signed-off-by: Pat Zielinski <70954403+patzielinski@users.noreply.github.com>
2024-06-14 13:37:05 -04:00
Aditya Sirish A Yelgundhalli
e44372fb30 gitinterface: Fix docs, add test for ranges across merged branches
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-06-14 13:01:43 -04:00
Aditya Sirish A Yelgundhalli
e871053716 gitinterface: Fixes for executor
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-06-13 11:42:27 -04:00
Aditya Sirish A Yelgundhalli
f938881ccc gitinterface: Check if ref has ref-prefix if unavailable locally
AbsoluteReference() returns the absolute ref path for a target based on what it
can find in the local copy of a repository. However, when it is given a string
with the ref-prefix included, it can use just that string.

Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-06-13 10:17:32 -04:00
Aditya Sirish A Yelgundhalli
34c00604d4 gitinterface: Fix docstring grammar
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-06-11 16:46:27 -04:00
Aditya Sirish A Yelgundhalli
ca0f537879 gitinterface: Add test-only support for merge commits
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-06-11 16:46:22 -04:00
Aditya Sirish A Yelgundhalli
d1ecf8fb70 gitinterface: Clean up repository.execute methods
This commit applies @wlynch's feedback from https://github.com/gittuf/gittuf/pull/383#discussion_r1628088633.

Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-06-11 16:46:22 -04:00
Aditya Sirish A Yelgundhalli
b0c6bac73b gitinterface: Fixes for tests
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-06-11 16:46:22 -04:00
Pat Zielinski
5c9403efcf gitinterface: Add remaining sync tests
Signed-off-by: Pat Zielinski <70954403+patzielinski@users.noreply.github.com>
2024-06-07 10:30:59 -04:00
Pat Zielinski
79deec165f gitinterface: Add (some) sync tests
Signed-off-by: Pat Zielinski <70954403+patzielinski@users.noreply.github.com>
2024-06-06 16:43:38 -04:00