From 075561f75cf9129eb2bebe4b6d88ab249b4737ae Mon Sep 17 00:00:00 2001 From: Musiker15 Date: Tue, 10 Nov 2026 11:11:17 +0100 Subject: [PATCH 1/9] =?UTF-8?q?Bericht=20z=C3=A4hlt=20nur=20am=20Ende=20de?= =?UTF-8?q?r=20Antwort?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Eine zitierte Zeile REVIEW_RESULT: clean irgendwo im Bericht machte das Ergebnis grün, und ein zitierter Block PRIVATE-FINDINGS wurde zu Alerts und schnitt den echten Bericht ab. --- .github/workflows/security-review.yml | 53 ++++++++++++++++----------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/.github/workflows/security-review.yml b/.github/workflows/security-review.yml index d178f49..6db90a8 100644 --- a/.github/workflows/security-review.yml +++ b/.github/workflows/security-review.yml @@ -1327,28 +1327,37 @@ jobs: answer = event if event.get('subtype') == 'success' and not event.get('is_error') else None report = (answer or {}).get('result') or '' - private = [] - block = re.search(r'', report, re.S) - if block: - report = report[:block.start()] + report[block.end():] - try: - found = json.loads(block.group(1)) - private = [entry for entry in found if isinstance(entry, dict)] - except json.JSONDecodeError: - private = [{'file': '', 'line': 1, 'title': 'Privater Befund, nicht lesbar', - 'severity': 'medium', 'description': block.group(1)[:4000]}] - # Anything else that looks like the start of such a block stays out - # of the public report as well. - report = re.sub(r'', + body[starts[-1]:], re.S) + if block: + body = body[:starts[-1]].rstrip() + try: + entries = json.loads(block.group(1)) + private = [entry for entry in entries if isinstance(entry, dict)] if isinstance(entries, list) else [] + except json.JSONDecodeError: + private = [{'file': '', 'line': 1, 'title': 'Privater Befund, nicht lesbar', + 'severity': 'medium', 'description': block.group(1)[:4000]}] + if len(starts) > (1 if block else 0): + # Out of the public report as well, whole or up to the end. + body = re.sub(r'|\Z)', '', body, flags=re.S) + if result == 'clean': + result = 'unclear' + report = body + '\n\n' + '\n'.join(line.strip() for line in lines[-2:]) + '\n' with open(os.path.join(temp, 'result', 'report.md'), 'w', encoding='utf-8') as handle: handle.write(report) with open(os.path.join(temp, 'result', 'result.txt'), 'w', encoding='utf-8') as handle: From 115a3d166a54181cb256fe95e894c69dd46716a1 Mon Sep 17 00:00:00 2001 From: Musiker15 Date: Tue, 10 Nov 2026 11:29:56 +0100 Subject: [PATCH 2/9] =?UTF-8?q?Privater=20Block=20beginnt=20am=20Zeilenanf?= =?UTF-8?q?ang,=20L=C3=A4nge=20z=C3=A4hlt=20ohne=20ihn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Eine Marke in einer Beschreibung zerlegte den Block und konnte Teile davon öffentlich machen; verworfene Marken stehen jetzt gezählt im Log. --- .github/workflows/security-review.yml | 37 +++++++++++++++++---------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/.github/workflows/security-review.yml b/.github/workflows/security-review.yml index 6db90a8..f84e9f2 100644 --- a/.github/workflows/security-review.yml +++ b/.github/workflows/security-review.yml @@ -1334,37 +1334,48 @@ jobs: # line or a block further up may be quoted from the pull request and # decides nothing; a marker of such a block there leaves the result # no better than unclear. + marker = r'', - body[starts[-1]:], re.S) + if heads: + block = re.fullmatch(r'[ \t]*' + marker + r'\s*(.*?)\s*PRIVATE-FINDINGS\s*-->', + body[heads[-1]:], re.S) if block: - body = body[:starts[-1]].rstrip() + body = body[:heads[-1]].rstrip() try: entries = json.loads(block.group(1)) private = [entry for entry in entries if isinstance(entry, dict)] if isinstance(entries, list) else [] except json.JSONDecodeError: private = [{'file': '', 'line': 1, 'title': 'Privater Befund, nicht lesbar', 'severity': 'medium', 'description': block.group(1)[:4000]}] - if len(starts) > (1 if block else 0): - # Out of the public report as well, whole or up to the end. - body = re.sub(r'|\Z)', '', body, flags=re.S) + # Every marker left further up: out of the public report as well, + # whole or up to the end, counted in the log without its content. + dropped = len(re.findall(marker, body)) + if dropped: + body = re.sub(marker + r'.*?(?:PRIVATE-FINDINGS\s*-->|\Z)', '', body, flags=re.S) if result == 'clean': result = 'unclear' - report = body + '\n\n' + '\n'.join(line.strip() for line in lines[-2:]) + '\n' - with open(os.path.join(temp, 'result', 'report.md'), 'w', encoding='utf-8') as handle: - handle.write(report) + # The least length is that of the public report, as before. + if len(body) < 500: + result = 'missing' + else: + report = body + '\n\n' + '\n'.join(line.strip() for line in lines[-2:]) + '\n' + with open(os.path.join(temp, 'result', 'report.md'), 'w', encoding='utf-8') as handle: + handle.write(report) with open(os.path.join(temp, 'result', 'result.txt'), 'w', encoding='utf-8') as handle: handle.write(result + '\n') with open(os.path.join(temp, 'private', 'findings.json'), 'w', encoding='utf-8') as handle: json.dump(private, handle) - print(f'Ergebnis: {result}, private Befunde: {len(private)}') + print(f'Ergebnis: {result}, private Befunde: {len(private)}, verworfene Blockmarken: {dropped}') PYTHON - name: Private Befunde als Code-Scanning-Alerts ablegen From 5489895911b3c94e094099e91acc7ac42c394032 Mon Sep 17 00:00:00 2001 From: Musiker15 Date: Tue, 10 Nov 2026 11:51:50 +0100 Subject: [PATCH 3/9] =?UTF-8?q?Bericht=20endet=20vor=20jeder=20=C3=BCbrige?= =?UTF-8?q?n=20Blockmarke,=20jeder=20Block=20wird=20ein=20Alert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Eine Schlussmarke in einer Beschreibung ließ den Rest eines Blocks öffentlich, ein Objekt statt einer Liste ging still verloren, und langer Leerraum ließ den Ausdruck für das Blockende kubisch laufen. --- .github/workflows/security-review.yml | 28 ++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/.github/workflows/security-review.yml b/.github/workflows/security-review.yml index f84e9f2..ce59815 100644 --- a/.github/workflows/security-review.yml +++ b/.github/workflows/security-review.yml @@ -1347,21 +1347,31 @@ jobs: heads = [match.start() for match in re.finditer(r'(?m)^[ \t]*' + marker, body)] block = None if heads: - block = re.fullmatch(r'[ \t]*' + marker + r'\s*(.*?)\s*PRIVATE-FINDINGS\s*-->', - body[heads[-1]:], re.S) - if block: + # The end is checked anchored, so no run of blanks makes the + # match backtrack. + tail = re.sub(r'\A[ \t]*' + marker, '', body[heads[-1]:], count=1) + closing = re.search(r'PRIVATE-FINDINGS\s*-->\Z', tail) + block = tail[:closing.start()].strip() if closing else None + if block is not None: body = body[:heads[-1]].rstrip() try: - entries = json.loads(block.group(1)) - private = [entry for entry in entries if isinstance(entry, dict)] if isinstance(entries, list) else [] + entries = json.loads(block) except json.JSONDecodeError: + entries = None + entries = [entries] if isinstance(entries, dict) else entries + # A block found here never goes without an alert: any other + # form becomes one entry that says so. + if isinstance(entries, list) and all(isinstance(entry, dict) for entry in entries): + private = entries + else: private = [{'file': '', 'line': 1, 'title': 'Privater Befund, nicht lesbar', - 'severity': 'medium', 'description': block.group(1)[:4000]}] - # Every marker left further up: out of the public report as well, - # whole or up to the end, counted in the log without its content. + 'severity': 'medium', 'description': block[:4000]}] + # Every marker left further up: the public report ends before the + # first of them, whatever its strings hold, and the log counts + # them without their content. dropped = len(re.findall(marker, body)) if dropped: - body = re.sub(marker + r'.*?(?:PRIVATE-FINDINGS\s*-->|\Z)', '', body, flags=re.S) + body = body[:re.search(marker, body).start()].rstrip() if result == 'clean': result = 'unclear' # The least length is that of the public report, as before. From 4fa60062551be42f45b3f85577b52115495b2b3f Mon Sep 17 00:00:00 2001 From: Musiker15 Date: Tue, 10 Nov 2026 11:55:39 +0100 Subject: [PATCH 4/9] =?UTF-8?q?Vorletzte=20Zeile=20ohne=20Ergebnis=20z?= =?UTF-8?q?=C3=A4hlt=20zum=20Bericht?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So durchläuft sie den Filter für private Blöcke, statt ungefiltert in den öffentlichen Bericht zu gehen. --- .github/workflows/security-review.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/security-review.yml b/.github/workflows/security-review.yml index ce59815..6d010d7 100644 --- a/.github/workflows/security-review.yml +++ b/.github/workflows/security-review.yml @@ -1340,7 +1340,10 @@ jobs: if len(lines) >= 2 and lines[-1].strip() == 'REVIEW_COMPLETE': found = re.fullmatch(r'REVIEW_RESULT:\s*(clean|findings)', lines[-2].strip()) result = found.group(1) if found else 'unclear' - body = '\n'.join(lines[:-2]).rstrip() + # Not a result line, the line before REVIEW_COMPLETE belongs to + # the report and goes through the same filter as the rest. + closing_lines = lines[-2:] if found else lines[-1:] + body = '\n'.join(lines[:len(lines) - len(closing_lines)]).rstrip() # The block starts at the start of a line: a JSON string holds no # raw line break, so a marker there is never one a description # quotes. @@ -1378,7 +1381,7 @@ jobs: if len(body) < 500: result = 'missing' else: - report = body + '\n\n' + '\n'.join(line.strip() for line in lines[-2:]) + '\n' + report = body + '\n\n' + '\n'.join(line.strip() for line in closing_lines) + '\n' with open(os.path.join(temp, 'result', 'report.md'), 'w', encoding='utf-8') as handle: handle.write(report) with open(os.path.join(temp, 'result', 'result.txt'), 'w', encoding='utf-8') as handle: From f2881b06933e6480656a18319476b37f1809792f Mon Sep 17 00:00:00 2001 From: Musiker15 Date: Tue, 10 Nov 2026 12:03:32 +0100 Subject: [PATCH 5/9] =?UTF-8?q?Verworfene=20Bl=C3=B6cke=20werden=20private?= =?UTF-8?q?=20Alerts,=20Leerzeilen=20am=20Ende=20z=C3=A4hlen=20nicht?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Weicht das Ende der Antwort leicht ab, ging ein privater Befund sonst ohne Spur verloren; die Mindestlänge zählt wieder am ganzen öffentlichen Bericht. --- .github/workflows/security-review.yml | 53 +++++++++++++++++---------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/.github/workflows/security-review.yml b/.github/workflows/security-review.yml index 6d010d7..89f4d0b 100644 --- a/.github/workflows/security-review.yml +++ b/.github/workflows/security-review.yml @@ -1330,20 +1330,24 @@ jobs: lines = report.strip().split('\n') # Only the end of the answer counts, where the prompt puts it: the # last line REVIEW_COMPLETE, the one before it the result, right - # above them the block of private findings, if there is one. A result - # line or a block further up may be quoted from the pull request and - # decides nothing; a marker of such a block there leaves the result - # no better than unclear. + # above them the block of private findings, if there is one; blank + # lines between them do not count. A result line or a block further + # up may be quoted from the pull request and decides nothing; a + # marker of such a block there leaves the result no better than + # unclear. marker = r'') + filled = [index for index, line in enumerate(lines) if line.strip()] + result, private, body, closing_lines = 'missing', [], report, [] + if filled and lines[filled[-1]].strip() == 'REVIEW_COMPLETE': + found = None + if len(filled) >= 2: + found = re.fullmatch(r'REVIEW_RESULT:\s*(clean|findings)', lines[filled[-2]].strip()) result = found.group(1) if found else 'unclear' # Not a result line, the line before REVIEW_COMPLETE belongs to # the report and goes through the same filter as the rest. - closing_lines = lines[-2:] if found else lines[-1:] - body = '\n'.join(lines[:len(lines) - len(closing_lines)]).rstrip() + closing_lines = [found.group(0), 'REVIEW_COMPLETE'] if found else ['REVIEW_COMPLETE'] + body = '\n'.join(lines[:filled[-2] if found else filled[-1]]).rstrip() # The block starts at the start of a line: a JSON string holds no # raw line break, so a marker there is never one a description # quotes. @@ -1369,19 +1373,28 @@ jobs: else: private = [{'file': '', 'line': 1, 'title': 'Privater Befund, nicht lesbar', 'severity': 'medium', 'description': block[:4000]}] - # Every marker left further up: the public report ends before the - # first of them, whatever its strings hold, and the log counts - # them without their content. - dropped = len(re.findall(marker, body)) - if dropped: - body = body[:re.search(marker, body).start()].rstrip() - if result == 'clean': - result = 'unclear' + # Every marker left, further up or in an answer without its end: the + # public report ends before the first of them, whatever its strings + # hold. What each holds goes to a private alert of its own, marked + # unchecked: it may be quoted from the pull request, but a finding + # of the agent is never lost on the way. The log counts them. + leftover = list(re.finditer(marker, body)) + dropped = len(leftover) + for match in leftover: + end = closing_marker.search(body, match.end()) + content = body[match.end():end.start() if end else len(body)].strip() + private.append({'file': '', 'line': 1, 'title': 'Privater Block verworfen, Inhalt ungeprüft', + 'severity': 'medium', 'description': content[:4000]}) + if dropped: + body = body[:leftover[0].start()].rstrip() + if result == 'clean': + result = 'unclear' + if result != 'missing': + report = body + '\n\n' + '\n'.join(closing_lines) + '\n' # The least length is that of the public report, as before. - if len(body) < 500: + if len(report) < 500: result = 'missing' else: - report = body + '\n\n' + '\n'.join(line.strip() for line in closing_lines) + '\n' with open(os.path.join(temp, 'result', 'report.md'), 'w', encoding='utf-8') as handle: handle.write(report) with open(os.path.join(temp, 'result', 'result.txt'), 'w', encoding='utf-8') as handle: From 4ecb0e818079c93b7388f07826e7e1b603cd1b3d Mon Sep 17 00:00:00 2001 From: Musiker15 Date: Tue, 10 Nov 2026 12:07:16 +0100 Subject: [PATCH 6/9] Felder privater Befunde sind Text, bevor jq sie verbindet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ein Titel als Zahl ließ den SARIF-Schritt scheitern und damit auch das Hochladen des Berichts. --- .github/workflows/security-review.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/security-review.yml b/.github/workflows/security-review.yml index 89f4d0b..a10a33a 100644 --- a/.github/workflows/security-review.yml +++ b/.github/workflows/security-review.yml @@ -1369,7 +1369,16 @@ jobs: # A block found here never goes without an alert: any other # form becomes one entry that says so. if isinstance(entries, list) and all(isinstance(entry, dict) for entry in entries): - private = entries + # Fields jq joins as text are text, so an odd entry does + # not stop the upload of every other one. + private = [{ + **entry, + 'file': entry['file'] if isinstance(entry.get('file'), str) else '', + 'title': entry['title'] if isinstance(entry.get('title'), str) else str(entry.get('title') or 'Befund'), + 'severity': entry['severity'] if entry.get('severity') in ('high', 'medium', 'low') else 'medium', + 'description': entry['description'] if isinstance(entry.get('description'), str) + else str(entry.get('description') or '')[:4000], + } for entry in entries] else: private = [{'file': '', 'line': 1, 'title': 'Privater Befund, nicht lesbar', 'severity': 'medium', 'description': block[:4000]}] From 4d3bcee2b75b7d42ca362c6f0286ab6b2e3c44df Mon Sep 17 00:00:00 2001 From: Musiker15 Date: Tue, 10 Nov 2026 12:17:46 +0100 Subject: [PATCH 7/9] =?UTF-8?q?Verworfener=20Teil=20des=20Berichts=20geht?= =?UTF-8?q?=20vollst=C3=A4ndig=20in=20private=20Alerts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Nach einem zitierten, geschlossenen Block ging der Rest des Berichts verloren, und lange Blöcke wurden bei 4000 Zeichen abgeschnitten. --- .github/workflows/security-review.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/security-review.yml b/.github/workflows/security-review.yml index a10a33a..dad5cb2 100644 --- a/.github/workflows/security-review.yml +++ b/.github/workflows/security-review.yml @@ -1336,7 +1336,6 @@ jobs: # marker of such a block there leaves the result no better than # unclear. marker = r'') filled = [index for index, line in enumerate(lines) if line.strip()] result, private, body, closing_lines = 'missing', [], report, [] if filled and lines[filled[-1]].strip() == 'REVIEW_COMPLETE': @@ -1381,7 +1380,8 @@ jobs: } for entry in entries] else: private = [{'file': '', 'line': 1, 'title': 'Privater Befund, nicht lesbar', - 'severity': 'medium', 'description': block[:4000]}] + 'severity': 'medium', 'description': block[offset:offset + 4000]} + for offset in range(0, max(len(block), 1), 4000)] # Every marker left, further up or in an answer without its end: the # public report ends before the first of them, whatever its strings # hold. What each holds goes to a private alert of its own, marked @@ -1389,12 +1389,13 @@ jobs: # of the agent is never lost on the way. The log counts them. leftover = list(re.finditer(marker, body)) dropped = len(leftover) - for match in leftover: - end = closing_marker.search(body, match.end()) - content = body[match.end():end.start() if end else len(body)].strip() - private.append({'file': '', 'line': 1, 'title': 'Privater Block verworfen, Inhalt ungeprüft', - 'severity': 'medium', 'description': content[:4000]}) if dropped: + # Everything the public report loses goes private, in full and + # in pieces of 4000 characters. + cut = body[leftover[0].start():].strip() + for offset in range(0, len(cut), 4000): + private.append({'file': '', 'line': 1, 'title': 'Privater Block verworfen, Inhalt ungeprüft', + 'severity': 'medium', 'description': cut[offset:offset + 4000]}) body = body[:leftover[0].start()].rstrip() if result == 'clean': result = 'unclear' From c7633e56ba6f0b68bbb15b7d2520a9be5ebe4592 Mon Sep 17 00:00:00 2001 From: Musiker15 Date: Tue, 10 Nov 2026 12:19:48 +0100 Subject: [PATCH 8/9] =?UTF-8?q?Privater=20Block=20f=C3=A4ngt=20jeden=20Les?= =?UTF-8?q?efehler=20von=20json.loads=20ab?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tief verschachteltes JSON und Zahlen über dem Ziffernlimit brachen den Schritt sonst ab, und jeder private Befund der Antwort ging verloren. --- .github/workflows/security-review.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/security-review.yml b/.github/workflows/security-review.yml index dad5cb2..543a019 100644 --- a/.github/workflows/security-review.yml +++ b/.github/workflows/security-review.yml @@ -1362,7 +1362,9 @@ jobs: body = body[:heads[-1]].rstrip() try: entries = json.loads(block) - except json.JSONDecodeError: + except (ValueError, RecursionError): + # JSONDecodeError is a ValueError; so is an integer past + # the digit limit, and deep nesting ends in recursion. entries = None entries = [entries] if isinstance(entries, dict) else entries # A block found here never goes without an alert: any other From 6db8a94526f87277467f566df435bb7d0385230d Mon Sep 17 00:00:00 2001 From: Musiker15 Date: Tue, 10 Nov 2026 12:27:54 +0100 Subject: [PATCH 9/9] Kurzbeschreibung eines Alerts bleibt unter dem Limit von GitHub MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ein Titel über 1024 Zeichen ließ das Hochladen der SARIF-Datei scheitern; der volle Titel steht weiter in der Nachricht. --- .github/workflows/security-review.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/security-review.yml b/.github/workflows/security-review.yml index 543a019..83bcb0d 100644 --- a/.github/workflows/security-review.yml +++ b/.github/workflows/security-review.yml @@ -1436,7 +1436,7 @@ jobs: informationUri: "https://github.com/OpenGewerk/.github", rules: [to_entries[] | { id: "pr-security-review/\(.key)", - shortDescription: {text: (.value.title // "Befund")} + shortDescription: {text: ((.value.title // "Befund") | .[0:1000])} }] }}, automationDetails: {id: $category},