-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes in readme, setup helper script (#10)
### Summary 📝 Adding email id as feedback so that security patches can be informed, updated readme, and added setup helper script.
- Loading branch information
1 parent
016333e
commit 0953344
Showing
4 changed files
with
103 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
|
||
# curl -sS https://bootstrap.pypa.io/get-pip.py | python3.11 | ||
|
||
# Create a new Python virtual environment named 'test' | ||
python3 -m venv test | ||
|
||
# Activate the virtual environment | ||
source test/bin/activate | ||
|
||
# Upgrade the 'testzeus-hercules' package | ||
pip install --upgrade testzeus-hercules | ||
playwright install --with-deps | ||
|
||
#Set Headless as false | ||
export HEADLESS=false | ||
|
||
# create a new directory named 'opt' | ||
mkdir -p opt/input opt/output opt/test_data | ||
|
||
# create a intput/test.feature file | ||
echo "Feature: Open Google homepage\nScenario: User opens Google homepage\n Given I have a web browser open\n When I navigate to https://www.google.com\n Then I should see the Google homepage" > opt/input/test.feature | ||
|
||
# get gpt-4o model API key by asking user | ||
echo "Enter your GPT-4o model API key:" | ||
read -s GPT_4O_API_KEY | ||
|
||
# Run the 'testzeus-hercules' command with the specified parameters | ||
testzeus-hercules \ | ||
--input-file opt/input/test.feature \ | ||
--output-path opt/output \ | ||
--test-data-path opt/test_data \ | ||
--llm-model gpt-4o \ | ||
--llm-model-api-key $GPT_4O_API_KEY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
from pydantic import BaseModel | ||
from sentry_sdk.scrubber import DEFAULT_DENYLIST, DEFAULT_PII_DENYLIST, EventScrubber | ||
from sentry_sdk.types import Event, Hint | ||
import json | ||
|
||
DSN = "https://d14d2ee82f26a3585b2a892fab7fffaa@o4508256143540224.ingest.us.sentry.io/4508256153042944" | ||
|
||
|
@@ -79,24 +80,66 @@ def my_before_send(event: Event, hint: Hint) -> Event | None: | |
sentry_sdk.set_user(None) | ||
|
||
|
||
def get_installation_id(file_path="installation_id.txt") -> str: | ||
"""Generate or load a unique installation ID.""" | ||
def get_installation_id( | ||
file_path: str = "installation_id.txt", is_manual_run: bool = True | ||
) -> Dict[str, Any]: | ||
"""Generate or load installation data. | ||
If the file exists and contains a dict, return it. | ||
If the file exists and contains only the installation ID, return a dict with default values. | ||
If the file does not exist: | ||
- If triggered manually by the user (is_manual_run is True), prompt for user_email. | ||
- Generate a new installation ID and save all data as a dict. | ||
- If not triggered manually, use default values for user_email. | ||
""" | ||
if os.path.exists(file_path): | ||
data = { | ||
"user_email": "[email protected]", | ||
} | ||
rewrite_data = False | ||
with open(file_path, "r") as file: | ||
return file.read().strip() | ||
content = file.read().strip() | ||
installation_id = content | ||
data["installation_id"] = installation_id | ||
try: | ||
data = json.loads(content) | ||
if isinstance(data, dict) and "installation_id" in data: | ||
return data | ||
except json.JSONDecodeError: | ||
rewrite_data = True | ||
if rewrite_data: | ||
with open(file_path, "w") as file: | ||
json.dump(data, file) | ||
else: | ||
installation_id = str(uuid.uuid4()) | ||
user_email = "[email protected]" | ||
if is_manual_run: | ||
print( | ||
"We need your email to inform you about any urgent security patches or issues detected in testzeus-hercules." | ||
) | ||
n_user_email = input( | ||
"Please provide your email (or press Enter to skip with empty email): " | ||
) | ||
user_email = n_user_email if n_user_email else user_email | ||
|
||
data = { | ||
"user_email": user_email, | ||
"installation_id": installation_id, | ||
} | ||
with open(file_path, "w") as file: | ||
file.write(installation_id) | ||
return installation_id | ||
json.dump(data, file) | ||
return data | ||
|
||
|
||
# Initialize the installation_id | ||
installation_id = get_installation_id() | ||
installation_data = get_installation_id( | ||
is_manual_run=os.environ.get("AUTO_MODE", "0") == "0" | ||
) | ||
|
||
# Global event collector with event_type buckets | ||
event_collector = { | ||
"installation_id": installation_id, | ||
"installation_id": installation_data["installation_id"], | ||
"user_email": installation_data["user_email"], | ||
"buckets": {}, | ||
"start_time": datetime.now().isoformat(), | ||
} | ||
|
@@ -144,6 +187,7 @@ def build_final_message() -> Dict[str, Any]: | |
""" | ||
message = { | ||
"installation_id": event_collector["installation_id"], | ||
"user_email": event_collector["user_email"], | ||
"session_start": event_collector["start_time"], | ||
"buckets": { | ||
event_type_s: events | ||
|