Skip to content

Commit

Permalink
Merge pull request #28 from matheusdefarias/adding-sigstore-cosign-ad…
Browse files Browse the repository at this point in the history
…justments-pr

A check has been created to verify if p.sigstore is different from nil
  • Loading branch information
willallves authored Jun 22, 2022
2 parents 405b05f + 848cbd7 commit 9aea3d8
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions pkg/agent/plugin/workloadattestor/k8s/k8s_posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,31 +337,37 @@ func (p *Plugin) Configure(ctx context.Context, req *configv1.ConfigureRequest)
if err := p.reloadKubeletClient(c); err != nil {
return nil, err
}
if p.sigstore != nil {
if err := configureSigstore(c, p.sigstore); err != nil {
return nil, err
}
}
// Set the config
p.setConfig(c)
return &configv1.ConfigureResponse{}, nil
}

func configureSigstore(config *k8sConfig, sigstore sigstore.Sigstore) error {
// Configure sigstore settings
p.sigstore.ClearSkipList()
if c.SkippedImages != nil {
for _, imageID := range c.SkippedImages {
p.sigstore.AddSkippedImage(imageID)
sigstore.ClearSkipList()
if config.SkippedImages != nil {
for _, imageID := range config.SkippedImages {
sigstore.AddSkippedImage(imageID)
}
}

p.sigstore.EnableAllowSubjectList(c.AllowedSubjectListEnabled)
p.sigstore.ClearAllowedSubjects()
if c.AllowedSubjects != nil {
for _, subject := range c.AllowedSubjects {
p.sigstore.AddAllowedSubject(subject)
sigstore.EnableAllowSubjectList(config.AllowedSubjectListEnabled)
sigstore.ClearAllowedSubjects()
if config.AllowedSubjects != nil {
for _, subject := range config.AllowedSubjects {
sigstore.AddAllowedSubject(subject)
}
}
if c.RekorURL != "" {
if err := p.sigstore.SetRekorURL(c.RekorURL); err != nil {
return nil, err
if config.RekorURL != "" {
if err := sigstore.SetRekorURL(config.RekorURL); err != nil {
return err
}
}

// Set the config
p.setConfig(c)
return &configv1.ConfigureResponse{}, nil
return nil
}

func (p *Plugin) setConfig(config *k8sConfig) {
Expand Down

0 comments on commit 9aea3d8

Please sign in to comment.