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

don't print security notice for krew itself #486

Merged
merged 1 commit into from
Jan 30, 2020
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
2 changes: 1 addition & 1 deletion cmd/krew/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Remarks:
output += fmt.Sprintf("Caveats:\n%s\n", indent(plugin.Spec.Caveats))
}
fmt.Fprintln(os.Stderr, indent(output))
internal.PrintSecurityNotice()
internal.PrintSecurityNotice(plugin.Name)
}
if len(failed) > 0 {
return errors.Wrapf(returnErr, "failed to install some plugins: %+v", failed)
Expand Down
12 changes: 9 additions & 3 deletions cmd/krew/cmd/internal/security_notice.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,19 @@ import (
"os"

"github.com/fatih/color"

"sigs.k8s.io/krew/pkg/constants"
)

const securityNotice = `You installed a plugin from the krew-index plugin repository.
const securityNotice = `You installed plugin %q from the krew-index plugin repository.
These plugins are not audited for security by the Krew maintainers.
Run them at your own risk.`

func PrintSecurityNotice() {
func PrintSecurityNotice(plugin string) {
if plugin == constants.KrewPluginName {
return // do not warn for krew itself
}
boldRed := color.New(color.FgRed, color.Bold).SprintfFunc()
fmt.Fprintf(os.Stderr, "%s: %s\n", boldRed("WARNING"), securityNotice)
msg := fmt.Sprintf(securityNotice, plugin)
fmt.Fprintf(os.Stderr, "%s: %s\n", boldRed("WARNING"), msg)
}
2 changes: 1 addition & 1 deletion cmd/krew/cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ kubectl krew upgrade foo bar"`,
return errors.Wrapf(err, "failed to upgrade plugin %q", name)
}
fmt.Fprintf(os.Stderr, "Upgraded plugin: %s\n", name)
internal.PrintSecurityNotice()
internal.PrintSecurityNotice(plugin.Name)
}
if nErrors > 0 {
fmt.Fprintf(os.Stderr, "WARNING: Some plugins failed to upgrade, check logs above.\n")
Expand Down