Skip to content

Commit

Permalink
fix(prowler-check-kreator): fix index list problems
Browse files Browse the repository at this point in the history
  • Loading branch information
puchy22 committed Sep 20, 2024
1 parent 16abc94 commit 1b58721
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion util/prowler_check_kreator/lib/llms/gemini.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import os
import re

import google.generativeai as genai

Expand Down Expand Up @@ -67,7 +68,11 @@ def _generate_content(self, prompt_parts: list) -> str:

def _prepare_check_prompt(self, check_name: str, check_reference: str) -> list:
"""Prepare the prompt for generating the check."""
class_name = check_reference.split("(")[0].split("class ")[1]

class_name = re.search(
r"class\s+([A-Za-z_][A-Za-z0-9_]*)\s*\((.*?)\)\s*:", check_reference
).group(1)

prompt_parts = [
f"Your task is to create a new security check called '{check_name}' for Prowler (a Cloud Security tool).",
"The control is a Python class that inherits from the Check class and has only one method called execute.",
Expand Down
6 changes: 3 additions & 3 deletions util/prowler_check_kreator/prowler_check_kreator.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def __init__(self, provider: str, check_name: str):
# Let the user to use the model that he wants
self._model = None
supported_models = [
"gemini-1.5-flash (default)",
"gemini-1.5-flash",
"gemini-1.5-pro",
"gemini-1.0-pro",
]
Expand Down Expand Up @@ -361,8 +361,8 @@ def _write_test_file(self) -> None:
sys.exit(prowler_check_creator.kreate_check())

except ValueError as e:
print(f"Error: {e}")
print(f"Error: {e} (line {sys.exc_info()[-1].tb_lineno})")
sys.exit(1)
except Exception as e:
print(f"Error: {e}")
print(f"Error: {e} (line {sys.exc_info()[-1].tb_lineno})")
sys.exit(1)

0 comments on commit 1b58721

Please sign in to comment.