Skip to content

Commit

Permalink
Blacklist /support/ and /resources/ anywhere in the URL (#121); r=Ms2ger
Browse files Browse the repository at this point in the history
  • Loading branch information
Ms2ger authored Sep 22, 2016
1 parent 0190bc1 commit 9cda987
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 5 additions & 3 deletions manifest/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@
@pytest.mark.parametrize("url", [
"/foo",
"/tools/foo",
"/resources/foo",
"/common/foo",
"/conformance-checkers/foo",
"/_certs/foo"
"/_certs/foo",
"/resources/foo",
"/support/foo",
"/foo/resources/bar",
"/foo/support/bar"
])
def test_is_blacklisted(url):
assert is_blacklisted(url) is True


@pytest.mark.parametrize("url", [
"/foo/tools/bar",
"/foo/resources/bar",
"/foo/common/bar",
"/foo/conformance-checkers/bar",
"/foo/_certs/bar"
Expand Down
4 changes: 4 additions & 0 deletions manifest/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from six import BytesIO

blacklist = ["/tools/", "/resources/", "/common/", "/conformance-checkers/", "/_certs/"]
blacklist_in = ["/resources/", "/support/"]

def rel_path_to_url(rel_path, url_base="/"):
assert not os.path.isabs(rel_path)
Expand All @@ -17,6 +18,9 @@ def is_blacklisted(url):
for item in blacklist:
if url.startswith(item):
return True
for item in blacklist_in:
if item in url:
return True
return False

def from_os_path(path):
Expand Down

0 comments on commit 9cda987

Please sign in to comment.