Skip to content
Open
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
6 changes: 3 additions & 3 deletions Kubeadm_Installation_Scripts_and_Documentation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ This guide outlines the steps needed to set up a Kubernetes cluster using `kubea

2. **Set Up Local kubeconfig**:
```bash
mkdir -p "$HOME"/.kube
sudo cp -i /etc/kubernetes/admin.conf "$HOME"/.kube/config
sudo chown "$(id -u)":"$(id -g)" "$HOME"/.kube/config
mkdir -p $HOME/.kube
sudo cp /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
Comment on lines +135 to +137
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Revert to quoted paths and command substitutions for shell safety.

The changes remove quotes around $HOME, $(id -u), and $(id -g), which violates shell scripting best practices. Unquoted variable and command substitution expansions are vulnerable to word-splitting and glob expansion if paths contain spaces or special characters. Additionally, the removal of the -i flag from cp changes behavior by making the command non-interactive.

Revert to the original quoted syntax to maintain shell safety:

- mkdir -p $HOME/.kube
- sudo cp /etc/kubernetes/admin.conf $HOME/.kube/config
- sudo chown $(id -u):$(id -g) $HOME/.kube/config
+ mkdir -p "$HOME"/.kube
+ sudo cp -i /etc/kubernetes/admin.conf "$HOME"/.kube/config
+ sudo chown "$(id -u)":"$(id -g)" "$HOME"/.kube/config

Per shell scripting best practices (POSIX, ShellCheck, Google Shell Style Guide), always quote variable expansions and command substitutions unless word-splitting is explicitly intended.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
mkdir -p $HOME/.kube
sudo cp /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
mkdir -p "$HOME"/.kube
sudo cp -i /etc/kubernetes/admin.conf "$HOME"/.kube/config
sudo chown "$(id -u)":"$(id -g)" "$HOME"/.kube/config
🤖 Prompt for AI Agents
In Kubeadm_Installation_Scripts_and_Documentation/README.md around lines
135-137, the three commands dropped necessary quoting and the -i flag on cp;
restore shell-safe syntax by quoting $HOME (e.g., "$HOME"), quoting the
destination config path (e.g., "$HOME/.kube/config"), and quoting the command
substitutions for ownership (e.g., "$(id -u)" and "$(id -g)"); also restore the
interactive flag on cp (use sudo cp -i ...) so the copy remains interactive.

```

3. **Install a Network Plugin (Calico)**:
Expand Down