-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
detect fork-bombs during build dependencies installs
- Loading branch information
1 parent
3ae5219
commit 43b8ed4
Showing
26 changed files
with
141 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,77 @@ | ||||
from __future__ import absolute_import | ||||
|
||||
import contextlib | ||||
import errno | ||||
import hashlib | ||||
import logging | ||||
import os | ||||
|
||||
from pip._internal.utils.temp_dir import TempDirectory | ||||
|
||||
|
||||
logger = logging.getLogger(__name__) | ||||
|
||||
|
||||
class RequirementTracker(object): | ||||
|
||||
def __init__(self): | ||||
self._root = os.environ.get('PIP_REQ_TRACKER') | ||||
if self._root is None: | ||||
self._temp_dir = TempDirectory(delete=False, kind='req-tracker') | ||||
self._temp_dir.create() | ||||
self._root = os.environ['PIP_REQ_TRACKER'] = self._temp_dir.path | ||||
logger.debug('Created requirements tracker %r', self._root) | ||||
else: | ||||
self._temp_dir = None | ||||
logger.debug('Re-using requirements tracker %r', self._root) | ||||
self._entries = set() | ||||
|
||||
def __enter__(self): | ||||
return self | ||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb): | ||||
self.cleanup() | ||||
|
||||
def _entry_path(self, link): | ||||
hashed = hashlib.sha224(link.url_without_fragment.encode()).hexdigest() | ||||
return os.path.join(self._root, hashed) | ||||
|
||||
def add(self, req): | ||||
link = req.link | ||||
info = str(req) | ||||
entry_path = self._entry_path(link) | ||||
try: | ||||
with open(entry_path) as fp: | ||||
# Error, these's already a build in progress. | ||||
raise LookupError('%s is already being built: %s' | ||||
% (link, fp.read())) | ||||
except IOError as e: | ||||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
pradyunsg
Member
|
except IOError as e: |
If you could file an issue about this, that'll be awesome.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include pyproject.toml |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[build-system] | ||
requires = ["setuptools", "wheel", "pep518_forkbomb"] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from setuptools import setup | ||
|
||
setup(name='pep518_forkbomb', | ||
version='235', | ||
py_modules=['pep518_forkbomb']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include pyproject.toml |
Empty file.
2 changes: 2 additions & 0 deletions
2
tests/data/src/pep518_twin_forkbombs_first-234/pyproject.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[build-system] | ||
requires = ["setuptools", "wheel", "pep518_twin_forkbombs_second"] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from setuptools import setup | ||
|
||
setup(name='pep518_twin_forkbombs_first', | ||
version='234', | ||
py_modules=['pep518_twin_forkbombs_first']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include pyproject.toml |
Empty file.
2 changes: 2 additions & 0 deletions
2
tests/data/src/pep518_twin_forkbombs_second-238/pyproject.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[build-system] | ||
requires = ["setuptools", "wheel", "pep518_twin_forkbombs_first"] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from setuptools import setup | ||
|
||
setup(name='pep518_twin_forkbombs_second', | ||
version='238', | ||
py_modules=['pep518_twin_forkbombs_second']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ideally, this should use
except (IOError, OSError) as e:
to remain compatible with Python versions < 3.2 (including 2.x).