fix(packaging): resolve SonarCloud regex reliability findings in nightly-release-tests.py (#10076)

This commit is contained in:
Dylan M. Taylor authored and GitHub committed 2026-11-29 08:26:47 -05:00
1 parent d4d8da4544
commit b3514b6277
1 file changed
+9 -3
+9 -3
View File
@@ -110,7 +110,7 @@ def assert_caller_secrets(source, job_name, names):
for value, children in (*root.values(), *job.values()):
outside_map = "\n".join([value or "", *children])
# Scan all remaining text: quoted braces can appear before a secret reference.
if re.search(r"(?im)^\s*environment:|\bsecrets\b", outside_map):
if re.search(r"(?im)(?:^\s*environment:)|(?:\bsecrets\b)", outside_map):
raise ValueError("secret bindings belong only in the signer map")
@@ -600,10 +600,13 @@ def app_workflows():
return {path.name: path.read_text() for path in sorted((ROOT / ".github/workflows").glob("*.y*ml"))}
WORKFLOW_KEY = re.compile(r'''("(?:[^"\\]|\\.)*"|'(?:[^']|'')*'|[^\s'"#{}\[\],:&*!|>%@`?-][^:#,{}]*?|-[^\s:#][^:#,{}]*?)\s*:(?:\s+(.*))?$''')
WORKFLOW_KEY = re.compile(
r'''((?:"(?:[^"\\]|\\.)*"|'(?:[^']|'')*')[ \t]*|[^\s'"#{}\[\],:&*!|>%@`?-][^:#,{}]*|-[^\s:#][^:#,{}]*):(?:[ \t]+(.*))?$'''
)
def _workflow_key(text):
text = text.rstrip()
if text.startswith('"'):
return None if "\\" in text else text[1:-1]
if text.startswith("'"):
@@ -620,7 +623,10 @@ def _workflow_value(text):
if text.startswith("'"):
quoted = re.match(r"'((?:[^']|'')*)'\s*(?:#.*)?$", text)
return None if quoted is None else quoted.group(1).replace("''", "'")
return re.split(r"\s+#", text, maxsplit=1)[0].strip()
for idx, ch in enumerate(text):
if ch == "#" and idx > 0 and text[idx - 1].isspace():
return text[:idx].rstrip()
return text
def _strip_comment(text):