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>
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>
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>
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>
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>
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>
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>
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>