From d9c992327c8e8a878adc90ff871c87ae8cfe4ef2 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 23 May 2026 00:55:08 +0000 Subject: [PATCH] Fix code injection in idstack-learnings-search Co-authored-by: savvides <1580637+savvides@users.noreply.github.com> --- bin/idstack-learnings-search | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/bin/idstack-learnings-search b/bin/idstack-learnings-search index 94cc40f..cffb181 100755 --- a/bin/idstack-learnings-search +++ b/bin/idstack-learnings-search @@ -40,10 +40,13 @@ if command -v python3 &>/dev/null; then python3 -c " import json, sys -sources = '$SOURCES'.split() -type_filter = '$TYPE' -keyword = '$KEYWORD'.lower() -limit = $LIMIT +sources = sys.argv[1].split() if len(sys.argv) > 1 else [] +type_filter = sys.argv[2] if len(sys.argv) > 2 else '' +keyword = sys.argv[3].lower() if len(sys.argv) > 3 else '' +try: + limit = int(sys.argv[4]) if len(sys.argv) > 4 else 3 +except ValueError: + limit = 3 matches = [] for src in sources: @@ -69,7 +72,7 @@ for src in sources: # Local learnings first (take precedence), then global for m in matches[-limit:]: print(m) -" 2>/dev/null || { +" "$SOURCES" "$TYPE" "$KEYWORD" "$LIMIT" 2>/dev/null || { # Fallback: basic grep if [ -n "$KEYWORD" ]; then cat $SOURCES 2>/dev/null | grep -i "$KEYWORD" | tail -"$LIMIT"