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

Print security notice when index is added #616

Merged
merged 5 commits into from
Jun 29, 2020

Conversation

chriskim06
Copy link
Member

@chriskim06 chriskim06 commented Jun 23, 2020

Right now I have the warning when the index is added as:

WARNING: You have added a new index from "/home/kimc/playground/temp"
The plugins in this index are not audited for security by the Krew maintainers.
Install them at your own risk.

let me know if you guys think I should change this.

Fixes #615
Related issue: #576

/area multi-index

Only print security notice on install/upgrade when plugin comes from
krew-index
@k8s-ci-robot k8s-ci-robot added area/multi-index cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 23, 2020
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jun 23, 2020
@ahmetb
Copy link
Member

ahmetb commented Jun 26, 2020

I think I'm good with this in principle.
/approve
/assign @corneliusweig

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ahmetb, chriskim06

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 26, 2020
@@ -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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TestKrewInstallDoesntShowSecurityWarningForCustomIndex

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1
Even if it looks redundant, it is an important documentation of our intended logic.

@@ -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 {
Copy link
Member

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)

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 26, 2020
}
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])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be better to say Install them at your own risk. for this particular msg.

Copy link
Contributor

@corneliusweig corneliusweig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, looks good to me!

}
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.
Install them at your own risk.`+"\n", args[1])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
Install them at your own risk.`+"\n", args[1])
Install them at your own risk.
`, args[1])

We are already using multiline string litrals with odd indentation. Then let's not bother about prettifying the trailing newline.


test.WithEnv(constants.EnableMultiIndexSwitch, 1).WithDefaultIndex()
out := string(test.Krew("index", "add", "foo", test.TempDir().Path("index/"+constants.DefaultIndexName)).RunOrFailOutput())
if !strings.Contains(out, "WARNING") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also check for a more specific message? Just in case when add prints two warnings, we want to make sure the test asserts on the correct one.

@@ -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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1
Even if it looks redundant, it is an important documentation of our intended logic.

@ahmetb
Copy link
Member

ahmetb commented Jun 29, 2020

/lgtm
Thanks!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 29, 2020
@k8s-ci-robot k8s-ci-robot merged commit bc5bea2 into kubernetes-sigs:master Jun 29, 2020
@chriskim06 chriskim06 deleted the index-warning branch June 29, 2020 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/multi-index cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update security warning for custom indexes
4 participants