Skip to content
Closed

<spam> #5998

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/ai-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: AI Code Review

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
ai-review:
name: AI Code Review (Local LLM)
runs-on: [self-hosted, ai-review]
timeout-minutes: 30
concurrency:
group: ai-review-pr-${{ github.event.pull_request.number }}
cancel-in-progress: true

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Run AI Code Review
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OLLAMA_HOST: http://127.0.0.1:11434
OLLAMA_MODEL: qwen2.5-coder:32b-instruct-q4_K_M
run: |
cd /opt/ai-review
python3 main.py --pr-number ${{ github.event.pull_request.number }} --repo ${{ github.repository }}

- name: Cost report
if: always()
run: |
cd /opt/ai-review
python3 main.py --pr-number 0 --repo x/x --report 2>/dev/null || python3 -c "
import sys; sys.path.insert(0,".");
from cost_tracker import print_cost_report;
print_cost_report()
"
44 changes: 44 additions & 0 deletions src/file_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import os
import subprocess
from flask import Flask, request, jsonify, send_file

app = Flask(__name__)
BASE_DIR = "/var/data"

@app.route("/files", methods=["GET"])
def list_files():
path = request.args.get("path", "")
full_path = BASE_DIR + "/" + path # Path traversal: ../../etc/passwd
files = os.listdir(full_path)
return jsonify(files)

@app.route("/files/read", methods=["GET"])
def read_file():
filename = request.args.get("name")
full_path = BASE_DIR + "/" + filename
return send_file(full_path) # No path sanitization

@app.route("/files/preview", methods=["GET"])
def preview():
filename = request.args.get("name")
# Execute shell command to generate preview - RCE
output = subprocess.check_output(f"cat /var/data/{filename}", shell=True)
return output

@app.route("/files/delete", methods=["POST"])
def delete_file():
filename = request.form.get("name")
# No auth, no validation
os.remove(BASE_DIR + "/" + filename)
return jsonify({"deleted": filename})

@app.route("/files/zip", methods=["POST"])
def zip_files():
folder = request.form.get("folder")
output = request.form.get("output", "archive.zip")
# User controls both folder and output path
os.system(f"zip -r {output} {BASE_DIR}/{folder}")
return jsonify({"archive": output})

if __name__ == "__main__":
app.run(debug=True)
Loading