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

Bug 1785194: don't gather pod endpoints using tokens #222

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions pkg/cli/admin/inspect/pod.go
Expand Up @@ -65,7 +65,11 @@ func (o *InspectOptions) gatherContainerInfo(destDir string, pod *corev1.Pod, co
if err := o.gatherContainerAllLogs(path.Join(destDir, "/"+container.Name), pod, &container); err != nil {
return err
}

if len(o.restConfig.BearerToken) > 0 {
// token authentication is vulnerable to replays if the token is sent to a potentially untrustworthy source.
klog.V(1).Infof(" Skipping container endpoint collection for pod %q container %q: Using token authentication\n", pod.Name, container.Name)
return nil
}
if len(container.Ports) == 0 {
klog.V(1).Infof(" Skipping container endpoint collection for pod %q container %q: No ports\n", pod.Name, container.Name)
return nil
Expand All @@ -75,7 +79,7 @@ func (o *InspectOptions) gatherContainerInfo(destDir string, pod *corev1.Pod, co
Port: container.Ports[0].ContainerPort,
}

if err := o.gatherContainerEndpoints(path.Join(destDir, "/"+container.Name), pod, &container, port); err != nil {
if err := o.gatherContainerEndpoints(path.Join(destDir, "/"+container.Name), pod, port); err != nil {
klog.V(1).Infof(" Skipping one or more container endpoint collection for pod %q container %q: %v\n", pod.Name, container.Name, err)
}

Expand All @@ -99,7 +103,7 @@ func (o *InspectOptions) gatherContainerAllLogs(destDir string, pod *corev1.Pod,
return nil
}

func (o *InspectOptions) gatherContainerEndpoints(destDir string, pod *corev1.Pod, container *corev1.Container, metricsPort *RemoteContainerPort) error {
func (o *InspectOptions) gatherContainerEndpoints(destDir string, pod *corev1.Pod, metricsPort *RemoteContainerPort) error {
// ensure destination path exists
if err := os.MkdirAll(destDir, os.ModePerm); err != nil {
return err
Expand Down