Skip to content
Merged
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
17 changes: 13 additions & 4 deletions tests/test_ssrf_protection.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,25 @@
import pytest

from appguardrail_core.controlplane import SafeRedirectHandler, _is_safe_url
from scanner.cli.appguardrail import _is_safe_url as _cli_is_safe_url


def test_is_safe_url_public_domains():
assert _is_safe_url("http://google.com/")
assert _is_safe_url("https://github.com/")

def test_is_safe_url_invalid_types():
assert not _is_safe_url(None)
assert not _is_safe_url(123)
assert not _is_safe_url(True)
@pytest.mark.parametrize(
"validator",
[_is_safe_url, _cli_is_safe_url],
ids=["controlplane", "cli"],
)
@pytest.mark.parametrize(
"value",
[123, True, None, [], {}],
ids=["integer", "boolean", "none", "list", "mapping"],
)
def test_is_safe_url_invalid_types(validator, value):
assert not validator(value)


def test_is_safe_url_ipv4_localhost():
Expand Down
Loading