Skip to content

Commit 8858663

Browse files
authored
Fix branch name in new policies (#270)
This corrects a bug where policies where being created with the full ref in the branch instead of the short name. Signed-off-by: Adolfo Garcia Veytia (puerco) <[email protected]>
1 parent 56da18b commit 8858663

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

pkg/policy/policy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ func computeSlsaLevel(branchPolicy *ProtectedBranch, _ *ProtectedTag, controls s
365365
}
366366

367367
if branchPolicy.GetSince().AsTime().Before(*eligibleSince) {
368-
return []slsa.ControlName{}, fmt.Errorf("policy sets target level %s since %v, but it has only been eligible for that level since %v", branchPolicy.GetTargetSlsaSourceLevel(), branchPolicy.GetSince(), eligibleSince)
368+
return []slsa.ControlName{}, fmt.Errorf("policy sets target level %s since %v, but it has only been eligible for that level since %v", branchPolicy.GetTargetSlsaSourceLevel(), branchPolicy.GetSince().AsTime(), eligibleSince)
369369
}
370370

371371
return []slsa.ControlName{slsa.ControlName(branchPolicy.GetTargetSlsaSourceLevel())}, nil

pkg/sourcetool/tool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ func (t *Tool) createPolicy(r *models.Repository, branch *models.Branch, control
214214
CanonicalRepo: r.GetHttpURL(),
215215
ProtectedBranches: []*policy.ProtectedBranch{
216216
{
217-
Name: branch.FullRef(),
217+
Name: branch.Name,
218218
Since: timestamppb.New(*eligibleSince),
219219
TargetSlsaSourceLevel: string(eligibleLevel),
220220
},

0 commit comments

Comments
 (0)