Repository navigation
CRASM-4351: FIlter Shodan Data to Attested CIDR IPs Only - #1642
Conversation
rapidray12
left a comment
There was a problem hiding this comment.
Query_cidrs_by_org() returns an empty DataFrame on API/connection/JSON failure. With the new logic, a CIDR API outage becomes indistinguishable from "this org has no attested CIDRs". THis causes the scan to skip all IPs and remove all Shodan findings.
A check for API returns and a logged error need to be added
Also not sure about how old/inactive CIDRS are handled. We need to confirm that old CIDR (inactive) blocks are not reported as active
|
I'll look into those query_cidrs_by_org() concerns. As for old/inactive CIDRs, that's handled by the ASM Sync process. Every time the ASM Sync runs it adds in the latest CIDRs from the CyHy MongoDB database and updates the "last_seen" field. Any CIDR records who have a "last_seen" date > 15 days old gets marked as inactive and are not used in P&E scripts/reports. |
|
Updated query_cidrs_by_org() error handling and edge cases |
rapidray12
left a comment
There was a problem hiding this comment.
Issues with handling API failures has been fixed.
ameliav
left a comment
There was a problem hiding this comment.
Spoke with Alex about a high finding from DHS chat which he will fix. Basically, he just needs to add a way to ensure that when null/none data is returned, it won't error out looking for the IP column.
|
Updated code based on Amelia's feedback so that it explicity checks for the presence of an "ip" column in query_shodan()'s output |
ameliav
left a comment
There was a problem hiding this comment.
Finding has been addressed so LGTM
rapidray12
left a comment
There was a problem hiding this comment.
Earlier status return issues have been fixed,
LGTM
🗣 Description
Add filters to report generation and shodan data collection scripts so that they only use Shodan findings with IPs that are contained within an organization's attested CIDRs.
💭 Motivation and context
We recently observed excessive shodan results that involved IP addresses that are not within an organization's attested CIDR blocks. This caused an issue with writing to excel (file too big) and the federal side also doesn't want to report non-CIDR ips to customers in general
🧪 Testing
Manually created sample data records to populate the CIDR, shodan_assets, and shodan_vulns tables locally. Then ran the updated report generation and shodan scripts to confirm the code is now filtering shodan results to only IPs within customer-owned CIDRs. Also updated unit tests to factor in filter changes
✅ Pre-approval checklist
bump_versionscript if this repository is versioned and the changes in this PR warrant a version bump.✅ Pre-merge checklist
✅ Post-merge checklist