Skip to content

Commit 16058ba

Browse files
committed
Ethereum Code Reviewer
0 parents  commit 16058ba

Some content is hidden

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

51 files changed

+18932
-0
lines changed

.env.example

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# Google OAuth Configuration
2+
GOOGLE_CLIENT_ID=your_google_client_id_here.apps.googleusercontent.com
3+
4+
# Flask Configuration
5+
FLASK_SECRET_KEY=your_super_secret_key_here
6+
FLASK_ENV=development
7+
8+
# Web App Configuration
9+
WEB_APP_PORT=5000
10+
FINDINGS_SERVER_PORT=8000
11+
FINDINGS_SERVER_URL=http://localhost:8000
12+
13+
# Database Configuration
14+
DATABASE_URL=postgresql://username:password@localhost:5432/security_findings
15+
16+
# Authorized Email Addresses (comma-separated)
17+
AUTHORIZED_EMAILS=[email protected]
18+
19+
# Optional: Telegram Configuration (if using Telegram notifications)
20+
TELEGRAM_BOT_TOKEN=your_telegram_bot_token_here
21+
TELEGRAM_CHAT_ID=your_telegram_chat_id_here
22+
23+
# Optional: LLM Provider API Keys
24+
OPENAI_API_KEY=your_openai_api_key_here
25+
ANTHROPIC_API_KEY=your_anthropic_api_key_here
26+
GOOGLE_AI_API_KEY=your_google_ai_api_key_here
27+
28+
# GitHub PAT token for accessing repositories
29+
GITHUB_TOKEN=your_github_token_here
30+
31+
# Email Notifications (Amazon SES)
32+
AWS_SES_REGION=us-east-1
33+
SES_FROM_EMAIL=[email protected]
34+
BASE_URL=https://your-domain.com
35+
AWS_ACCESS_KEY_ID=your_aws_access_key_here
36+
AWS_SECRET_ACCESS_KEY=your_aws_secret_access_key_here
37+
38+
# Notification Settings
39+
NOTIFY_CLEAN_COMMITS=false
40+
41+
# Embeddings API key (required for Claude with docs)
42+
VOYAGE_API_KEY=your_voyage_api_key_here
43+
44+
# GitHub App Settings
45+
GITHUB_APP_ID=12345
46+
GITHUB_PRIVATE_KEY_PATH=./privatekey.pem
47+
GITHUB_WEBHOOK_SECRET=your_webhook_secret_here
48+
GITHUB_CLIENT_SECRET=your_github_client_secret_here
49+
50+
# AMQP Message Queue (optional)
51+
AMQP_URL=amqp://guest:guest@localhost:5672/
52+
QUEUE_NAME=security_review_requests
53+
RESPONSE_QUEUE_NAME=security_review_responses
54+
55+
# Weights for LLM Providers (used when multiple providers are enabled)
56+
ANTHROPIC_WEIGHT=1
57+
OPENAI_WEIGHT=1
58+
GEMINI_WEIGHT=1
59+
DEEPSEEK_WEIGHT=1
60+
LLAMA_WEIGHT=1
61+
62+
# Optional: Enable SQL query debugging (set to true to see SQL queries in logs)
63+
SQL_DEBUG=false
64+
65+
# LLM Prompts Configuration
66+
LLM_SECURITY_PROMPT_INTRO="You are a security expert specializing in Ethereum client implementations and blockchain security."
67+
68+
LLM_SECURITY_PROMPT_FOCUS_AREAS="Pay special attention to Blockchain specific vulnerabilities."
69+
70+
LLM_SECURITY_PROMPT_IMPORTANT_NOTES="IMPORTANT:\n- Focus on concrete exploitable vulnerabilities."
71+
72+
LLM_SECURITY_PROMPT_EXAMPLES="Examples of concrete vulnerabilities:\n- Gas costs that deviate from EIP specifications."
73+
74+
LLM_SECURITY_PROMPT_RESPONSE_FORMAT="CRITICAL: Your response must be ONLY the following JSON object, with no additional text, explanation, or markdown formatting:\n{\n \"confidence_score\": <use highest confidence from findings, or 100 if no vulnerabilities>,\n \"has_vulnerabilities\": <true/false>,\n \"findings\": [\n {\n \"severity\": \"<HIGH|MEDIUM|LOW>\",\n \"description\": \"<specific vulnerability with exact code location>\",\n \"recommendation\": \"<precise fix required>\",\n \"confidence\": <0-100, how certain you are about this specific vulnerability>,\n \"detailed_explanation\": \"<comprehensive explanation of what the issue is>\",\n \"impact_explanation\": \"<what can happen if this vulnerability is exploited>\",\n \"detailed_recommendation\": \"<detailed explanation of how to fix the issue>\",\n \"code_example\": \"<the existing problematic code block, with proposed changes highlighted using html-style comments>\",\n \"additional_resources\": \"<links to documentation or other resources>\"\n }\n ],\n \"summary\": \"<only mention concrete vulnerabilities found>\"\n}\n\nIMPORTANT: The overall confidence_score should match the highest confidence score from the findings.\nFor example, if you find one vulnerability with 90% confidence, the overall confidence_score should also be 90."
75+
76+
LLM_SECURITY_PROMPT_NO_VULNS_RESPONSE="If no clear vulnerabilities are found in the code changes, return:\n{\n \"confidence_score\": 100,\n \"has_vulnerabilities\": false,\n \"findings\": [],\n \"summary\": \"No concrete vulnerabilities identified in the changed code.\"\n}"
77+
78+
LLM_SKEPTICAL_VERIFICATION_INTRO="You are a skeptical security auditor tasked with CRITICALLY reviewing and VERIFYING potential vulnerabilities."
79+
80+
LLM_SKEPTICAL_VERIFICATION_CRITICAL_QUESTIONS="Ask yourself is this is really a vulnerability."
81+
82+
LLM_SKEPTICAL_VERIFICATION_BE_CRITICAL="Keep a critical mindset."
83+
84+
LLM_SKEPTICAL_VERIFICATION_ONLY_CONFIRM="Only confirm vulnerabilities you are very sure about."
85+
86+
LLM_SKEPTICAL_VERIFICATION_RESPONSE_FORMAT="Return ONLY a JSON object with your verification results:\n{\n \"verified_findings\": [\n {\n \"original_index\": <index of the original finding, starting from 0>,\n \"is_real_vulnerability\": <true/false>,\n \"verification_confidence\": <0-100>,\n \"reason\": \"<why you believe this is or isnt a real vulnerability>\"\n }\n ],\n \"summary\": \"<brief summary of your verification>\"\n}"
87+
88+
LLM_SYNTHESIS_PROMPT_INTRO="You are a security expert tasked with synthesizing multiple security analyses into a single coherent report."
89+
90+
LLM_SYNTHESIS_PROMPT_INSTRUCTION="Please synthesize these analyses into a single, coherent security report. Combine similar findings, use the highest confidence scores where appropriate, and create a unified summary."
91+
92+
LLM_SYNTHESIS_SYSTEM_PROMPT="You are a security expert specializing in code review. Return ONLY JSON output with no additional text or explanation."
93+
94+
LLM_SYNTHESIS_SYSTEM_PROMPT_ANTHROPIC="You are a skeptical security auditor. Return ONLY JSON output with no additional text or explanation."
95+
96+
LLM_SYNTHESIS_SYSTEM_PROMPT_SYNTHESIZE="You are a security expert specializing in synthesizing multiple analyses. Return ONLY JSON output with no additional text or explanation."
97+
98+
99+
# End of .env.example
100+
# Note: Rename this file to .env and fill in the actual values before running the application.

.env.webapp.example

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
DEEPSEEK_API_KEY=""
2+
LLAMA_API_KEY=""
3+
GITHUB_TOKEN=""
4+
ANTHROPIC_API_KEY=""
5+
OPENAI_API_KEY=""
6+
VOYAGE_API_KEY=""
7+
TELEGRAM_BOT_TOKEN=""
8+
TELEGRAM_CHAT_ID=""
9+
TELEGRAM_CHAT_ID_GOOD=""
10+
GEMINI_API_KEY=""
11+
MULTI_JUDGE=""
12+
NOTIFY_CLEAN_COMMITS=""
13+
DATABASE_URL=""
14+
GOOGLE_CLIENT_ID=""
15+
FLASK_SECRET_KEY=""
16+
AUTHORIZED_EMAILS=""
17+
WEB_APP_PORT=""
18+
AWS_SES_REGION=""
19+
SES_FROM_EMAIL=""
20+
BASE_URL=""
21+
AWS_ACCESS_KEY_ID=""
22+
AWS_SECRET_ACCESS_KEY=""
23+
LLM_SECURITY_PROMPT_INTRO="You are a security expert specializing in Ethereum client implementations and blockchain security."
24+
LLM_SECURITY_PROMPT_FOCUS_AREAS="Pay special attention to Blockchain specific vulnerabilities."
25+
LLM_SECURITY_PROMPT_IMPORTANT_NOTES="IMPORTANT:\n- Focus on concrete exploitable vulnerabilities."
26+
LLM_SECURITY_PROMPT_EXAMPLES="Examples of concrete vulnerabilities:\n- Gas costs that deviate from EIP specifications."
27+
LLM_SECURITY_PROMPT_RESPONSE_FORMAT="CRITICAL: Your response must be ONLY the following JSON object, with no additional text, explanation, or markdown formatting:\n{\n \"confidence_score\": <use highest confidence from findings, or 100 if no vulnerabilities>,\n \"has_vulnerabilities\": <true/false>,\n \"findings\": [\n {\n \"severity\": \"<HIGH|MEDIUM|LOW>\",\n \"description\": \"<specific vulnerability with exact code location>\",\n \"recommendation\": \"<precise fix required>\",\n \"confidence\": <0-100, how certain you are about this specific vulnerability>,\n \"detailed_explanation\": \"<comprehensive explanation of what the issue is>\",\n \"impact_explanation\": \"<what can happen if this vulnerability is exploited>\",\n \"detailed_recommendation\": \"<detailed explanation of how to fix the issue>\",\n \"code_example\": \"<the existing problematic code block, with proposed changes highlighted using html-style comments>\",\n \"additional_resources\": \"<links to documentation or other resources>\"\n }\n ],\n \"summary\": \"<only mention concrete vulnerabilities found>\"\n}\n\nIMPORTANT: The overall confidence_score should match the highest confidence score from the findings.\nFor example, if you find one vulnerability with 90% confidence, the overall confidence_score should also be 90."
28+
LLM_SECURITY_PROMPT_NO_VULNS_RESPONSE="If no clear vulnerabilities are found in the code changes, return:\n{\n \"confidence_score\": 100,\n \"has_vulnerabilities\": false,\n \"findings\": [],\n \"summary\": \"No concrete vulnerabilities identified in the changed code.\"\n}"
29+
LLM_SKEPTICAL_VERIFICATION_INTRO="You are a skeptical security auditor tasked with CRITICALLY reviewing and VERIFYING potential vulnerabilities."
30+
LLM_SKEPTICAL_VERIFICATION_CRITICAL_QUESTIONS="Ask yourself is this is really a vulnerability."
31+
LLM_SKEPTICAL_VERIFICATION_BE_CRITICAL="Keep a critical mindset."
32+
LLM_SKEPTICAL_VERIFICATION_ONLY_CONFIRM="Only confirm vulnerabilities you are very sure about."
33+
LLM_SKEPTICAL_VERIFICATION_RESPONSE_FORMAT="Return ONLY a JSON object with your verification results:\n{\n \"verified_findings\": [\n {\n \"original_index\": <index of the original finding, starting from 0>,\n \"is_real_vulnerability\": <true/false>,\n \"verification_confidence\": <0-100>,\n \"reason\": \"<why you believe this is or isnt a real vulnerability>\"\n }\n ],\n \"summary\": \"<brief summary of your verification>\"\n}"
34+
LLM_SYNTHESIS_PROMPT_INTRO="You are a security expert tasked with synthesizing multiple security analyses into a single coherent report."
35+
LLM_SYNTHESIS_PROMPT_INSTRUCTION="Please synthesize these analyses into a single, coherent security report. Combine similar findings, use the highest confidence scores where appropriate, and create a unified summary."
36+
LLM_SYNTHESIS_SYSTEM_PROMPT="You are a security expert specializing in code review. Return ONLY JSON output with no additional text or explanation."
37+
LLM_SYNTHESIS_SYSTEM_PROMPT_ANTHROPIC="You are a skeptical security auditor. Return ONLY JSON output with no additional text or explanation."
38+
LLM_SYNTHESIS_SYSTEM_PROMPT_SYNTHESIZE="You are a security expert specializing in synthesizing multiple analyses. Return ONLY JSON output with no additional text or explanation."

.gitignore

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.so
6+
.Python
7+
build/
8+
develop-eggs/
9+
dist/
10+
downloads/
11+
eggs/
12+
.eggs/
13+
lib/
14+
lib64/
15+
parts/
16+
sdist/
17+
var/
18+
wheels/
19+
*.egg-info/
20+
.installed.cfg
21+
*.egg
22+
23+
# Testing
24+
.pytest_cache/
25+
.coverage
26+
htmlcov/
27+
.tox/
28+
.nox/
29+
coverage.xml
30+
*.cover
31+
*.py,cover
32+
.hypothesis/
33+
34+
# Environment
35+
.env
36+
.venv
37+
env/
38+
venv/
39+
ENV/
40+
env.bak/
41+
venv.bak/
42+
43+
# IDE
44+
.idea/
45+
.vscode/
46+
*.swp
47+
*.swo
48+
*~
49+
50+
# Flask Session
51+
flask_session/
52+
53+
# Project specific
54+
docs/embeddings.npy
55+
docs/docs.json
56+
privatekey.pem
57+
vector-database-docs/

Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM python:3.11-slim
2+
3+
ENV PYTHONUNBUFFERED=1
4+
5+
WORKDIR /app
6+
7+
COPY . .
8+
RUN pip install --no-cache-dir -e .
9+
10+
ENTRYPOINT ["python", "-u", "-m", "pr_security_review"]

Dockerfile.github

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM python:3.11-slim
2+
3+
ENV PYTHONUNBUFFERED=1
4+
5+
WORKDIR /app
6+
7+
COPY . .
8+
RUN pip install --no-cache-dir -e .
9+
10+
ENTRYPOINT ["python", "-u", "-m", "pr_security_review", "--github-app"]

Dockerfile.queue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM python:3.11-slim
2+
3+
ENV PYTHONUNBUFFERED=1
4+
5+
WORKDIR /app
6+
7+
COPY . .
8+
RUN pip install --no-cache-dir -e .
9+
10+
ENTRYPOINT ["python", "-u", "-m", "pr_security_review", "--listen-queue"]

Dockerfile.telegram

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM python:3.11-slim
2+
3+
ENV PYTHONUNBUFFERED=1
4+
5+
WORKDIR /app
6+
7+
COPY . .
8+
RUN pip install --no-cache-dir -e .
9+
10+
ENTRYPOINT ["python", "-u", "-m", "pr_security_review", "--monitor-continuous", "--config-file", "config.json", "--docs-dir", "vector-database-docs"]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)