fix(tools): prevent command injection in px_mkfw.py (#26678)

* fix(tools): prevent command injection in px_mkfw.py

* copilot review: only capture stdout
This commit is contained in:
Jacob Dahl 2026-03-06 14:23:20 -09:00 committed by GitHub
parent ec56d2d83b
commit 343fd01e19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -42,6 +42,7 @@
import argparse
import json
import base64
import os
import zlib
import time
import subprocess
@ -99,14 +100,13 @@ if args.summary != None:
if args.description != None:
desc['description'] = str(args.description)
if args.git_identity != None:
cmd = "git --git-dir '{:}/.git' describe --exclude ext/* --always --tags".format(args.git_identity)
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout
desc['git_identity'] = p.read().strip().decode('utf-8')
p.close()
cmd = "git --git-dir '{:}/.git' rev-parse --verify HEAD".format(args.git_identity)
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout
desc['git_hash'] = p.read().strip().decode('utf-8')
p.close()
git_dir = os.path.join(args.git_identity, '.git')
p = subprocess.run(["git", "--git-dir", git_dir, "describe", "--exclude", "ext/*", "--always", "--tags"],
stdout=subprocess.PIPE, text=True)
desc['git_identity'] = p.stdout.strip()
p = subprocess.run(["git", "--git-dir", git_dir, "rev-parse", "--verify", "HEAD"],
stdout=subprocess.PIPE, text=True)
desc['git_hash'] = p.stdout.strip()
if args.parameter_xml != None:
f = open(args.parameter_xml, "rb")
bytes = f.read()