Skip to content

Conversation

@ic0ns
Copy link
Contributor

@ic0ns ic0ns commented Jun 23, 2025

Summary

  • Enhanced ScanTarget to support multiple IP addresses per hostname
  • Implemented backward-compatible solution maintaining existing API
  • Updated related components to handle multiple IPs correctly

Changes

  • Modified ScanTarget class to store multiple IPs in a List<String> field
  • Updated fromTargetString() method to resolve all IP addresses using InetAddress.getAllByName()
  • Maintained backward compatibility by keeping the existing ip field and marking getIp()/setIp() as deprecated
  • Updated DenylistFileProvider to check all IPs when evaluating denylists
  • Added MongoDB index for the new ips field to support efficient queries
  • Added comprehensive unit tests for both ScanTarget and DenylistFileProvider

Test Plan

  • Added unit tests for ScanTarget multiple IP functionality
  • Added unit tests for DenylistFileProvider with multiple IPs
  • All existing tests pass without modification
  • Manual testing with hostnames that resolve to multiple IPs

Fixes #11

- Changed ScanTarget to store multiple IP addresses in a List<String>
- Updated fromTargetString() to resolve all IPs using getAllByName()
- Maintained backward compatibility with deprecated getIp()/setIp() methods
- Updated DenylistFileProvider to check all IPs when evaluating denylists
- Added MongoDB index for the new ips field
- Added comprehensive unit tests for the new functionality

Fixes #11
Comment on lines +168 to +171
if (this.ips.isEmpty() || !this.ips.get(0).equals(ip)) {
this.ips = new ArrayList<>();
this.ips.add(ip);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could cause weird effects. I would assume that this function just sets ips to a list of size 1.

Comment on lines +78 to +83
for (String ip : target.getIps()) {
if (ipDenylistSet.contains(ip)
|| cidrDenylist.stream().anyMatch(subnetInfo -> isInSubnet(ip, subnetInfo))) {
return true;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure what the correct behavior is, if a domain resolves to two IPs and only one is denylisted:

1: We do not scan this domain at all. Maybe the domain owner just forgot to tell us all IPs -> the intention of the denylist entry is to not be scanned at all.
2: We scan the domain, but just exclude the denylisted IPs. Maybe the domain is on two different infrastructures, and one of the infrastructures is on our denylist -> domain does not mind being scanned. Also: Some domains may resolve to IPs that are on our denylist for other reasons (local IPs).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support multiple IPs per hostname in ScanTarget

3 participants