mirror of
https://github.com/anthropics/claude-cookbooks.git
synced 2025-10-06 01:00:28 +03:00
refactor: let Claude handle security checks intelligently
- Remove brittle hardcoded API key checks from validate_notebooks.py - Enhance Claude review to check for any secrets (not just Anthropic) - Claude understands context (e.g., educational 'bad examples' are OK)
This commit is contained in:
@@ -25,14 +25,6 @@ def validate_notebook(path: Path) -> list:
|
||||
if output.get('output_type') == 'error':
|
||||
issues.append(f"Cell {i}: Contains error output")
|
||||
|
||||
# Check for hardcoded API keys
|
||||
for i, cell in enumerate(nb['cells']):
|
||||
if cell['cell_type'] == 'code':
|
||||
source = ''.join(cell['source'])
|
||||
if 'sk-ant-' in source or 'anthropic_api_key=' in source.lower():
|
||||
issues.append(f"Cell {i}: Potential hardcoded API key")
|
||||
if 'api_key' in source.lower() and 'os.environ' not in source and 'getenv' not in source:
|
||||
issues.append(f"Cell {i}: API key not using environment variable")
|
||||
|
||||
return issues
|
||||
|
||||
|
||||
Reference in New Issue
Block a user