Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing privacy statement, print in multiple locations #2622

Merged
merged 1 commit into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions cmd/cosign/cli/fulcio/fulcio.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ import (
"golang.org/x/term"

"github.com/sigstore/cosign/v2/cmd/cosign/cli/options"
"github.com/sigstore/cosign/v2/cmd/cosign/cli/sign/privacy"
"github.com/sigstore/cosign/v2/internal/pkg/cosign/fulcio/fulcioroots"
"github.com/sigstore/cosign/v2/internal/ui"
"github.com/sigstore/cosign/v2/pkg/cosign"
"github.com/sigstore/cosign/v2/pkg/providers"
"github.com/sigstore/fulcio/pkg/api"
Expand Down Expand Up @@ -158,6 +160,19 @@ func NewSigner(ctx context.Context, ko options.KeyOpts) (*Signer, error) {
fmt.Fprintln(os.Stderr, "Non-interactive mode detected, using device flow.")
flow = flowDevice
default:
var statementErr error
privacy.StatementOnce.Do(func() {
ui.Info(ctx, privacy.Statement)
ui.Info(ctx, privacy.StatementConfirmation)
if !ko.SkipConfirmation {
if err := ui.ConfirmContinue(ctx); err != nil {
statementErr = err
}
}
})
if statementErr != nil {
return nil, statementErr
}
flow = flowNormal
}
Resp, err := GetCert(ctx, priv, idToken, flow, ko.OIDCIssuer, ko.OIDCClientID, ko.OIDCClientSecret, ko.OIDCRedirectURL, fClient) // TODO, use the chain.
Expand Down
31 changes: 31 additions & 0 deletions cmd/cosign/cli/sign/privacy/privacy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2022 The Sigstore Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package privacy

import "sync"

const (
// spacing is intentional to have this indented
Statement = `
Note that there may be personally identifiable information associated with this signed artifact.
This may include the email address associated with the account with which you authenticate.
This information will be used for signing this artifact and will be stored in public transparency logs and cannot be removed later.
`
StatementConfirmation = "By typing 'y', you attest that you grant (or have permission to grant) and agree to have this information stored permanently in transparency logs."
)

var (
StatementOnce sync.Once
)
20 changes: 4 additions & 16 deletions cmd/cosign/cli/sign/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"os"
"path/filepath"
"strings"
"sync"

"github.com/google/go-containerregistry/pkg/name"
v1 "github.com/google/go-containerregistry/pkg/v1"
Expand All @@ -35,6 +34,7 @@ import (
"github.com/sigstore/cosign/v2/cmd/cosign/cli/fulcio/fulcioverifier"
"github.com/sigstore/cosign/v2/cmd/cosign/cli/options"
"github.com/sigstore/cosign/v2/cmd/cosign/cli/rekor"
"github.com/sigstore/cosign/v2/cmd/cosign/cli/sign/privacy"
icos "github.com/sigstore/cosign/v2/internal/pkg/cosign"
ifulcio "github.com/sigstore/cosign/v2/internal/pkg/cosign/fulcio"
ipayload "github.com/sigstore/cosign/v2/internal/pkg/cosign/payload"
Expand Down Expand Up @@ -68,25 +68,13 @@ const TagReferenceMessage string = `Image reference %s uses a tag, not a digest,
images by tag will be removed in a future release.
`

const (
// spacing is intentional to have this indented
privacyStatement = `
Note that there may be personally identifiable information associated with this signed artifact.
This may include the email address associated with the account with which you authenticate.
This information will be used for signing this artifact and will be stored in public transparency logs and cannot be removed later.`
privacyStatementConfirmation = "By typing 'y', you attest that you grant (or have permission to grant) and agree to have this information stored permanently in transparency logs."
)

var (
privacyStatementOnce sync.Once
)

func ShouldUploadToTlog(ctx context.Context, ko options.KeyOpts, ref name.Reference, tlogUpload bool) (bool, error) {
upload := shouldUploadToTlog(ctx, ko, ref, tlogUpload)
var statementErr error
if upload {
privacyStatementOnce.Do(func() {
ui.Info(ctx, privacyStatementConfirmation)
privacy.StatementOnce.Do(func() {
ui.Info(ctx, privacy.Statement)
ui.Info(ctx, privacy.StatementConfirmation)
if !ko.SkipConfirmation {
if err := ui.ConfirmContinue(ctx); err != nil {
statementErr = err
Expand Down