Skip to content

Commit

Permalink
Merge pull request #181 from Syslifters/sysreptor-303-redirect-issues
Browse files Browse the repository at this point in the history
Raise error if server redirects
  • Loading branch information
aronmolnar authored Aug 20, 2024
2 parents 1cbba47 + 9751cc0 commit fbf28f8
Show file tree
Hide file tree
Showing 4 changed files with 13,905 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.22
* Update reptor for updated SysReptor field definition
* Raise error if wrong server URL was specified

# 0.21
* Create findings from finding templates
* Fix errors in exportfindings plugin
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "reptor"
version = "0.21"
version = "0.22"
authors = [
{ name="Richard Schwabe" },
{ name="Aron Molnar", email="[email protected]" }
Expand Down
7 changes: 6 additions & 1 deletion reptor/api/APIClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ def _get_headers(self, json_content=True) -> typing.Dict:
def _prepare_kwargs(self, kwargs, json_content=True):
return kwargs | {
'headers': kwargs.get('headers', {}) | self._get_headers(json_content=json_content),
'verify': kwargs.get('verify', self.verify)
'verify': kwargs.get('verify', self.verify),
'allow_redirects': False,
}

@property
Expand Down Expand Up @@ -164,6 +165,10 @@ def _do_request(
self.debug(f"{method} URL: {url}")
kwargs = self._prepare_kwargs(kwargs, json_content=json_content)
response = methods[method](url, **kwargs)
if response.headers.get('location'):
raise requests.exceptions.HTTPError(
f"Received redirect to {response.headers.get('location')}. Maybe run \"reptor conf\" to update your server URL?"
)
self.debug(f"Received response: {response.content[:1000]}")
response.raise_for_status()
return response
Expand Down
13,894 changes: 13,894 additions & 0 deletions reptor/plugins/tools/Nessus/tests/data/nessus_v_unknown.nessus

Large diffs are not rendered by default.

0 comments on commit fbf28f8

Please sign in to comment.