Skip to content

Commit 304aad0

Browse files
committed
feat(conf): allow only npm.yandex-team.ru for tarballs
3a6842acece105b7a4de5c3c9a89c1ad78558140
1 parent b5c4ec4 commit 304aad0

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

build/plugins/lib/nots/package_manager/base/lockfile.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@
44
from six import add_metaclass
55

66

7+
class LockfilePackageMetaInvalidError(RuntimeError):
8+
pass
9+
10+
11+
def is_tarball_url_valid(tarball_url):
12+
if not tarball_url.startswith("https://") and not tarball_url.startswith("http://"):
13+
return True
14+
15+
return tarball_url.startswith("https://npm.yandex-team.ru/") or tarball_url.startswith("http://npm.yandex-team.ru/")
16+
17+
718
class LockfilePackageMeta(object):
819
"""
920
Basic struct representing package meta from lockfile.
@@ -16,6 +27,11 @@ def from_str(s):
1627
return LockfilePackageMeta(*s.strip().split(" "))
1728

1829
def __init__(self, key, tarball_url, sky_id, integrity, integrity_algorithm):
30+
if not is_tarball_url_valid(tarball_url):
31+
raise LockfilePackageMetaInvalidError(
32+
"tarball can only point to npm.yandex-team.ru, got {}".format(tarball_url)
33+
)
34+
1935
# http://npm.yandex-team.ru/@scope%2fname/-/name-0.0.1.tgz
2036
parts = tarball_url.split("/")
2137

@@ -37,10 +53,6 @@ def to_uri(self):
3753
return pkg_uri
3854

3955

40-
class LockfilePackageMetaInvalidError(RuntimeError):
41-
pass
42-
43-
4456
@add_metaclass(ABCMeta)
4557
class BaseLockfile(object):
4658
@classmethod

0 commit comments

Comments
 (0)