You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(openshift): Address security concern by creating temporary dir
- Update `collect_ovn_data.py` and `analyze_placement.py` to require a private temporary directory for file operations, improving security.
- Implement safe file writing and appending methods in `ovn_utils.py` to prevent symlink attacks.
- Refactor file handling to ensure all output is directed to the specified temporary directory.
Signed-off-by: Matteo Dallaglio <[email protected]>
Copy file name to clipboardExpand all lines: plugins/openshift/skills/generating-ovn-topology/SKILL.md
+20-14Lines changed: 20 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
name: generating-ovn-topology
3
-
description: Generates and displays OVN-Kubernetes network topology diagrams showing logical switches, routers, ports, and load balancers with IP/MAC addresses in Mermaid format
3
+
description: Generates and displays OVN-Kubernetes network topology diagrams showing logical switches, routers, ports with IP/MAC addresses in Mermaid format
4
4
tools: [Bash, Read, Write]
5
5
---
6
6
@@ -91,9 +91,15 @@ tools: [Bash, Read, Write]
91
91
3.**Check Output File**: Ask user if `ovn-topology-diagram.md` exists:
- Skip UUID column when parsing switches/routers detail files
118
124
- If placement is `per-node` → put inside node subgraph
119
125
- If placement is `cluster-wide` or `cluster-wide-visual` → put outside subgraphs
120
126
121
-
7.**Save & Report**: Write diagram to file, show summary, clean up temporary files
127
+
8.**Save & Report**: Write diagram to file, show summary, clean up temporary files
122
128
123
129
**CRITICAL RULES**:
124
130
- ❌ NO codebase searching for IPs/MACs
@@ -127,8 +133,9 @@ tools: [Bash, Read, Write]
127
133
- ❌ NO direct kubectl commands (must use helper scripts only)
128
134
- ✅ Always use `KUBECONFIG="$KC" kubectl --kubeconfig="$KC"` for kubectl commands
129
135
- ✅ Use helper scripts for architecture discovery
130
-
- ✅ Temporary files use `$TMPDIR` (defaults to `/tmp/` if not set)
131
-
- ✅ Clean up temporary files when done
136
+
- ✅ **SECURITY**: Create private temp directory with `TMPDIR=$(mktemp -d)` - never use `/tmp` directly
137
+
- ✅ Temporary files use `$TMPDIR` (private directory created with mkdtemp)
138
+
- ✅ Clean up temporary files when done: `rm -rf "$TMPDIR"`
132
139
133
140
## Safety & Security Guarantees
134
141
@@ -177,7 +184,7 @@ All helper scripts are in the `scripts/` directory.
177
184
|--------|---------|-------|--------|
178
185
|[detect-cluster.sh](scripts/detect-cluster.sh)| Find OVN cluster kubeconfig across all contexts. Scans multiple kubeconfig files and all their contexts. Returns parseable list. | None | Parseable list to stdout: `index|kubeconfig|cluster|nodes|namespace`. Exit: 0=success, 1=none found |
179
186
|[check_permissions.py](scripts/check_permissions.py)| Check user permissions and warn if write access detected. | KUBECONFIG path | Exit: 0=proceed, 1=cancelled/error, 2=write perms (needs user confirmation) |
180
-
|[collect_ovn_data.py](scripts/collect_ovn_data.py)|**Data collector**: Queries each node for all data, with **graceful degradation** (continues on node failures). Writes detail files. | KUBECONFIG path | Detail files: `ovn_switches_detail.txt`, `ovn_routers_detail.txt`, `ovn_lsps_detail.txt`, `ovn_lrps_detail.txt`, `ovn_pods_detail.txt`|
187
+
|[collect_ovn_data.py](scripts/collect_ovn_data.py)|**Data collector**: Queries each node for all data, with **graceful degradation** (continues on node failures). Writes detail files. | KUBECONFIG path, TMPDIR| Detail files: `ovn_switches_detail.txt`, `ovn_routers_detail.txt`, `ovn_lsps_detail.txt`, `ovn_lrps_detail.txt`, `ovn_pods_detail.txt`|
181
188
|[analyze_placement.py](scripts/analyze_placement.py)|**Placement analyzer**: Analyzes UUID patterns from detail files to determine per-node vs cluster-wide placement. | TMPDIR (reads detail files) | Placement files: `ovn_switch_placement.txt`, `ovn_router_placement.txt`|
0 commit comments