findcdn icon indicating copy to clipboard operation
findcdn copied to clipboard

Handle invalid domains more gracefully

Open S4lt5 opened this issue 2 years ago โ€ข 3 comments

๐Ÿ—ฃ Description

As per #42, invalid domains should be handled gracefully.

These are checked for in main() before running the executor, and put in a separate "invalid domains" bucket.

Also, as part of code cleanup, the domain class was moved to a separate python file.

There is a LOT to do and a lot of redundant call chains to be removed, but each journey starts with a single step!

๐Ÿ’ญ Motivation and context

๐Ÿงช Testing

Added unit tests for valid/invalid cdnCheck() and main() calls with valid/invalid domains

Sample output

โฏ findcdn list "*.domain.com"
0 Domains Validated.
1 domain(s) rejected, listed below:
	*.domain.com
0it [00:00, ?it/s]
{
    "date": "11/21/2022, 11:44:09",
    "cdn_count": "0",
    "domains": {},
    "invalid_domains": [
        "*.domain.com"
    ]
}
Domain processing completed.
0 domains had CDN's out of 1.
1 Domains Validated.
2 domain(s) rejected, listed below:
	*.foo.bar
	wildcard domain
[Pending: 0 jobs]==[Threads: 1]: 100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 1/1 [00:01<00:00,  1.26s/it]
{
    "date": "11/21/2022, 11:44:53",
    "cdn_count": "1",
    "domains": {
        "cisa.gov": {
            "IP": "'104.117.51.217'",
            "cdns": "'.edgekey.net', '.akamaitechnologies.fr'",
            "cdns_by_names": "'Akamai', 'Akamai'"
        }
    },
    "invalid_domains": [
        "*.foo.bar",
        "wildcard domain"
    ]
}
Domain processing completed.
1 domains had CDN's out of 3.

โœ… Pre-approval checklist

  • [ ] This PR has an informative and human-readable title.
  • [ ] Changes are limited to a single goal - eschew scope creep!
  • [ ] All future TODOs are captured in issues, which are referenced in code comments.
  • [ ] All relevant type-of-change labels have been added.
  • [ ] I have read the CONTRIBUTING document.
  • [ ] These code changes follow cisagov code standards.
  • [ ] All relevant repo and/or project documentation has been updated to reflect the changes in this PR.
  • [ ] Tests have been added and/or modified to cover the changes in this PR.
  • [ ] All new and existing tests pass.

โœ… Pre-merge checklist

  • [ ] Revert dependencies to default branches.
  • [ ] Finalize version.

โœ… Post-merge checklist

  • [ ] Add a tag or create a release.

S4lt5 avatar Nov 21 '22 17:11 S4lt5