Artemis
Artemis copied to clipboard
Domain Scanner
π Implement domain validation and task addition for efficient scanning
π Description
This PR introduces two complementary methods in the ArtemisBase
class: check_domain_exists
for domain validation and add_valid_domains_task
for adding tasks for valid domains. The primary purpose of these additions is to ensure that only valid domains are sent for further scanning, improving efficiency and reducing unnecessary processing.
π§ Changes
- β¨ Added
check_domain_exists
andadd_valid_domains_task
method toArtemisBase
class - π Implemented domain validation logic using NS and A record lookups
- π Created a method to filter and add tasks only for valid domains
- Fix mock setup in
ArtemisModuleTestCase
to handle multiple arguments in lookup function calls, resolving TypeError in tests.- This change is important because:
- It fixes a breaking error in the test suite, allowing tests to run successfully.
- It more accurately mimics the real lookup function's signature, improving test fidelity.
- It prevents false negatives in tests that could mask real issues in the code being tested.
- It ensures that the mock can handle various lookup calls throughout the codebase, increasing test coverage and reliability.
- This change is important because:
π Benefits
- π― Ensures only valid domains proceed to further scanning stages
- π Improves overall system efficiency by reducing unnecessary scans
- 𧩠Provides reusable domain validation logic across modules
- π Centralizes the process of adding tasks for valid domains
- π‘οΈ Reduces potential false positives from invalid or non-existent domains
π€ How the methods complement each other
-
check_domain_exists
verifies the validity of a domain by checking for NS or A records -
add_valid_domains_task
usescheck_domain_exists
to filter out invalid domains - Only domains that pass the validation are added as new tasks for further scanning
This combination ensures a streamlined and efficient domain processing pipeline.
πTesting
- [x] Updated unit tests for the
check_domain_exists
method to ensure all scenarios are covered, including:- Domains with only NS records
- Domains with only A records
- Domains with both NS and A records
- Non-existent domains
- Scenarios where DNS resolution fails
TODO
- remove NS records for subdomains maybe? since most of them will inherit it from the parent domains and for subdomains only A records will be checked.
π Related Issues
Closes #1094