pub struct Policy { /* private fields */ }Expand description
A policy for OpenPGP signatures in git.
A Policy governs state changes in git repositories. A state
change is a change from one git commit with a policy embedded into
it to the next commit, which may change the policy, the source, or
both.
Implementations§
Source§impl Policy
impl Policy
pub fn parse_bytes<D: AsRef<[u8]>>(bytes: D) -> Result<Self>
Sourcepub fn read_file<P: AsRef<Path>>(path: P) -> Result<Policy>
pub fn read_file<P: AsRef<Path>>(path: P) -> Result<Policy>
Reads the policy from the given path.
Sourcepub fn read_file_or_default<P: AsRef<Path>>(path: P) -> Result<Policy>
pub fn read_file_or_default<P: AsRef<Path>>(path: P) -> Result<Policy>
Reads the policy from the given path.
Sourcepub fn read_from_working_dir() -> Result<Policy>
pub fn read_from_working_dir() -> Result<Policy>
Reads the policy from the current git working directory.
Default to the empty policy if the work directory doesn’t contain a policy.
Sourcepub fn read_bytes_from_commit(git: &Repository, commit: &Oid) -> Result<Vec<u8>>
pub fn read_bytes_from_commit(git: &Repository, commit: &Oid) -> Result<Vec<u8>>
Reads the policy from the given git commit.
Sourcepub fn read_from_commit(git: &Repository, commit: &Oid) -> Result<Self>
pub fn read_from_commit(git: &Repository, commit: &Oid) -> Result<Self>
Reads the policy from the given git commit.
Sourcepub fn write<P: AsRef<Path>>(&self, path: P) -> Result<()>
pub fn write<P: AsRef<Path>>(&self, path: P) -> Result<()>
Writes the policy into a file with the given path.
Sourcepub fn write_to_working_dir(&self) -> Result<()>
pub fn write_to_working_dir(&self) -> Result<()>
Writes the policy to the current git working directory.
Sourcepub fn commit_goodlist(&self) -> &BTreeSet<String>
pub fn commit_goodlist(&self) -> &BTreeSet<String>
Set of commits that is assumed to be good.
The commits will pass verification even if it would fail for whatever reason.
To change this set, you need the audit right.
Sourcepub fn commit_goodlist_mut(&mut self) -> &mut BTreeSet<String>
pub fn commit_goodlist_mut(&mut self) -> &mut BTreeSet<String>
Set of commits that is assumed to be good.
The commits will pass verification even if it would fail for whatever reason.
To change this set, you need the audit right.
Set of authorizations.
The key is a free-form, human-readable identifier for the authorization.
Set of authorizations.
The key is a free-form, human-readable identifier for the authorization.
Sourcepub fn diff<'f, 't>(&'f self, other: &'t Policy) -> Result<Diff<'f, 't>>
pub fn diff<'f, 't>(&'f self, other: &'t Policy) -> Result<Diff<'f, 't>>
Computes the difference between this policy and other.
Sourcepub fn verify(
&self,
git: &Repository,
commit_id: &Oid,
commit_policy: &Policy,
signer_keys: &mut BTreeSet<Fingerprint>,
primary_uids: &mut BTreeSet<UserID>,
) -> Result<Vec<Result<(String, Signature, Cert, Fingerprint)>>>
pub fn verify( &self, git: &Repository, commit_id: &Oid, commit_policy: &Policy, signer_keys: &mut BTreeSet<Fingerprint>, primary_uids: &mut BTreeSet<UserID>, ) -> Result<Vec<Result<(String, Signature, Cert, Fingerprint)>>>
Verifies that the given commit adheres to this policy.
During verification, the key(s) used are stored in
signer_keys, and the primary user id of the issuing cert at
the time of the signing is stored in primary_uids. This
information can be used to prune certs in a policy.
If the commit is goodlisted, this function returns Ok with an empty vector of verification results.