fix: handle urlscan pagination and source errors safely - #136
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughAlienVault and Common Crawl now classify failure results as ChangesSource handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Run
participant urlscan_API
participant buildSearchAfter
Run->>urlscan_API: Request search page
urlscan_API-->>Run: Return results, has_more, and sort
Run->>buildSearchAfter: Validate sort data
buildSearchAfter-->>Run: Return next-page token
Run->>urlscan_API: Request next page with token
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/source/urlscan/urlscan.go`:
- Around line 70-84: The buildSearchAfter function must reject non-finite and
fractional first sort values before formatting, while preserving valid integral
values. Validate the float64 with an integral-safe check, format it without
converting through int, and update the related tests in
pkg/source/urlscan/urlscan_test.go lines 275-309 to cover fractional and
non-finite rejection; the implementation change belongs in
pkg/source/urlscan/urlscan.go lines 70-84.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 70e07d85-b2f1-4f3b-b460-47e7bcf4a28a
📒 Files selected for processing (4)
pkg/source/alienvault/alienvault.gopkg/source/commoncrawl/commoncrawl.gopkg/source/urlscan/urlscan.gopkg/source/urlscan/urlscan_test.go
|
Fixed by rejecting fractional and non-finite cursor values and formatting the validated number without converting it to int. |
|
The lint check is failing before analyzing this PR because the All build jobs pass on Linux, macOS, and Windows, and CodeQL reports no new alerts. This appears to be an issue with the shared lint action rather than the changes in this PR. |
Description
This PR prevents urlscan from panicking when the API returns incomplete or malformed pagination sort values.
Previously, urlscan accessed the second sort value after only checking that the first one existed. It also used an unsafe type assertion for the first value, which could cause another panic if the API returned an unexpected type.
Pagination sort values are now validated before use and are only extracted when another page is available.
The PR also adds the missing
source.Errortype to error results in the AlienVault, Common Crawl, and urlscan sources. Without this type, the runner interpreted those errors as URL results and silently discarded them.Changes
has_moreis false.source.Errortypes to AlienVault, Common Crawl, and urlscan error results.Testing