Commit graph

195 commits

Author SHA1 Message Date
Aditya Sirish A Yelgundhalli
2dc047ec98
*: Remove some unnecessary pieces
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2025-02-18 10:54:27 -05:00
Aditya Sirish A Yelgundhalli
8b2d9967ed
policy: Check policy ref matches RSL during Apply
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2025-02-12 15:58:47 -05:00
Aditya Sirish A Yelgundhalli
58bde0d547
policy: Load and commit controller metadata
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2025-02-12 11:16:21 -05:00
Aditya Sirish A Yelgundhalli
0a4f65ae7d
policy: Use wrapper type for state metadata
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2025-02-11 17:17:52 -05:00
Aditya Sirish A Yelgundhalli
e1099796ea
policy: Support verifying initial root signatures
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2025-02-10 14:47:36 -05:00
Aditya Sirish A Yelgundhalli
b75f01a275
*: Add ReferenceUpdaterEntry interface
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2025-02-07 15:54:50 -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 A Yelgundhalli
82dfce994c
gittuf,policy: Add VerifyMergeableForCommit
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2025-01-28 17:53:09 -05:00
Aditya Sirish
4f2eea978e
policy: Add failure tests for app attestations
Signed-off-by: Aditya Sirish <aditya@saky.in>
2025-01-23 13:40:16 -05:00
Aditya Sirish
20780c2d84
*: Initial support for naming for gittuf app
gittuf has a companion app for GitHub that can record attestations for
pull request reviews. Previously, the app was identified by its signing
key. This commit adds initial support for naming the app, with an eye
towards eventually supporting attestations from multiple apps.

Signed-off-by: Aditya Sirish <aditya@saky.in>
2025-01-23 13:34:42 -05:00
Aditya Sirish
3e24f4ceaf
*: Support multiple types of global rules
This commit adds support for different types of global rules (i.e., non
threshold constraints). This commit also adds a global rule to block
force pushes to one or more specified refs.

Signed-off-by: Aditya Sirish <aditya@saky.in>
2025-01-09 19:14:29 -05:00
Aditya Sirish
a012480111
Merge pull request #699 from gittuf/global-constraints
Add support for global rules
2025-01-09 17:10:51 -05:00
Aditya Sirish
96516300f6
*: Add support for global rules
This commit adds initial support for "global rules" that set baselines
that must be met during verification. Currently, the global rule only
enforces threshold rules. Each rule is enforced by inspecting the set of
principals successfully verified for a change. If a change is not
protected explicitly, then it's verified using all principals in the
policy.

Signed-off-by: Aditya Sirish <aditya@saky.in>
2025-01-09 17:03:39 -05:00
Aditya Sirish
840b2cf45f
*: Fix GetLatestReferenceEntry's before condition
The before condition check was incorrect when handling repositories that
were not numbered from the start. This commit updates the before entry
number condition to only apply if the entry being examined is in fact
numbered.

This commit also adds some debug statements.

Signed-off-by: Aditya Sirish <aditya@saky.in>
2025-01-09 16:03:07 -05:00
Aditya Sirish
f5422d9cc0
policy: Streamline verification helper
We have two very similar helpers: verifyGitObjectAndAttestations and
verifyGitObjectAndAttestationsUsingVerifiers. The first one calls the
second one. However, there were numerous cases of direct invocation of
the second one. This commit makes the first helper the one that's used
consistently. This ensures that finding which verifiers to use and so on
are consistent everywhere.

Signed-off-by: Aditya Sirish <aditya@saky.in>
2025-01-08 16:17:12 -05:00
Aditya Sirish
90a4d1a806
gittuf,cache,policy,cmd: Use persistent cache
This commit adds support for persistent cache searching as well as
explicit populating.

Signed-off-by: Aditya Sirish <aditya@saky.in>
2025-01-08 12:42:13 -05:00
Aditya Sirish
79334280f7
gittuf,policy: Add PolicyVerifier type
This commit corrals all policy.Verify APIs as methods on a
PolicyVerifier type. This has benefits such as how they share the
underlying repository handler as well as searchers, cache populating,
etc.

Signed-off-by: Aditya Sirish <aditya@saky.in>
2025-01-03 16:54:12 -05:00
Aditya Sirish
3d531cff8f
policy: Rename Verifier to SignatureVerifier
Signed-off-by: Aditya Sirish <aditya@saky.in>
2025-01-03 15:55:40 -05:00
Aditya Sirish
be3a9d8c48
policy: Add cacheSearcher stubs
Signed-off-by: Aditya Sirish <aditya@saky.in>
2025-01-02 15:17:07 -05:00
Aditya Sirish
eb489edf48
policy: Use ecdsa type rather than scheme
Signed-off-by: Aditya Sirish <aditya@saky.in>
2024-12-16 11:13:39 -05:00
Aditya Sirish A Yelgundhalli
a601aee55d
*: Various policy fixes
1. VerifyMergeable was incorrectly returning an error when no verifiers were
found (for an unprotected base branch).

2. Policy's searcher interface was also returning the wrong error when the
latest policy or attestation entry was not found.

3. A verify-mergeable command has been added to simplify debugging.

Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-12-06 16:08:32 -05:00
Pat Zielinski
ced719a901 *: Fix some typos
Signed-off-by: Pat Zielinski <70954403+patzielinski@users.noreply.github.com>
2024-12-04 09:51:44 -05:00
Aditya Sirish A Yelgundhalli
3619fc4a4d
policy: Consolidate some preprocessing passes
We have some policy state specific tasks that need to happen only once and can
be consolidated as part of a generic preprocessing flow.

Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-11-21 21:26:55 -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
8f11d8c679
policy: Add some explicit assumptions in verification flow
Signed-off-by: Aditya Sirish <aditya@saky.in>
2024-11-11 10:42:42 -05:00
Aditya Sirish A Yelgundhalli
f3cb6331c3
policy: Add more debug statements
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-11-08 12:44:15 -05:00
Aditya Sirish A Yelgundhalli
9fe56eaf29
policy: Add debug statements for approval attestation verification
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-11-08 10:44:44 -05:00
Aditya Sirish A Yelgundhalli
4ccc102f8e
*: Use person associatedIdentities to verify code review tool approvals
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-11-07 17:21:19 -05:00
Aditya Sirish A Yelgundhalli
9c08c47035
*: Expose persons in CLI
This commit allows for using persons in the CLI. In doing so, it updates the
expected flow where add-rule no longer also adds the principals passed in.
Instead, keys / persons must be added explicitly first, and add-rule will fail
if the principal is not found.

Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-11-07 15:11:52 -05:00
Aditya Sirish A Yelgundhalli
8c49dfea3a
policy, cmd: Add list-principals sub command
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-11-07 12:48:06 -05:00
Aditya Sirish A Yelgundhalli
fbea8edfa6
policy: Add tests using v02 policy and persons
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-11-05 11:40:07 -05:00
Aditya Sirish A Yelgundhalli
6996955f98
policy: Support principals in policy.Verifier
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-11-05 11:40:07 -05:00
Aditya Sirish A Yelgundhalli
6e14a8d598
tuf, policy, gittuf: Add v02 of policy metadata
This commit introduces v02 of policy metadata schemas for root and targets
files. The biggest change is the introduction of the Person principal type.
This commit also adds a migration function from v01 to v02, though it's
selectively invoked.

Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-11-05 11:26:53 -05:00
Aditya Sirish A Yelgundhalli
3a12c934b5
attestations, policy, gittuf: Add v0.2 ref authorization
v0.1 assumes the target is a tree, meaning it's not possible to approve tags.
v0.2 fixes this assumption.

Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-10-31 16:21:40 -04:00
Aditya Sirish A Yelgundhalli
17b058f7f4
*: Support multiple predicate versions
This commit moves existing implementations of attestation predicates into
subpackages to start supporting multiple versions in parallel.

Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-10-23 10:37:01 -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
75b2b7c5ce
policy: Add back support for legacy key types
We took out support for legacy key types a few commits ago, but this would mean
we will have to reset gittuf metadata for gittuf's own repository. This commit
adds support for verifying signatures using those legacy key types but does not
support them for signing new metadata.

Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-10-16 13:47:05 -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
8a43f4fffd
*: Remove vendored signerverifier library
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-10-10 13:30:32 -04:00
Aditya Sirish A Yelgundhalli
f1473c53e5
*: Add sigstore signer for metadata
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-10-09 16:13:01 -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
a5a9ff1e7d
*: Move policy metadata manipulations to tuf package
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-10-09 12:59:32 -04:00
Aditya Sirish A Yelgundhalli
634b1cd98e
*: Remove legacy key types
This commit drops support for the legacy / custom securesystemslib key format.
This format was used in two forms:
a) In tests
b) On disk in the policy state for the root keys

To address the removal, tests have been updated to use SSH keys (via the
ssh-keygen signer). This makes up the majority of the diff for this commit, and
includes some additions to the ssh package to more easily load test artifacts.

Additionally, we don't need to store a policy state's root keys on disk for
that ref. This was an error in our initial design, and it actually leads to
complications in ensuring that the policy state's on disk keys match the keys
listed in the state's root metadata. This commit updates it so only the root
metadata's record of the root keys are used, with the keys directory omitted
for future policy states. However, we maintain backwards compatibility for
policy states that include the keys on disk, we just ignore them.

Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-10-04 14:58:50 -04:00
Aditya Sirish A Yelgundhalli
a1c369e528
policy: Fix attestation load for tag verification
Currently, attestations are loaded assuming the approval target is a Git tree.
Entries for tags don't have trees. Separately, we can add support for approval
attestations for tags that know not to compute merge trees when approving a
tag, instead using the commit ID the tag is expected to point to.

Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-10-01 16:05:07 -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
4a84a2e641
Merge pull request #563 from gittuf/vendor-dsse
Vendor go-sslib/dsse and add support for setting a signature extension
2024-09-27 14:02:13 -04:00