Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix issue where duplicate query params were passed #195

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions snyk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def get(
params: dict = None,
version: str = None,
exclude_version: bool = False,
exclude_params: bool = False,
) -> requests.Response:
"""
Rest (formerly v3) Compatible Snyk Client, assumes the presence of Version, either set in the client
Expand All @@ -146,7 +147,7 @@ def get(
else:
url = f"{self.api_url}/{path}"

if params or self.version:
if (params or self.version) and not exclude_params:

if not params:
params = {}
Expand Down Expand Up @@ -223,7 +224,9 @@ def get_rest_pages(self, path: str, params: dict = {}) -> List:
next_url = page_data.get("links", {}).get("next")

# The next url comes back fully formed (i.e. with all the params already set, so no need to do it here)
next_page_response = self.get(next_url, {}, exclude_version=True)
next_page_response = self.get(
next_url, {}, exclude_version=True, exclude_params=True
)
page_data = next_page_response.json()
return_data.extend(page_data["data"])
logger.debug(
Expand Down
7 changes: 6 additions & 1 deletion snyk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ def cleanup_path(path: str) -> str:
if path[-1] == "/":
path = path.rstrip("/")

return path
# Ensure we remove "rest/" from next urls
parts = path.split("/")
if parts[0] == "rest":
parts.pop(0)

return "/".join(parts)


def load_test_data(test_dir: str, test_name: str) -> dict:
Expand Down