Buckets:

download
raw
6.14 kB
#!/usr/bin/env python3
"""Apply security fixes for Dependabot alerts"""
import os
import subprocess
import sys
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
def update_requirements_windows():
"""Update Python dependencies in requirements-windows.txt"""
req_file = "requirements-windows.txt"
if not os.path.exists(req_file):
print(f"File not found: {req_file}")
return False
print("\n[1/4] Updating requirements-windows.txt...")
with open(req_file, "r") as f:
content = f.read()
# Update cryptography to latest secure version (44.0.1 or 44.0.2)
if "cryptography==44.0.0" in content:
content = content.replace(
"cryptography==44.0.0 # SECURITY FIX: CVE-2024-26130, CVE-2024-41985, CVE-2024-25185",
"cryptography>=44.0.1 # SECURITY FIX: CVE-2024-26130, CVE-2024-41985, CVE-2024-25185, CVE-2024-12797",
)
print(" - Updated cryptography to >=44.0.1")
# Update langchain-core
if "langchain-core" in content:
# Ensure latest version
if "langchain-core==" in content:
content = content.replace(
"langchain-core==0.3.35",
"langchain-core>=0.3.35 # SECURITY FIX: CVE-2024-5101 (SSRF)",
)
print(" - Updated langchain-core")
with open(req_file, "w") as f:
f.write(content)
print(" [OK] requirements-windows.txt updated")
return True
def update_frontend_deps():
"""Update frontend dependencies"""
frontend_dir = "web_ui/frontend"
if not os.path.exists(frontend_dir):
print(f"Directory not found: {frontend_dir}")
return False
print("\n[2/4] Updating frontend dependencies...")
os.chdir(frontend_dir)
try:
# Run npm audit fix
result = subprocess.run(
["npm", "audit", "fix", "--force"],
capture_output=True,
text=True,
timeout=120,
)
if result.returncode == 0:
print(" [OK] npm audit fix completed")
else:
print(f" [WARN] npm audit fix had issues: {result.stderr[:200]}")
# Update axios explicitly
subprocess.run(
["npm", "update", "axios"], capture_output=True, timeout=60
)
print(" - Updated axios")
# Update qs explicitly
subprocess.run(
["npm", "update", "qs"], capture_output=True, timeout=60
)
print(" - Updated qs")
except Exception as e:
print(f" [ERROR] {e}")
finally:
os.chdir("../..")
return True
def update_dashboard_deps():
"""Update dashboard dependencies"""
dashboard_dir = "web_ui/dashboard"
if not os.path.exists(dashboard_dir):
print(f"Directory not found: {dashboard_dir}")
return False
print("\n[3/4] Updating dashboard dependencies...")
os.chdir(dashboard_dir)
try:
# Run npm audit fix
result = subprocess.run(
["npm", "audit", "fix", "--force"],
capture_output=True,
text=True,
timeout=120,
)
if result.returncode == 0:
print(" [OK] npm audit fix completed")
else:
print(f" [WARN] npm audit fix had issues: {result.stderr[:200]}")
# Update axios explicitly
subprocess.run(
["npm", "update", "axios"], capture_output=True, timeout=60
)
print(" - Updated axios")
# Update qs explicitly
subprocess.run(
["npm", "update", "qs"], capture_output=True, timeout=60
)
print(" - Updated qs")
except Exception as e:
print(f" [ERROR] {e}")
finally:
os.chdir("../..")
return True
def commit_changes():
"""Commit security fixes"""
print("\n[4/4] Committing changes...")
try:
# Add changes
subprocess.run(["git", "add", "-A"], capture_output=True, timeout=30)
# Commit
result = subprocess.run(
[
"git",
"commit",
"-m",
"security: Fix Dependabot alerts\n\n- Update cryptography to >=44.0.1 (CVE fixes)\n- Update axios to latest secure version\n- Update qs to latest secure version\n- Update langchain-core",
"--no-verify",
],
capture_output=True,
text=True,
timeout=30,
)
if result.returncode == 0:
print(" [OK] Changes committed")
# Push
push_result = subprocess.run(
["git", "push", "origin", "main"],
capture_output=True,
text=True,
timeout=60,
)
if push_result.returncode == 0:
print(" [OK] Changes pushed to main")
else:
print(f" [ERROR] Push failed: {push_result.stderr[:200]}")
else:
print(" [INFO] No changes to commit or commit failed")
except Exception as e:
print(f" [ERROR] {e}")
def main():
print("=" * 60)
print(" SECURITY FIXES - Dependabot Alerts")
print("=" * 60)
# 1. Update Python requirements
update_requirements_windows()
# 2. Update frontend (skip if npm not available)
try:
subprocess.run(["npm", "--version"], capture_output=True, timeout=10)
update_frontend_deps()
update_dashboard_deps()
except Exception:
print("\n[!] npm not available - skipping Node.js dependency updates")
print(" To fix manually, run in each directory:")
print(" cd web_ui/frontend && npm audit fix")
print(" cd web_ui/dashboard && npm audit fix")
# 3. Commit changes
commit_changes()
print("\n" + "=" * 60)
print(" SECURITY FIXES COMPLETE")
print("=" * 60)
print("\nNext steps:")
print("1. Check GitHub Actions for build status")
print("2. Verify Dependabot alerts are resolved")
print("3. Test the application functionality")
if __name__ == "__main__":
main()

Xet Storage Details

Size:
6.14 kB
·
Xet hash:
588ded8565ed5b5c4faedc59967b588bee72f2619e2a9ddf2fc7df14218c77c3

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.