Skip to content

Commit 97647e9

Browse files
committed
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)
1 parent 027216e commit 97647e9

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

.github/workflows/claude-notebook-review.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ jobs:
5555
- Dependencies properly imported
5656
5757
## Security
58-
- No exposed secrets or API keys
58+
- Check for any hardcoded API keys or secrets (not just Anthropic keys)
59+
- Ensure all sensitive credentials use environment variables (os.environ, getenv, etc.)
60+
- Flag any potential secret patterns (tokens, passwords, private keys)
61+
- Note: Educational examples showing "what not to do" are acceptable if clearly marked
5962
- Safe handling of user inputs
6063
- Appropriate use of environment variables
6164

scripts/validate_notebooks.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,6 @@ def validate_notebook(path: Path) -> list:
2525
if output.get('output_type') == 'error':
2626
issues.append(f"Cell {i}: Contains error output")
2727

28-
# Check for hardcoded API keys
29-
for i, cell in enumerate(nb['cells']):
30-
if cell['cell_type'] == 'code':
31-
source = ''.join(cell['source'])
32-
if 'sk-ant-' in source or 'anthropic_api_key=' in source.lower():
33-
issues.append(f"Cell {i}: Potential hardcoded API key")
34-
if 'api_key' in source.lower() and 'os.environ' not in source and 'getenv' not in source:
35-
issues.append(f"Cell {i}: API key not using environment variable")
3628

3729
return issues
3830

0 commit comments

Comments
 (0)