Skip to content

Commit 939f207

Browse files
committed
Add tag protection to generated policy
This commit adds the tag protection entry to the generated policy when it is reported in the active controls. Signed-off-by: Adolfo Garcia Veytia (puerco) <[email protected]>
1 parent 3a1a6ed commit 939f207

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

pkg/policy/policy.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,16 @@ func (pe *PolicyEvaluator) CreateLocalPolicy(ctx context.Context, repo *models.R
276276
},
277277
},
278278
}
279+
280+
// If the controls returned
281+
controls := slsa.Controls(provPred.GetControls())
282+
tagHygiene := controls.GetControl(slsa.TagHygiene)
283+
if tagHygiene != nil {
284+
p.ProtectedTag = &ProtectedTag{
285+
Since: tagHygiene.GetSince(),
286+
TagHygiene: true,
287+
}
288+
}
279289
data, err := json.MarshalIndent(&p, "", " ")
280290
if err != nil {
281291
return "", err

pkg/sourcetool/tool.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,15 @@ func (t *Tool) createPolicy(r *models.Repository, branch *models.Branch, control
220220
},
221221
},
222222
}
223+
224+
// If the controls returned
225+
tagHygiene := controls.GetActiveControls().GetControl(slsa.TagHygiene)
226+
if tagHygiene != nil {
227+
p.ProtectedTag = &policy.ProtectedTag{
228+
Since: tagHygiene.GetSince(),
229+
TagHygiene: true,
230+
}
231+
}
223232
return p, nil
224233
}
225234

0 commit comments

Comments
 (0)