Skip to content

Commit fcd34a8

Browse files
committed
improve verification message and file permissions
Signed-off-by: Sanskar Jaiswal <[email protected]>
1 parent 6ee9864 commit fcd34a8

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

Diff for: controllers/helmchart_controller.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -1038,13 +1038,11 @@ func observeChartBuild(obj *sourcev1.HelmChart, build *chart.Build, err error) {
10381038

10391039
if build.VerificationSignature != nil && build.ProvFilePath != "" {
10401040
var sigVerMsg strings.Builder
1041-
sigVerMsg.WriteString(fmt.Sprintf("chart signed by: '%v'", strings.Join(build.VerificationSignature.Identities[:], ",")))
1042-
sigVerMsg.WriteString(fmt.Sprintf(" using key with fingeprint: '%X'", build.VerificationSignature.KeyFingerprint))
1043-
sigVerMsg.WriteString(fmt.Sprintf(" and hash verified: '%s'", build.VerificationSignature.FileHash))
1041+
sigVerMsg.WriteString(fmt.Sprintf("verified chart hash: '%s'", build.VerificationSignature.FileHash))
1042+
sigVerMsg.WriteString(fmt.Sprintf(" signed by: '%s'", build.VerificationSignature.Identity))
1043+
sigVerMsg.WriteString(fmt.Sprintf(" with key: '%X'", build.VerificationSignature.KeyFingerprint))
10441044

10451045
conditions.MarkTrue(obj, sourcev1.SourceVerifiedCondition, sourcev1.ChartVerificationSucceededReason, sigVerMsg.String())
1046-
} else {
1047-
conditions.Delete(obj, sourcev1.SourceVerifiedCondition)
10481046
}
10491047

10501048
if err != nil {
@@ -1080,6 +1078,7 @@ func reasonForBuild(build *chart.Build) string {
10801078

10811079
func (r *HelmChartReconciler) getProvenanceKeyring(ctx context.Context, chart *sourcev1.HelmChart) ([]byte, error) {
10821080
if chart.Spec.VerificationKeyring == nil {
1081+
conditions.Delete(chart, sourcev1.SourceVerifiedCondition)
10831082
return nil, nil
10841083
}
10851084
name := types.NamespacedName{

Diff for: controllers/helmchart_controller_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,10 @@ func TestHelmChartReconciler_reconcileStorage(t *testing.T) {
327327
if err := testStorage.MkdirAll(*obj.Status.Artifact); err != nil {
328328
return err
329329
}
330-
if err := testStorage.AtomicWriteFile(obj.Status.Artifact, strings.NewReader(v), 0644); err != nil {
330+
if err := testStorage.AtomicWriteFile(obj.Status.Artifact, strings.NewReader(v), 0o644); err != nil {
331331
return err
332332
}
333-
if err := testStorage.AtomicWriteFile(provArtifact, strings.NewReader(v), 0644); err != nil {
333+
if err := testStorage.AtomicWriteFile(provArtifact, strings.NewReader(v), 0o644); err != nil {
334334
return err
335335
}
336336
}
@@ -384,7 +384,7 @@ func TestHelmChartReconciler_reconcileStorage(t *testing.T) {
384384
if err := testStorage.MkdirAll(*obj.Status.Artifact); err != nil {
385385
return err
386386
}
387-
if err := testStorage.AtomicWriteFile(obj.Status.Artifact, strings.NewReader("file"), 0644); err != nil {
387+
if err := testStorage.AtomicWriteFile(obj.Status.Artifact, strings.NewReader("file"), 0o644); err != nil {
388388
return err
389389
}
390390
return nil
@@ -551,7 +551,7 @@ func TestHelmChartReconciler_reconcileSource(t *testing.T) {
551551
g.Expect(obj.Status.ObservedSourceArtifactRevision).To(Equal(gitArtifact.Revision))
552552
g.Expect(obj.Status.Conditions).To(conditions.MatchConditions([]metav1.Condition{
553553
*conditions.TrueCondition(sourcev1.ArtifactOutdatedCondition, "NewChart", "pulled 'helmchart' chart with version '0.1.0'"),
554-
*conditions.TrueCondition(sourcev1.SourceVerifiedCondition, sourcev1.ChartVerificationSucceededReason, "chart signed by: 'TestUser' using key with fingeprint: '943CB5929ECDA2B5B5EC88BC7035BA97D32A87C1' and hash verified: 'sha256:007c7b7446eebcb18caeffe9898a3356ba1795f54df40ad39cfcc7382874a10a'"),
554+
*conditions.TrueCondition(sourcev1.SourceVerifiedCondition, sourcev1.ChartVerificationSucceededReason, "verified chart hash: 'sha256:007c7b7446eebcb18caeffe9898a3356ba1795f54df40ad39cfcc7382874a10a' signed by: 'TestUser' with key: '943CB5929ECDA2B5B5EC88BC7035BA97D32A87C1'"),
555555
}))
556556
},
557557
cleanFunc: func(g *WithT, build *chart.Build) {

Diff for: internal/helm/chart/verify.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func provenanceFilePath(path string) string {
7474

7575
// ref: https://github.com/helm/helm/blob/v3.8.0/pkg/action/verify.go#L47-L51
7676
type VerificationSignature struct {
77-
Identities []string
77+
Identity string
7878
KeyFingerprint [20]byte
7979
FileHash string
8080
}
@@ -84,7 +84,8 @@ func buildVerificationSig(ver *provenance.Verification) *VerificationSignature {
8484
if ver != nil {
8585
if ver.SignedBy != nil {
8686
for name := range ver.SignedBy.Identities {
87-
verSig.Identities = append(verSig.Identities, name)
87+
verSig.Identity = name
88+
break
8889
}
8990
}
9091
verSig.FileHash = ver.FileHash

0 commit comments

Comments
 (0)