Commit graph

138 commits

Author SHA1 Message Date
Aditya Sirish
a95ec8df43
*: Fix linter issues
This commit fixes issues flagged by the additional linters enabled in
the parent commit.

Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-10-24 16:48:46 -04:00
Aditya Sirish
f24f7f27fc
gitinterface: Add fastForwardOnly flag to Fetch
Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-10-11 23:18:07 -04:00
Aditya Sirish
be3eece7be
gitinterface: Simplify tmp dir handling in tests
Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-10-11 21:31:29 -04:00
Aditya Sirish
483c6eb2a6
gitinterface: Set HEAD in fetch tests
Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-10-11 21:31:29 -04:00
Aditya Sirish
ef38590f91
*: Drop explicit trackRemote option
Now, the remote tracker is always updated. If gitinterface.Fetch is used
with a refName, it assumes the default is to fetch to the same target in
the local repository. By default, it also updates the remote tracker.
For more granular control, FetchRefSpec must be used.

Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-10-11 21:31:28 -04:00
Aditya Sirish
30953507b0
gitinterface: Make remote ref generation reusable
Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-10-11 21:30:35 -04:00
Aditya Sirish
7d59b2643c
gitinterface: Resolve HEAD to target absolute path
Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-10-11 20:52:41 -04:00
Pat Zielinski
d0905e7816 Add SPDX License Identifiers to code files
Signed-off-by: Pat Zielinski <70954403+patzielinski@users.noreply.github.com>
2023-10-09 08:09:34 -04:00
Aditya Sirish
30f583e7e4
*: Add verify-commit
Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-10-02 10:47:14 -04:00
Aditya Sirish
14f50e8bb1
gitinterface: Fix gpg key load in test
Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-09-15 14:36:25 -04:00
Aditya Sirish
106f034933
Merge pull request #113 from gittuf/tags
Add support for tags
2023-09-15 14:34:23 -04:00
Aditya Sirish
ad96717b0e
gitinterface: Fix test config value and invocation
This fixes a previously unnoticed bug in setting the test config where
the user's name and email were actually left blank. This is an issue
with how go-git parses the raw parts of the config vs the defined
structs. This was primarily noticed because of mismatched hashes on
GitHub actions in the tag, the expected values have changed in some
existing tests as well.

Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-09-13 13:30:16 -04:00
Aditya Sirish
b4d19ff9f8
gitinterface: Add tag specific functions
Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-09-13 12:50:09 -04:00
Aditya Sirish
bdf56b6577
gitinterface: Generalize signature functions
This is in preparation for re-use with tags.

Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-09-13 12:24:26 -04:00
Aditya Sirish
f7eb00a6d6
*: Clean up GPG key load from bytes
Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-09-13 11:26:19 -04:00
Aditya Sirish
12a29c17aa
gitinterface: Add syncing features
Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-09-12 13:06:53 -04:00
Aditya Sirish
a6e7ece288
*: Add RefSpec creation capability to gitinterface
Also moves AbsoluteReference from repository to gitinterface.

Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-09-12 13:06:53 -04:00
Aditya Sirish
29b795abe3
*: Update gitinterface.Commit behavior
1. Commit now returns the ID of the newly created commit. This will help
   us avoid extraneous calls to repo.Reference to get the new state of
   the affected ref.
2. Commit also creates the ref if it doesn't already exist. This allows
   to skip initializing (to zero) refs we're about to commit to anyway.
   Note: this commit does not actually remove those extra
   initializations. That is left to a future patch or clean up pass.

Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-09-12 13:06:53 -04:00
Aditya Sirish
b850488960
gitinterface: Changes and commit reachability
* Add functions to track changes introduced by commits or between commits
* Add function to check if a commit knows another using reachability

Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-09-11 15:34:14 -04:00
Josh Soref
675b9eb0e2 spelling: nonexistent
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-09-01 16:09:30 -04:00
Aditya Sirish
3192cdb861
Rename module to use gittuf org
Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-08-30 13:13:54 -04:00
Aditya Sirish
d48a0b8ead
common, gitinterface: Clean up test data
Define test data such as user information, Git config, fake clock once
at most per package.

Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-08-18 16:32:21 -04:00
Aditya Sirish
5bb804a767
gitinterface: Identify changed files
Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-08-18 16:07:45 -04:00
Aditya Sirish
0d4be41b91
Early gitsign support
This commit introduces early, experimental support for gitsign
signatures on git commits. It uses TAP-18 to specify sigstore identity
constraints in delegations.

The feature introduced here depends on unreleased prototype code in
go-securesystemslib and is also insufficiently tested due to some
sigstore library constraints.

See: #73

Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-08-07 15:27:37 -04:00
Aditya Sirish
3eb898b586
Merge pull request #62 from adityasaky/redo-verify
Take 2 of gittuf verification functions
2023-07-14 11:03:05 -04:00
Aditya Sirish
5fa283d717
policy: Add basic verification functions
This commit introduces basic verification workflows for Git refs.
Specifically, a Git ref can be verified against either the latest policy
or from the very start of the RSL. As part of this, relative
verification is also introduced from one RSL entry to the next.

Note: also adds basic Match functionality for delegation patterns in the tuf
package.

Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-07-14 10:48:22 -04:00
Aditya Sirish
ce0ddf8b5b
rsl, gitinterface: Use empty tree
Currently, we're using a zerohash for the tree ID for RSL entries. This
is flagged as an error by Git, and visible when trying to push to some
forges.

Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-07-12 18:01:04 -04:00
Aditya Sirish
22b87ba83e
gitinterface: Add docstrings
Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-06-20 15:51:43 -07:00
Aditya Sirish
24244629a7
gitinterface, sv: Add support for GPG signing
Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-06-20 15:48:00 -07:00
Aditya Sirish
31035b843c
cmd: Refactor entirely
This is a full fledged refactor of the cmd package based on this comment:
https://github.com/adityasaky/gittuf/pull/41#discussion_r1198995982.

First, the dev subcommand is retired as it was necessary to test certain
RSL functions which have now been built. The subcommand also printed out
the git config, again something we no longer need. To that end,
GetConfig() in gitinterface has been made private.

Second, the trust and policy subcommands have been reimplemented using
the recommended structure with specific packages that construct them
with their options.

Finally, the cmd package has been moved to the internal namespace.

Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-05-20 15:17:11 -04:00
Aditya Sirish
e3df99765e
gitinterface: Improve testing of GetSigningInfo
First, the test is switched to using an in-memory repository. Second,
due to changes in how config is read, we no longer have the issue of
system / user git configs polluting the test config. So, the previously
disabled tests (expected to error out) have been enabled as well.

Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-05-18 14:39:08 -04:00
Aditya Sirish
c94749b32c
gitinterface: Make GetConfig test friendly
This change allows for testing dependents of GetConfig with in-memory
repositories.

Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-05-18 14:37:31 -04:00
Aditya Sirish
80b419edf1
Merge pull request #37 from adityasaky/init-root-role
Implement basic root signing capabilities
2023-05-18 10:43:58 -04:00
Aditya Sirish
43d94afac6
gitinterface: Reset test directory
Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-05-18 10:38:32 -04:00
Aditya Sirish
e085386a16
Remove repo parameter when crafting signing command
Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-05-07 15:01:01 -04:00
Aditya Sirish
30c2fb572b
Fix repository handling in packages
This removes several direct fs handling for namespace creation as well
as making the RSL package dependent on repo information being passed in.
This also means that several tests can move to in-memory repositories.

Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-04-25 17:13:29 -04:00
Aditya Sirish
9195a70ba7
Several changes to prepare policy namespace
This commit includes several plumbing changes.
* Support for trees and blobs in gitinterface
* Initialization of refs/gittuf independent of policy / RSL packages
* Initialization of policy and policy-staging namespaces
* rsl.InitializeNamespace is now only responsible for its own namespace
* Replaces some t.Error calls with t.Fatal

Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-03-21 12:46:09 -04:00
Aditya Sirish
c94f87d5f9
Add gitinterface package
This package includes a set of helpers to interface with the underlying
git repository. Features:
* parse git configs to determine commit signing mechanism
* create and sign commit objects

Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-02-20 14:09:44 -05:00