GitHub PullRequestEvent at 2014-09-14 22:52:12
Repository: pip
Actor: jeverling
Payload: {"action":"opened","number":2035,"pull_request":{"url":"https://api.github.com/repos/pypa/pip/pulls/2035","id":21209454,"html_url":"https://github.com/pypa/pip/pull/2035","diff_url":"https://github.com/pypa/pip/pull/2035.diff","patch_url":"https://github.com/pypa/pip/pull/2035.patch","issue_url":"https://api.github.com/repos/pypa/pip/issues/2035","number":2035,"state":"open","locked":false,"title":"Raise SuspiciousVersion exception if git branch/tag looks like commit id","user":{"login":"jeverling","id":121946,"avatar_url":"https://avatars.githubusercontent.com/u/121946?v=2","gravatar_id":"c4980c64353203e4e736557989b50542","url":"https://api.github.com/users/jeverling","html_url":"https://github.com/jeverling","followers_url":"https://api.github.com/users/jeverling/followers","following_url":"https://api.github.com/users/jeverling/following{/other_user}","gists_url":"https://api.github.com/users/jeverling/gists{/gist_id}","starred_url":"https://api.github.com/users/jeverling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeverling/subscriptions","organizations_url":"https://api.github.com/users/jeverling/orgs","repos_url":"https://api.github.com/users/jeverling/repos","events_url":"https://api.github.com/users/jeverling/events{/privacy}","received_events_url":"https://api.github.com/users/jeverling/received_events","type":"User","site_admin":false},"body":"I think the current behavior when installing a specific revision from a git repository is potentially problematic. When specifying a revision using `@`, pip will first check if there is a remote branch that matches, then will check for local branch or tag and after that will assume a commit id (`\"Could not find a tag or branch '%s', assuming commit.\" % rev,`).\r\nThis means that it is possible to name a branch or tag like a previous commit, thus replacing the commit with different code.\r\nIf there are projects that install packages from github and pin them to specific revisions in requirements.txt (I frequently do), than it would be possible for a person gaining access to the git repo to replace this commit with different code. Admittedly this is pretty far fetched, but I think pip should nonetheless make sure that this cannot be done. I've created a \"proof of concept\" here: [https://bitbucket.org/jeverling/pip_git_issue/](https://bitbucket.org/jeverling/pip_git_issue/)\r\n\r\nThere is a commit b6b948c237013603e2eb77d29d4463c8d0e51229 that contains a module that does nothing more than printing \"hello world!\" when imported. Then I've created a branch that is named like this commit id. If you do now install this package using pip (`pip install -e \"git+git@bitbucket.org:jeverling/pip_git_issue.git@b6b948c237013603e2eb77d29d4463c8d0e51229#egg=pip_git_issue\"` or using requirements.txt from the repo) a different module will be installed that will start a HTTP server that serves your root directory (on localhost, to demonstrate the potential for abuse). I thought for a while about how to deal with this (albeit very artificial) case, and I think the best course of action is to just raise an exception if a branch or tag is named like a git commit id hash. It would be possible to e.g. ask for user interaction, but I think it is extremely unlikely that a 40 character hex-string is being used as branch or tag name without something being not quite right.\r\n\r\nI have defined a new exception `pip.exceptions.SuspiciousVersion`, which is raised by `pip.vcs.git.check_rev_options` if rev matches `r\"\\b[a-f0-9]{40}\\b\"`. In my opinion this should take care of this potential problem.\r\n\r\nBest Regards,\r\n\r\nJesaja Everling\r\n","created_at":"2014-09-14T22:52:12Z","updated_at":"2014-09-14T22:52:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pypa/pip/pulls/2035/commits","review_comments_url":"https://api.github.com/repos/pypa/pip/pulls/2035/comments","review_comment_url":"https://api.github.com/repos/pypa/pip/pulls/comments/{number}","comments_url":"https://api.github.com/repos/pypa/pip/issues/2035/comments","statuses_url":"https://api.github.com/repos/pypa/pip/statuses/083d1878583ae35edaf587a79984e003c2e25c22","head":{"label":"jeverling:develop","ref":"develop","sha":"083d1878583ae35edaf587a79984e003c2e25c22","user":{"login":"jeverling","id":121946,"avatar_url":"https://avatars.githubusercontent.com/u/121946?v=2","gravatar_id":"c4980c64353203e4e736557989b50542","url":"https://api.github.com/users/jeverling","html_url":"https://github.com/jeverling","followers_url":"https://api.github.com/users/jeverling/followers","following_url":"https://api.github.com/users/jeverling/following{/other_user}","gists_url":"https://api.github.com/users/jeverling/gists{/gist_id}","starred_url":"https://api.github.com/users/jeverling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeverling/subscriptions","organizations_url":"https://api.github.com/users/jeverling/orgs","repos_url":"https://api.github.com/users/jeverling/repos","events_url":"https://api.github.com/users/jeverling/events{/privacy}","received_events_url":"https://api.github.com/users/jeverling/received_events","type":"User","site_admin":false},"repo":{"id":24035142,"name":"pip","full_name":"jeverling/pip","owner":{"login":"jeverling","id":121946,"avatar_url":"https://avatars.githubusercontent.com/u/121946?v=2","gravatar_id":"c4980c64353203e4e736557989b50542","url":"https://api.github.com/users/jeverling","html_url":"https://github.com/jeverling","followers_url":"https://api.github.com/users/jeverling/followers","following_url":"https://api.github.com/users/jeverling/following{/other_user}","gists_url":"https://api.github.com/users/jeverling/gists{/gist_id}","starred_url":"https://api.github.com/users/jeverling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeverling/subscriptions","organizations_url":"https://api.github.com/users/jeverling/orgs","repos_url":"https://api.github.com/users/jeverling/repos","events_url":"https://api.github.com/users/jeverling/events{/privacy}","received_events_url":"https://api.github.com/users/jeverling/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jeverling/pip","description":"The PyPA recommended tool for installing Python packages","fork":true,"url":"https://api.github.com/repos/jeverling/pip","forks_url":"https://api.github.com/repos/jeverling/pip/forks","keys_url":"https://api.github.com/repos/jeverling/pip/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jeverling/pip/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jeverling/pip/teams","hooks_url":"https://api.github.com/repos/jeverling/pip/hooks","issue_events_url":"https://api.github.com/repos/jeverling/pip/issues/events{/number}","events_url":"https://api.github.com/repos/jeverling/pip/events","assignees_url":"https://api.github.com/repos/jeverling/pip/assignees{/user}","branches_url":"https://api.github.com/repos/jeverling/pip/branches{/branch}","tags_url":"https://api.github.com/repos/jeverling/pip/tags","blobs_url":"https://api.github.com/repos/jeverling/pip/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jeverling/pip/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jeverling/pip/git/refs{/sha}","trees_url":"https://api.github.com/repos/jeverling/pip/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jeverling/pip/statuses/{sha}","languages_url":"https://api.github.com/repos/jeverling/pip/languages","stargazers_url":"https://api.github.com/repos/jeverling/pip/stargazers","contributors_url":"https://api.github.com/repos/jeverling/pip/contributors","subscribers_url":"https://api.github.com/repos/jeverling/pip/subscribers","subscription_url":"https://api.github.com/repos/jeverling/pip/subscription","commits_url":"https://api.github.com/repos/jeverling/pip/commits{/sha}","git_commits_url":"https://api.github.com/repos/jeverling/pip/git/commits{/sha}","comments_url":"https://api.github.com/repos/jeverling/pip/comments{/number}","issue_comment_url":"https://api.github.com/repos/jeverling/pip/issues/comments/{number}","contents_url":"https://api.github.com/repos/jeverling/pip/contents/{+path}","compare_url":"https://api.github.com/repos/jeverling/pip/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jeverling/pip/merges","archive_url":"https://api.github.com/repos/jeverling/pip/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jeverling/pip/downloads","issues_url":"https://api.github.com/repos/jeverling/pip/issues{/number}","pulls_url":"https://api.github.com/repos/jeverling/pip/pulls{/number}","milestones_url":"https://api.github.com/repos/jeverling/pip/milestones{/number}","notifications_url":"https://api.github.com/repos/jeverling/pip/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jeverling/pip/labels{/name}","releases_url":"https://api.github.com/repos/jeverling/pip/releases{/id}","created_at":"2014-09-14T22:33:31Z","updated_at":"2014-09-14T22:48:16Z","pushed_at":"2014-09-14T22:48:14Z","git_url":"git://github.com/jeverling/pip.git","ssh_url":"git@github.com:jeverling/pip.git","clone_url":"https://github.com/jeverling/pip.git","svn_url":"https://github.com/jeverling/pip","homepage":"https://pip.pypa.io/","size":35044,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"pypa:develop","ref":"develop","sha":"ea3252e664a6e322777e097836c0ccc033ca0102","user":{"login":"pypa","id":647025,"avatar_url":"https://avatars.githubusercontent.com/u/647025?v=2","gravatar_id":"097e00640790ef99fa4df9e0c29cc6d8","url":"https://api.github.com/users/pypa","html_url":"https://github.com/pypa","followers_url":"https://api.github.com/users/pypa/followers","following_url":"https://api.github.com/users/pypa/following{/other_user}","gists_url":"https://api.github.com/users/pypa/gists{/gist_id}","starred_url":"https://api.github.com/users/pypa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pypa/subscriptions","organizations_url":"https://api.github.com/users/pypa/orgs","repos_url":"https://api.github.com/users/pypa/repos","events_url":"https://api.github.com/users/pypa/events{/privacy}","received_events_url":"https://api.github.com/users/pypa/received_events","type":"Organization","site_admin":false},"repo":{"id":1446467,"name":"pip","full_name":"pypa/pip","owner":{"login":"pypa","id":647025,"avatar_url":"https://avatars.githubusercontent.com/u/647025?v=2","gravatar_id":"097e00640790ef99fa4df9e0c29cc6d8","url":"https://api.github.com/users/pypa","html_url":"https://github.com/pypa","followers_url":"https://api.github.com/users/pypa/followers","following_url":"https://api.github.com/users/pypa/following{/other_user}","gists_url":"https://api.github.com/users/pypa/gists{/gist_id}","starred_url":"https://api.github.com/users/pypa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pypa/subscriptions","organizations_url":"https://api.github.com/users/pypa/orgs","repos_url":"https://api.github.com/users/pypa/repos","events_url":"https://api.github.com/users/pypa/events{/privacy}","received_events_url":"https://api.github.com/users/pypa/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pypa/pip","description":"The PyPA recommended tool for installing Python packages","fork":false,"url":"https://api.github.com/repos/pypa/pip","forks_url":"https://api.github.com/repos/pypa/pip/forks","keys_url":"https://api.github.com/repos/pypa/pip/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pypa/pip/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pypa/pip/teams","hooks_url":"https://api.github.com/repos/pypa/pip/hooks","issue_events_url":"https://api.github.com/repos/pypa/pip/issues/events{/number}","events_url":"https://api.github.com/repos/pypa/pip/events","assignees_url":"https://api.github.com/repos/pypa/pip/assignees{/user}","branches_url":"https://api.github.com/repos/pypa/pip/branches{/branch}","tags_url":"https://api.github.com/repos/pypa/pip/tags","blobs_url":"https://api.github.com/repos/pypa/pip/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pypa/pip/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pypa/pip/git/refs{/sha}","trees_url":"https://api.github.com/repos/pypa/pip/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pypa/pip/statuses/{sha}","languages_url":"https://api.github.com/repos/pypa/pip/languages","stargazers_url":"https://api.github.com/repos/pypa/pip/stargazers","contributors_url":"https://api.github.com/repos/pypa/pip/contributors","subscribers_url":"https://api.github.com/repos/pypa/pip/subscribers","subscription_url":"https://api.github.com/repos/pypa/pip/subscription","commits_url":"https://api.github.com/repos/pypa/pip/commits{/sha}","git_commits_url":"https://api.github.com/repos/pypa/pip/git/commits{/sha}","comments_url":"https://api.github.com/repos/pypa/pip/comments{/number}","issue_comment_url":"https://api.github.com/repos/pypa/pip/issues/comments/{number}","contents_url":"https://api.github.com/repos/pypa/pip/contents/{+path}","compare_url":"https://api.github.com/repos/pypa/pip/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pypa/pip/merges","archive_url":"https://api.github.com/repos/pypa/pip/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pypa/pip/downloads","issues_url":"https://api.github.com/repos/pypa/pip/issues{/number}","pulls_url":"https://api.github.com/repos/pypa/pip/pulls{/number}","milestones_url":"https://api.github.com/repos/pypa/pip/milestones{/number}","notifications_url":"https://api.github.com/repos/pypa/pip/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pypa/pip/labels{/name}","releases_url":"https://api.github.com/repos/pypa/pip/releases{/id}","created_at":"2011-03-06T14:30:46Z","updated_at":"2014-09-14T17:51:37Z","pushed_at":"2014-09-12T00:03:03Z","git_url":"git://github.com/pypa/pip.git","ssh_url":"git@github.com:pypa/pip.git","clone_url":"https://github.com/pypa/pip.git","svn_url":"https://github.com/pypa/pip","homepage":"https://pip.pypa.io/","size":35044,"stargazers_count":1702,"watchers_count":1702,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":654,"mirror_url":null,"open_issues_count":443,"forks":654,"open_issues":443,"watchers":1702,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/pypa/pip/pulls/2035"},"html":{"href":"https://github.com/pypa/pip/pull/2035"},"issue":{"href":"https://api.github.com/repos/pypa/pip/issues/2035"},"comments":{"href":"https://api.github.com/repos/pypa/pip/issues/2035/comments"},"review_comments":{"href":"https://api.github.com/repos/pypa/pip/pulls/2035/comments"},"review_comment":{"href":"https://api.github.com/repos/pypa/pip/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/pypa/pip/pulls/2035/commits"},"statuses":{"href":"https://api.github.com/repos/pypa/pip/statuses/083d1878583ae35edaf587a79984e003c2e25c22"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":25,"deletions":2,"changed_files":3}}