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

Whether the output directory of the kubectl-edit-xxx.yaml file is configurable #126993

Open
kangzhiqin opened this issue Aug 29, 2024 · 7 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. sig/cli Categorizes an issue or PR as relevant to SIG CLI. sig/security Categorizes an issue or PR as relevant to SIG Security.

Comments

@kangzhiqin
Copy link

What would you like to be added?

When kubectl edits resources, a kubectl-edit-xxx.yaml file is generated in the /tmp directory. Can this file be generated in other directories or can it be configured? In actual applications, the /tmp directory has security risks.
image

The code is probably in this location:

}
// launch the editor
editedDiff := edited
edited, file, err = edit.LaunchTempFile(fmt.Sprintf("%s-edit-", filepath.Base(os.Args[0])), o.editPrinterOptions.ext, buf)
if err != nil {
return preservedFile(err, results.file, o.ErrOut)
}
// If we're retrying the loop because of an error, and no change was made in the file, short-circuit
if containsError && bytes.Equal(cmdutil.StripComments(editedDiff), cmdutil.StripComments(edited)) {

Why is this needed?

The /tmp directory has security risks. It is recommended that logs be stored in other directories or be configurable.

k8s version is 1.28.1

@kangzhiqin kangzhiqin added the kind/feature Categorizes issue or PR as related to a new feature. label Aug 29, 2024
@k8s-ci-robot k8s-ci-robot added needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Aug 29, 2024
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@neolit123
Copy link
Member

/sig cli

@k8s-ci-robot k8s-ci-robot added sig/cli Categorizes an issue or PR as relevant to SIG CLI. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Aug 29, 2024
@github-project-automation github-project-automation bot moved this to Needs Triage in SIG CLI Aug 29, 2024
@neolit123
Copy link
Member

/sig security

@k8s-ci-robot k8s-ci-robot added the sig/security Categorizes an issue or PR as relevant to SIG Security. label Aug 29, 2024
@BenTheElder
Copy link
Member

When kubectl edits resources, a kubectl-edit-xxx.yaml file is generated in the /tmp directory. Can this file be generated in other directories or can it be configured?

https://github.com/kubernetes/kubernetes/blob/baf11b01c5420aeb5b1f7d9b91eb76a2110b98f9/staging/src/k8s.io/kubectl/pkg/cmd/util/editor/editor.go#L97C15-L97C25

https://pkg.go.dev/os#CreateTemp which follows https://pkg.go.dev/os#TempDir

You can influence it by setting TMPDIR environment variable

In actual applications, the /tmp directory has security risks.

The /tmp directory has security risks. It is recommended that logs be stored in other directories or be configurable.

This isn't a log file, and anywhere we create a file there's roughly the same issues with access control and other processes.

What do you propose instead?

@kangzhiqin
Copy link
Author

When kubectl edits resources, a kubectl-edit-xxx.yaml file is generated in the /tmp directory. Can this file be generated in other directories or can it be configured?

https://github.com/kubernetes/kubernetes/blob/baf11b01c5420aeb5b1f7d9b91eb76a2110b98f9/staging/src/k8s.io/kubectl/pkg/cmd/util/editor/editor.go#L97C15-L97C25

https://pkg.go.dev/os#CreateTemp which follows https://pkg.go.dev/os#TempDir

You can influence it by setting TMPDIR environment variable

In actual applications, the /tmp directory has security risks.

The /tmp directory has security risks. It is recommended that logs be stored in other directories or be configurable.

This isn't a log file, and anywhere we create a file there's roughly the same issues with access control and other processes.

What do you propose instead?

Thank you for your reply. Can you add a configuration parameter to specify the output directory and consider the file aging?

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 29, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle rotten
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Dec 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. sig/cli Categorizes an issue or PR as relevant to SIG CLI. sig/security Categorizes an issue or PR as relevant to SIG Security.
Projects
Status: Needs Triage
Development

No branches or pull requests

5 participants