Reject non-public URLs in JIRA connection helper#14867
Open
Maffooch wants to merge 2 commits into
Open
Conversation
`connect_to_jira` in `dojo/jira/helper.py` passed the configured server URL straight into the `JIRA()` client with no pre-flight validation. URLs pointing at private, loopback, or link-local addresses produced low-level connection errors instead of a clean form validation message. Now `connect_to_jira` calls `validate_url_for_ssrf` from `dojo.utils_ssrf` (the same helper already used by `dojo/tools/risk_recon/api.py`) before constructing the JIRA client. A blocked URL raises `ValueError`, which `BaseJiraForm.test_jira_connection` already catches and surfaces as a form-validation error. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`connect_to_jira` now rejects unresolvable hostnames via `validate_url_for_ssrf` before invoking the JIRA client, surfacing as `ValueError`. Broaden the `assertRaises` to accept the new path while keeping the original requests-level failure mode as a fallback. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
connect_to_jiraindojo/jira/helper.pypassed the configured server URL straight into theJIRA()client with no pre-flight validation. URLs pointing at private, loopback, or link-local addresses (e.g. a typo'd hostname resolving to127.0.0.1, or a copy-pasted internal address like172.18.0.3) produced low-level connection errors / unhandled stacktraces instead of a clean form validation message.connect_to_jiracallsvalidate_url_for_ssrffromdojo.utils_ssrf(the same helper already used bydojo/tools/risk_recon/api.py) before constructing the JIRA client. A blocked URL raisesValueError("JIRA URL is not allowed: …"), whichBaseJiraForm.test_jira_connectionalready catches and surfaces as a form-validation error on theusername/passwordfields.unittests/test_jira_helper_ssrf.pycovering RFC 1918, loopback, link-local, an unsupported scheme, the happy-path public URL (mocking theJIRAclient), and the form-level error path.Test plan
python manage.py test unittests.test_jira_helper_ssrfpython manage.py test unittests.test_utils_ssrfpython manage.py checkruff check . --fix