Automate safety scan with project config - #124
Conversation
Reviewer's GuideThis PR integrates Safety CLI v3 into the CircleCI pipeline by adding a dedicated safety-scan job, supplying non-interactive project and policy configuration files, and implementing exit code handling so the CI fails only on high/critical vulnerabilities. Entity relationship diagram for Safety CLI configuration fileserDiagram
SAFETY_PROJECT_INI {
string name
string id
string organization
list targets
bool interactive
bool continue_on_error
string policy_file
string format
bool detailed
}
SAFETY_POLICY_YML {
string version
string project_name
string project_description
list fail_on_severity_levels
bool continue_on_vulnerability_error
list ignore
list ignore_packages
object environments
object reporting
object auto_fix
object audit
list custom_rules
}
SAFETY_PROJECT_INI ||--|| SAFETY_POLICY_YML : references
CIRCLECI_CONFIG_YML {
job safety-scan
step install_safety
step run_safety_scan
step handle_exit_code
}
CIRCLECI_CONFIG_YML ||--|| SAFETY_PROJECT_INI : uses
CIRCLECI_CONFIG_YML ||--|| SAFETY_POLICY_YML : uses
Flow diagram for Safety scan job in CircleCIflowchart TD
Start([Start safety-scan job]) --> Install[Install Safety CLI]
Install --> Config[Read .safety-project.ini]
Config --> Policy[Read .safety-policy.yml]
Policy --> Scan[Run safety scan]
Scan --> CheckExit[Check exit code]
CheckExit -->|Exit code 64| Fail[Fail CI job]
CheckExit -->|Other exit code| Warn[Show warning]
CheckExit -->|Success| Pass[Pass CI job]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Cursor Agent can help with this pull request. Just |
|
Here's the code health analysis summary for commits Analysis Summary
|
|
Closing obsolete safety scan PR - Safety scanning is now integrated into fortress system through .safety-project.ini configuration (extracted in PR #179) and automated CI workflows. |
🐍 Python 3.8 Compatibility Fixes - CLEAN & FOCUSED
📋 PR Overview
This PR integrates Safety CLI v3 into the CircleCI pipeline, resolving critical interactive prompt issues and enabling policy-driven security vulnerability scanning. It's a focused fix to automate security checks without blocking CI.
🎯 Scope: SAFETY CLI V3 INTEGRATION & CONFIGURATION ONLY
What This PR DOES:
✅ Eliminate Interactive Prompts
.safety-project.inito pre-configure codebase name and scan settings.✅ Implement Policy-Driven Security Scanning
.safety-policy.ymlto define vulnerability severity thresholds.✅ Integrate Safety Scan into CircleCI
safety-scanjob to.circleci/config.yml.✅ Maintain CI Robustness
What This PR DOES NOT DO:
❌ No new application features (only CI/security tooling)
❌ No refactoring of application code (only configuration files)
❌ No architecture changes (only CI pipeline updates)
❌ No testing improvements (beyond enabling the safety scan itself)
❌ No scope creep (strictly focused on Safety CLI integration)
🚨 CRITICAL PROBLEM ADDRESSED:
Root Cause:
Safety CLI v3.6.0 (and similar versions) requires interactive codebase initialization (
Enter a name for this codebase) even when--non-interactiveflags are used. This was blocking the CI pipeline, preventing automated security scans from completing.Impact:
📊 Change Summary
🔍 Files Modified
Files Fixed/Added:
.circleci/config.yml- ✅ MODIFIED (Addedsafety-scanjob and workflow step).safety-project.ini- ✅ NEW FILE (Pre-configures Safety CLI to prevent prompts).safety-policy.yml- ✅ NEW FILE (Defines vulnerability policy for CI)Files Identified for Future Fixes:
🧪 Testing Improvements Made
1. Critical Blocking Issues Resolved
2. Code Quality Improvements
🚀 Benefits of This Focused Approach
For Developers:
For CI/CD:
🔒 SCOPE CONTROL MEASURES
1. Strict Focus:
2. Separation of Concerns:
cursor/automate-safety-scan-with-project-config-1a0a)🧪 Testing Instructions
Before (Blocked):
After (Working):
safety-scanjob:.safety-project.iniand.safety-policy.yml.🎯 Success Criteria
.safety-policy.yml) is applied correctly.🚀 Future Considerations
Next Phase (Separate PR):
.safety-policy.ymlfor different environments (e.g., production).📋 Review Checklist
🎉 CONCLUSION
This PR fully automates and integrates Safety CLI v3 into our CI pipeline, resolving a critical blocking issue caused by interactive prompts. It establishes a robust, policy-driven security scanning mechanism for our dependencies, significantly enhancing our project's security posture without introducing scope creep.
Ready for review and merge! 🚀
Summary by Sourcery
Automate dependency vulnerability scanning in CI by integrating Safety CLI v3 in non-interactive mode with project and policy configurations to enforce high/critical severity failures
New Features:
Enhancements:
CI: