-
Notifications
You must be signed in to change notification settings - Fork 371
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
Print security notice when index is added #616
Changes from 1 commit
90d2da2
be13d52
018003f
56ac20d
c2d0f7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,7 +75,13 @@ var indexAddCmd = &cobra.Command{ | |
if !indexoperations.IsValidIndexName(name) { | ||
return errInvalidIndexName | ||
} | ||
return indexoperations.AddIndex(paths, name, args[1]) | ||
err := indexoperations.AddIndex(paths, name, args[1]) | ||
if err == nil { | ||
internal.PrintWarning(os.Stderr, `You have added a new index from %q | ||
The plugins in this index are not audited for security by the Krew maintainers. | ||
Run them at your own risk.`+"\n", args[1]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be better to say |
||
} | ||
return err | ||
}, | ||
} | ||
|
||
|
@@ -86,7 +92,7 @@ var indexDeleteCmd = &cobra.Command{ | |
|
||
It is only safe to remove indexes without installed plugins. Removing an index | ||
while there are plugins installed will result in an error, unless the --force | ||
option is used ( not recommended).`, | ||
option is used (not recommended).`, | ||
|
||
Args: cobra.ExactArgs(1), | ||
RunE: indexDelete, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ import ( | |
"sigs.k8s.io/krew/internal/installation" | ||
"sigs.k8s.io/krew/internal/installation/receipt" | ||
"sigs.k8s.io/krew/internal/pathutil" | ||
"sigs.k8s.io/krew/pkg/constants" | ||
) | ||
|
||
func init() { | ||
|
@@ -104,7 +105,9 @@ kubectl krew upgrade foo bar"`, | |
return errors.Wrapf(err, "failed to upgrade plugin %q", pluginDisplayName) | ||
} | ||
fmt.Fprintf(os.Stderr, "Upgraded plugin: %s\n", pluginDisplayName) | ||
internal.PrintSecurityNotice(plugin.Name) | ||
if indexName == constants.DefaultIndexName { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TestKrewInstallDoesntShowSecurityWarningForCustomIndex There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 |
||
internal.PrintSecurityNotice(plugin.Name) | ||
} | ||
} | ||
if nErrors > 0 { | ||
fmt.Fprintf(os.Stderr, "WARNING: Some plugins failed to upgrade, check logs above.\n") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
if err != nil { return err}
then printing this outside the if-block would be better.also worth adding tests for (just to check WARNING: exists)