Add patch to remove shell=True

Resolves: RHEL-103750
Signed-off-by: Kseniia Nivnia <knivnia@redhat.com>
This commit is contained in:
Kseniia Nivnia 2025-07-17 13:28:37 +01:00
parent 4a67069e8e
commit f5847521bc
No known key found for this signature in database
2 changed files with 40 additions and 0 deletions

View File

@ -9,6 +9,9 @@ License: BSD-3-Clause
URL: https://github.com/aaugustin/websockets
Source0: %{url}/archive/%{version}/%{pypi_name}-%{version}.tar.gz
# remove shell=True from experiments/compression/corpus.py
Patch0: remove-shell-true.patch
BuildRequires: gcc

37
remove-shell-true.patch Normal file
View File

@ -0,0 +1,37 @@
diff --git a/experiments/compression/corpus.py b/experiments/compression/corpus.py
index 56e2621..c8bd343 100644
--- a/experiments/compression/corpus.py
+++ b/experiments/compression/corpus.py
@@ -10,16 +10,17 @@ import time
def github_commits():
OAUTH_TOKEN = getpass.getpass("OAuth Token? ")
- COMMIT_API = (
- f'curl -H "Authorization: token {OAUTH_TOKEN}" '
- f"https://api.github.com/repos/python-websockets/websockets/git/commits/:sha"
- )
+
+ def fetch_commit(sha):
+ url = f"https://api.github.com/repos/python-websockets/websockets/git/commits/{sha}"
+ headers = ["-H", f"Authorization: token {OAUTH_TOKEN}"]
+ cmd = ["curl"] + headers + [url]
+ return subprocess.check_output(cmd)
commits = []
head = subprocess.check_output(
- "git rev-parse origin/main",
- shell=True,
+ ["git", "rev-parse", "origin/main"],
text=True,
).strip()
todo = [head]
@@ -27,7 +28,7 @@ def github_commits():
while todo:
sha = todo.pop(0)
- commit = subprocess.check_output(COMMIT_API.replace(":sha", sha), shell=True)
+ commit = fetch_commit(sha)
commits.append(commit)
seen.add(sha)
for parent in json.loads(commit)["parents"]: