Skip to content

Commit 08a980c

Browse files
authored
refactor(security): Remove hardcoded API keys and secure configuration (#1)
* refactor(security): Remove hardcoded API keys and secure configuration Foundation Cleanup - Step 1 Complete ✅ Security improvements: - Removed hardcoded Google API key from state_llm_integration.py - All API keys now managed via .env file through SecureConfig - Added support for OpenAI, Anthropic, DeepSeek API keys in .env.example - Added detect-secrets pre-commit hook to prevent future leaks - Added detect-private-key hook for additional protection Configuration improvements: - Updated config.yaml with FreeCAD AppImage path configuration - Documented FreeCAD path for AppImage location - Prepared for multi-provider LLM architecture (litellm) Files modified: - src/ai_designer/core/state_llm_integration.py - .env.example - config/config.yaml - .pre-commit-config.yaml - docs/EXECUTION_PLAN.md - docs/IMPLEMENTATION_PLAN.md Next: Step 2 - Replace exec() with safe execution sandbox * refactor: consolidate documentation and improve linting setup - Remove CI/CD workflows (.github/workflows/) - Re-enable mypy in pre-commit configuration - Consolidate 28 docs into 14 organized files (50% reduction) - Create docs/guides/ and docs/advanced/ structure - Preserve EXECUTION_PLAN.md as requested - Delete IMPLEMENTATION_PLAN.md and redundant summaries - Update README.md with new documentation structure Consolidated docs: - DeepSeek R1: 3 files → DEEPSEEK_R1_GUIDE.md - Complex Shapes: 3 files → COMPLEX_SHAPES_GUIDE.md - State Management: 2 files → STATE_GUIDE.md - Security: 2 files → SECURITY_GUIDE.md - Summaries: 5 files → PROJECT_STATUS.md Linting improvements: - mypy type checking re-enabled - All security checks maintained (bandit, detect-secrets) - Code formatting preserved (black, isort, flake8)
1 parent 49f843d commit 08a980c

36 files changed

Lines changed: 5344 additions & 5568 deletions

.env.example

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,43 @@
22
# Copy this file to .env and fill in your actual values
33
# DO NOT commit .env to version control
44

5+
# ========================================
6+
# LLM Provider API Keys
7+
# ========================================
8+
59
# Google Generative AI API Key
610
# Get your API key from: https://makersuite.google.com/app/apikey
711
GOOGLE_API_KEY=your_google_api_key_here
812

9-
# Redis Configuration (if using Redis)
13+
# OpenAI API Key (for GPT-4o, GPT-4, etc.)
14+
# Get your API key from: https://platform.openai.com/api-keys
15+
OPENAI_API_KEY=your_openai_api_key_here
16+
17+
# Anthropic API Key (for Claude models)
18+
# Get your API key from: https://console.anthropic.com/
19+
ANTHROPIC_API_KEY=your_anthropic_api_key_here
20+
21+
# DeepSeek API Key (if using DeepSeek cloud API)
22+
# Get your API key from: https://platform.deepseek.com/
23+
DEEPSEEK_API_KEY=your_deepseek_api_key_here
24+
25+
# ========================================
26+
# Redis Configuration
27+
# ========================================
1028
REDIS_HOST=localhost
1129
REDIS_PORT=6379
1230
REDIS_DB=0
31+
REDIS_PASSWORD=
1332

33+
# ========================================
1434
# FreeCAD Configuration
15-
FREECAD_PATH=/path/to/freecad
16-
FREECAD_PYTHON_PATH=/path/to/freecad/python
35+
# ========================================
36+
# Path to FreeCAD AppImage or installation directory
37+
# Example AppImage: /home/username/Downloads/FreeCAD_1.0.1-conda-Linux-x86_64-py311.AppImage
38+
# Example system install: /usr/lib/freecad
39+
FREECAD_PATH=/home/vansh5632/Downloads/FreeCAD_1.0.1-conda-Linux-x86_64-py311.AppImage
40+
FREECAD_LIB_PATH=
41+
FREECAD_MOD_PATH=
1742

1843
# Development Settings
1944
DEBUG=false

.github/workflows/ci.yml

Lines changed: 0 additions & 126 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.4.0
3+
rev: v4.5.0
44
hooks:
55
- id: trailing-whitespace
66
- id: end-of-file-fixer
77
- id: check-yaml
88
- id: check-added-large-files
9+
args: ['--maxkb=1000']
910
- id: check-merge-conflict
1011
- id: debug-statements
1112
- id: check-docstring-first
1213
- id: check-json
1314
- id: check-toml
1415
- id: mixed-line-ending
16+
- id: detect-private-key
17+
18+
# Secret detection - CRITICAL for security
19+
- repo: https://github.com/Yelp/detect-secrets
20+
rev: v1.4.0
21+
hooks:
22+
- id: detect-secrets
23+
args: ['--exclude-files', '.secrets.baseline']
1524

1625
- repo: https://github.com/psf/black
1726
rev: 23.9.1
@@ -31,17 +40,16 @@ repos:
3140
hooks:
3241
- id: flake8
3342

34-
# Temporarily disabled mypy to focus on basic linting
35-
# - repo: https://github.com/pre-commit/mirrors-mypy
36-
# rev: v1.5.1
37-
# hooks:
38-
# - id: mypy
39-
# additional_dependencies: [
40-
# types-PyYAML,
41-
# types-requests,
42-
# types-redis,
43-
# ]
44-
# args: [--config-file=mypy.ini]
43+
- repo: https://github.com/pre-commit/mirrors-mypy
44+
rev: v1.5.1
45+
hooks:
46+
- id: mypy
47+
additional_dependencies: [
48+
types-PyYAML,
49+
types-requests,
50+
types-redis,
51+
]
52+
args: [--config-file=mypy.ini]
4553

4654
- repo: https://github.com/PyCQA/bandit
4755
rev: 1.7.5

config/config.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1-
api_key: "your_api_key_here"
1+
# API keys are now managed via .env file for security
2+
# See .env.example for required environment variables
23
freecad_api_url: "http://localhost:8080"
34

5+
# FreeCAD Installation Configuration
6+
freecad:
7+
# Path to FreeCAD AppImage or installation
8+
# Can be overridden by FREECAD_PATH environment variable
9+
appimage_path: "/home/vansh5632/Downloads/FreeCAD_1.0.1-conda-Linux-x86_64-py311.AppImage"
10+
# These paths are auto-detected from AppImage, only set if custom installation
11+
lib_path: ""
12+
mod_path: ""
13+
414
# DeepSeek R1 Local Configuration
515
deepseek:
616
enabled: true

0 commit comments

Comments
 (0)