-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix findings upload during dry #657
Conversation
Reviewer's Guide by SourceryThis PR fixes a bug where the findings file was not uploaded during a dry run. It modifies the Sequence diagram for findings upload during dry runsequenceDiagram
participant Agent
participant Config
participant Upload
Note over Agent: Changes to handle dry run
Agent->>Config: Check dry run status
Config-->>Agent: Return dry status
Agent->>Agent: Process findings
Note over Agent: Remove conditional check
Agent->>Upload: Upload findings file
Note over Upload: Upload checks should_upload internally
Upload-->>Agent: Upload complete
Flow diagram for findings upload logicflowchart TD
A[Start] --> B[Process Repository]
B --> C[Generate Findings]
C --> D{Findings Success?}
D -->|Yes| E[Upload Findings]
D -->|No| F[Skip Processing]
E --> G[End]
F --> G
note[Upload happens regardless of dry run status]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @SeanTConrad - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #657 +/- ##
==========================================
- Coverage 77.57% 77.55% -0.03%
==========================================
Files 29 29
Lines 2181 2179 -2
==========================================
- Hits 1692 1690 -2
Misses 489 489 ☔ View full report in Codecov by Sentry. |
route="git", | ||
source=repo_name | ||
) | ||
# if Path(git_output_file).exists(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will cause errors when we attempt to upload files that don't exist, won't it? We've had that before where one bit fails
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check for "if Path(git_output_file).exists():" was added two years ago, but there's not a similar check for all the other uploads. So all the others write this to the log:
2025-01-13 11:04:05 /home/stconrad/verinfast/src/verinfast/agent.py@168 upload: File does not exist: /home/stconrad/veri
nfast/tests/results_dry/small-test-repo.git.git.log.json
2025-01-13 11:04:05 /home/stconrad/verinfast/src/verinfast/agent.py@168 upload: File does not exist: /home/stconrad/veri
nfast/tests/results_dry/small-test-repo.git.sizes.json
2025-01-13 11:04:05 /home/stconrad/verinfast/src/verinfast/agent.py@168 upload: File does not exist: /home/stconrad/veri
nfast/tests/results_dry/small-test-repo.git.stats.json
2025-01-13 11:04:05 /home/stconrad/verinfast/src/verinfast/agent.py@168 upload: File does not exist: /home/stconrad/veri
nfast/tests/results_dry/small-test-repo.git.findings.json
Upload has an error check:
def upload(self, file: str, route: str, source: str = '', isJSON=True):
if not self.config.shouldUpload:
self.log(
msg='Skipping Uploads',
tag=f"Skipping uploading {file} for {source} to {self.config.baseUrl}/{route}.",
display=True
)
return True
if not Path(file).exists():
self.log(
msg=f"File does not exist: {file}"
)
return False
I think we added the error check to upload, but never cleaned up git, because it was first.
Why are these changes needed?
A November release had changes to fix the scan from crashing when the machine had no Internet access. These changes accidentally introduced a bug where the findings file would not upload on a "dry" run.
Related issue number
Checks
Summary by Sourcery
Bug Fixes: