fix: handle SSL and DNS errors gracefully in DNStwist analyzer. Close #3282#3290
fix: handle SSL and DNS errors gracefully in DNStwist analyzer. Close #3282#3290NikhilRaikwar wants to merge 3 commits intointelowlproject:developfrom
Conversation
| report = dnstwist.run(**params) | ||
| except (OSError, ssl.SSLError) as e: | ||
| return {"error": f"Network/SSL error: {str(e)}"} | ||
| except Exception as e: |
There was a problem hiding this comment.
unexpected errors should still make the analyzer fail so please remove this.
Here we want to manage the errors that are not caused by the tool itself but are based on the input data based on the current observations that we reported in the issue.
There was a problem hiding this comment.
I've removed the catch-all Exception block in the latest commit.
|
Hi @mlodic, Thanks for the feedback! I've removed the catch-all The analyzer now only catches |
|
This pull request has been marked as stale because it has had no activity for 10 days. If you are still working on this, please provide some updates or it will be closed in 5 days. |
Description
This PR fixes the
ssl.SSLEOFErrorandsocket.gaierrorin the DNStwist analyzer. These errors occurred when the analyzer encountered misconfigured domains or non-existent domains, causing the Celery worker to crash or report a failed job.The fix wraps the
dnstwist.run()call in atry...exceptblock to catchssl.SSLErrorandsocket.error. Instead of failing, the analyzer now returns a structured error message within the analysis report, allowing IntelOwl to handle the situation gracefully and inform the user.Closes #3282
Type of change
Checklist
developdumpplugincommand and added it in the project as a data migration. (N/A)urlthat contains this information.get_mocker_response()method of the unittest class.DataModelfor the new analyzer... (N/A)# This file is a part of IntelOwl https://github.com/intelowlproject/IntelOwl # See the file 'LICENSE' for copying permission.Ruff) gave 0 errors.testsfolder). All the tests (new and old ones) gave 0 errors.DeepSource,Django Doctorsor other third-party linters have triggered any alerts during the CI checks, I have solved those alerts.Screenshots & Verification
The fix has been verified by simulating the SSL and DNS exceptions encountered during analysis and by adding automated unit tests.
1. Automated Unit Tests Result
Added 3 new test cases to

tests/api_app/analyzers_manager/unit_tests/observable_analyzers/test_dnstwist.pyto verify handling ofSSLEOFError,gaierror, and unexpected exceptions.(Command:
python3 manage.py test tests.api_app.analyzers_manager.unit_tests.observable_analyzers.test_dnstwist)2. DNS Resolution Error Handling
Verified that non-existent domains now return a graceful gateway error instead of crashing the worker.

3. SSL Handshake Error Handling
Verified that domains with SSL/TLS protocol violations (Python 3.11 strict handling) are now caught and reported.

4. Celery Worker Stability
The Celery worker logs confirm that these exceptions no longer produce tracebacks or interrupt the worker process.

JSON Result (Graceful error report)
{ "error": "Network/SSL error: [Errno -2] Name or service not known" }Important Rules