diff --git a/flask_webgoat/actions.py b/flask_webgoat/actions.py index 8820d7b2..82060c57 100644 --- a/flask_webgoat/actions.py +++ b/flask_webgoat/actions.py @@ -47,15 +47,18 @@ def grep_processes(): ) if res.stdout is None: return jsonify({"error": "no stdout returned"}) + out = res.stdout.decode("utf-8") lines = out.split("\n") - # Filter lines containing the name and extract the 11th field (command) + + # Filter lines containing the name and extract the 11th column (command) names = [] for line in lines: - if name and name in line: + if name in line: parts = line.split() if len(parts) >= 11: - names.append(parts[10]) # 0-indexed, so field 11 is index 10 + names.append(parts[10]) # 0-indexed, so 11th column is index 10 + return jsonify({"success": True, "names": names})