Skip to content

Commit 9ce582e

Browse files
committed
style: Clean up code formatting across the codebase
Remove trailing whitespace, standardize quote usage, improve consistency. Generated with Ripperdoc Co-Authored-By: Ripperdoc
1 parent f97e5f5 commit 9ce582e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+850
-622
lines changed

examples/hooks/check_bash.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,15 @@
3434
r"\bmkfs\b",
3535
r"\bdd\s+.*of=/dev/",
3636
r"\b:(){ :\|:& };:", # Fork bomb
37-
3837
# Network attacks
3938
r"\bnmap\b.*-sS", # SYN scan
4039
r"\bhping3?\b",
41-
4240
# Privilege escalation attempts
4341
r"\bchmod\s+[0-7]*777\s+/", # chmod 777 on root paths
4442
r"\bsudo\s+su\b",
45-
4643
# Credential theft
4744
r"\bcat\s+.*/(passwd|shadow|sudoers)",
4845
r"\b/etc/shadow\b",
49-
5046
# Cleanup protection
5147
r"\bgit\s+push\s+.*--force.*main\b",
5248
r"\bgit\s+push\s+.*--force.*master\b",

examples/hooks/check_edit.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,13 @@
3333
(r"password\s*=\s*['\"][^'\"]+['\"]", "hardcoded password"),
3434
(r"api_key\s*=\s*['\"][^'\"]+['\"]", "hardcoded API key"),
3535
(r"secret\s*=\s*['\"][^'\"]+['\"]", "hardcoded secret"),
36-
3736
# Dangerous functions
3837
(r"\beval\s*\(", "eval() usage"),
3938
(r"\bexec\s*\(", "exec() usage"),
4039
(r"__import__\s*\(", "dynamic import"),
41-
4240
# SQL injection risks
4341
(r"f['\"].*SELECT.*{", "possible SQL injection"),
4442
(r"\.format\(.*\).*(?:SELECT|INSERT|UPDATE|DELETE)", "possible SQL injection"),
45-
4643
# Command injection risks
4744
(r"subprocess\..*shell\s*=\s*True", "shell=True in subprocess"),
4845
(r"os\.system\s*\(", "os.system usage"),

examples/hooks/check_prompt.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,19 @@
3131
# Password patterns
3232
(r"(?i)\b(password|passwd|pwd)\s*[:=]\s*\S+", "password"),
3333
(r"(?i)\bpassword\s+is\s+['\"]?\S+", "password"),
34-
3534
# API key patterns
3635
(r"(?i)\b(api[_-]?key|apikey)\s*[:=]\s*\S+", "API key"),
3736
(r"(?i)\b(secret[_-]?key|secretkey)\s*[:=]\s*\S+", "secret key"),
38-
3937
# Token patterns
4038
(r"(?i)\b(auth[_-]?token|bearer)\s*[:=]\s*\S+", "auth token"),
4139
(r"(?i)\b(access[_-]?token)\s*[:=]\s*\S+", "access token"),
42-
4340
# AWS patterns
4441
(r"AKIA[0-9A-Z]{16}", "AWS access key"),
4542
(r"(?i)aws[_-]?secret[_-]?access[_-]?key\s*[:=]\s*\S+", "AWS secret key"),
46-
4743
# Private key patterns
4844
(r"-----BEGIN\s+(RSA\s+)?PRIVATE\s+KEY-----", "private key"),
49-
5045
# Database connection strings
5146
(r"(?i)(mysql|postgres|mongodb)://[^\s]+:[^\s]+@", "database connection string"),
52-
5347
# Generic secret patterns
5448
(r"(?i)\bsecret\s*[:=]\s*['\"]?\S{10,}", "secret value"),
5549
]

examples/hooks/demo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ def main() -> None:
4747
timestamp = datetime.now().isoformat()
4848
event_name = input_data.get("event_name", "unknown")
4949

50-
log_entry = f"\n{'='*60}\n"
50+
log_entry = f"\n{'=' * 60}\n"
5151
log_entry += f"[{timestamp}] Event: {event_name}\n"
52-
log_entry += f"{'='*60}\n"
52+
log_entry += f"{'=' * 60}\n"
5353
log_entry += json.dumps(input_data, indent=2, default=str)
5454
log_entry += "\n"
5555

examples/hooks/integration_example.py

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929
{
3030
"type": "command",
3131
"command": "python $RIPPERDOC_PROJECT_DIR/.ripperdoc/hooks/log_bash.py",
32-
"timeout": 5
32+
"timeout": 5,
3333
},
3434
{
3535
"type": "command",
3636
"command": "python $RIPPERDOC_PROJECT_DIR/.ripperdoc/hooks/check_bash.py",
37-
"timeout": 5
38-
}
39-
]
37+
"timeout": 5,
38+
},
39+
],
4040
},
4141
# Protect sensitive files from modification
4242
{
@@ -45,12 +45,11 @@
4545
{
4646
"type": "command",
4747
"command": "python $RIPPERDOC_PROJECT_DIR/.ripperdoc/hooks/check_write.py",
48-
"timeout": 5
48+
"timeout": 5,
4949
}
50-
]
51-
}
50+
],
51+
},
5252
],
53-
5453
# Code quality checks after edits
5554
"PostToolUse": [
5655
{
@@ -59,62 +58,58 @@
5958
{
6059
"type": "command",
6160
"command": "python $RIPPERDOC_PROJECT_DIR/.ripperdoc/hooks/check_edit.py",
62-
"timeout": 5
61+
"timeout": 5,
6362
}
64-
]
63+
],
6564
}
6665
],
67-
6866
# Validate user prompts for sensitive content
6967
"UserPromptSubmit": [
7068
{
7169
"hooks": [
7270
{
7371
"type": "command",
7472
"command": "python $RIPPERDOC_PROJECT_DIR/.ripperdoc/hooks/check_prompt.py",
75-
"timeout": 5
73+
"timeout": 5,
7674
}
7775
]
7876
}
7977
],
80-
8178
# Desktop notifications
8279
"Notification": [
8380
{
8481
"hooks": [
8582
{
8683
"type": "command",
8784
"command": "python $RIPPERDOC_PROJECT_DIR/.ripperdoc/hooks/log_notification.py",
88-
"timeout": 10
85+
"timeout": 10,
8986
}
9087
]
9188
}
9289
],
93-
9490
# Session lifecycle tracking
9591
"SessionStart": [
9692
{
9793
"hooks": [
9894
{
9995
"type": "command",
10096
"command": "python $RIPPERDOC_PROJECT_DIR/.ripperdoc/hooks/session_start.py",
101-
"timeout": 5
97+
"timeout": 5,
10298
}
10399
]
104100
}
105101
],
106-
107102
"SessionEnd": [
108103
{
109104
"hooks": [
110105
{
111106
"type": "command",
112107
"command": "python $RIPPERDOC_PROJECT_DIR/.ripperdoc/hooks/session_end.py",
113-
"timeout": 5
108+
"timeout": 5,
114109
}
115110
]
116111
}
117-
]
112+
],
118113
}
119114
}
120115

examples/hooks/log_notification.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def send_notification_windows(title: str, message: str) -> bool:
5858
"""Send notification on Windows using PowerShell toast."""
5959
try:
6060
# Use PowerShell to send a toast notification
61-
ps_script = f'''
61+
ps_script = f"""
6262
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
6363
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null
6464
@@ -77,7 +77,7 @@ def send_notification_windows(title: str, message: str) -> bool:
7777
$xml.LoadXml($template)
7878
$toast = [Windows.UI.Notifications.ToastNotification]::new($xml)
7979
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("Ripperdoc").Show($toast)
80-
'''
80+
"""
8181
subprocess.run(
8282
["powershell", "-Command", ps_script],
8383
check=True,

examples/hooks/session_end.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,7 @@ def main() -> None:
7676
f.write(log_entry)
7777

7878
# Print summary (goes to stderr so it's visible but doesn't affect hook output)
79-
print(
80-
f"Session ended: {duration_str}, {message_count} messages",
81-
file=sys.stderr
82-
)
79+
print(f"Session ended: {duration_str}, {message_count} messages", file=sys.stderr)
8380

8481
sys.exit(0)
8582

examples/hooks/test_hooks.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,7 @@ def test_load_valid_config(self) -> None:
151151
"PreToolUse": [
152152
{
153153
"matcher": "Bash",
154-
"hooks": [
155-
{"type": "command", "command": "echo test", "timeout": 10}
156-
]
154+
"hooks": [{"type": "command", "command": "echo test", "timeout": 10}],
157155
}
158156
]
159157
}
@@ -173,14 +171,8 @@ def test_get_hooks_for_event(self) -> None:
173171
config = HooksConfig(
174172
hooks={
175173
"PreToolUse": [
176-
HookMatcher(
177-
matcher="Bash",
178-
hooks=[HookDefinition(command="echo bash")]
179-
),
180-
HookMatcher(
181-
matcher="Write",
182-
hooks=[HookDefinition(command="echo write")]
183-
),
174+
HookMatcher(matcher="Bash", hooks=[HookDefinition(command="echo bash")]),
175+
HookMatcher(matcher="Write", hooks=[HookDefinition(command="echo write")]),
184176
]
185177
}
186178
)
@@ -211,9 +203,7 @@ def test_merge_configs(self) -> None:
211203
"PreToolUse": [
212204
HookMatcher(matcher="Write", hooks=[HookDefinition(command="echo 2")])
213205
],
214-
"PostToolUse": [
215-
HookMatcher(matcher="*", hooks=[HookDefinition(command="echo 3")])
216-
]
206+
"PostToolUse": [HookMatcher(matcher="*", hooks=[HookDefinition(command="echo 3")])],
217207
}
218208
)
219209

examples/tool_examples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ async def example_bash_tool() -> None:
2121
input_data = BashToolInput(command="echo 'Hello from Ripperdoc!'", timeout=10000)
2222

2323
async for result in tool.call(input_data, context):
24-
if hasattr(result, 'data'):
24+
if hasattr(result, "data"):
2525
print(f"Command: {result.data.command}") # type: ignore[union-attr]
2626
print(f"Output: {result.data.stdout}") # type: ignore[union-attr]
2727
print(f"Exit Code: {result.data.exit_code}") # type: ignore[union-attr]

ripperdoc/cli/cli.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ async def run_query(
169169
console.print(f"[red]Error: {escape(str(e))}[/red]")
170170
logger.warning(
171171
"[cli] Unhandled error while running prompt: %s: %s",
172-
type(e).__name__, e,
172+
type(e).__name__,
173+
e,
173174
extra={"session_id": session_id},
174175
)
175176
if verbose:
@@ -397,11 +398,20 @@ def main() -> None:
397398
sys.exit(130)
398399
except SystemExit:
399400
raise
400-
except (RuntimeError, ValueError, TypeError, OSError, IOError, ConnectionError, click.ClickException) as e:
401+
except (
402+
RuntimeError,
403+
ValueError,
404+
TypeError,
405+
OSError,
406+
IOError,
407+
ConnectionError,
408+
click.ClickException,
409+
) as e:
401410
console.print(f"[red]Fatal error: {escape(str(e))}[/red]")
402411
logger.warning(
403412
"[cli] Fatal error in main CLI entrypoint: %s: %s",
404-
type(e).__name__, e,
413+
type(e).__name__,
414+
e,
405415
)
406416
sys.exit(1)
407417

0 commit comments

Comments
 (0)