-
Notifications
You must be signed in to change notification settings - Fork 497
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Handle editable pip installs (#2731)
* fix: Handle editable pip install Editable pip installs (-e) should be considered secure if the package is installed from a local source or a remote source (VCS install) but pinned by commit hash. To keep the behaviour we have for normal pip installs, we need to guarantee the package dependencies are pinned by hash too. For normal pip installs, we verify that by using --require-hashes flag. Unfortunately, --require-hashes flag is not compatible with editable installs, so we use --no-deps flag to verify the dependencies are not installed since we can't verify if they are pinned. Signed-off-by: Gabriela Gutierrez <[email protected]> * test: Editable pip install in GHA Signed-off-by: Gabriela Gutierrez <[email protected]> * test: Editable pip install in Dockerfile Signed-off-by: Gabriela Gutierrez <[email protected]> * test: Editable pip install in shell script Signed-off-by: Gabriela Gutierrez <[email protected]> * fix: Code complexity increase Signed-off-by: Gabriela Gutierrez <[email protected]> * fix: Simplify boolean return Signed-off-by: Gabriela Gutierrez <[email protected]> * docs: Add pip editable install references in comments Signed-off-by: Gabriela Gutierrez <[email protected]> * fix: Handle multiple packages in editable pip install Signed-off-by: Gabriela Gutierrez <[email protected]> * test: Multi editable pip install in GHA Signed-off-by: Gabriela Gutierrez <[email protected]> * test: Multi editable pip install in Dockerfile Signed-off-by: Gabriela Gutierrez <[email protected]> * test: Multi editable pip install in shell script Signed-off-by: Gabriela Gutierrez <[email protected]> --------- Signed-off-by: Gabriela Gutierrez <[email protected]> Co-authored-by: laurentsimon <[email protected]>
- Loading branch information
1 parent
110e352
commit 6ff94eb
Showing
7 changed files
with
322 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -261,7 +261,7 @@ func TestGithubWorkflowPkgManagerPinning(t *testing.T) { | |
{ | ||
name: "npm packages without verification", | ||
filename: "./testdata/.github/workflows/github-workflow-pkg-managers.yaml", | ||
warns: 36, | ||
warns: 46, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
|
@@ -557,6 +557,66 @@ func TestDockerfileInsecureDownloadsLineNumber(t *testing.T) { | |
endLine: 42, | ||
t: checker.DependencyUseTypePipCommand, | ||
}, | ||
{ | ||
snippet: "pip install --no-deps -e hg+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package", | ||
startLine: 46, | ||
endLine: 46, | ||
t: checker.DependencyUseTypePipCommand, | ||
}, | ||
{ | ||
snippet: "pip install --no-deps -e svn+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package", | ||
startLine: 47, | ||
endLine: 47, | ||
t: checker.DependencyUseTypePipCommand, | ||
}, | ||
{ | ||
snippet: "pip install --no-deps -e bzr+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package", | ||
startLine: 48, | ||
endLine: 48, | ||
t: checker.DependencyUseTypePipCommand, | ||
}, | ||
{ | ||
snippet: "pip install --no-deps -e git+https://github.com/username/repo.git", | ||
startLine: 49, | ||
endLine: 49, | ||
t: checker.DependencyUseTypePipCommand, | ||
}, | ||
{ | ||
snippet: "pip install --no-deps -e git+https://github.com/username/repo.git#egg=package", | ||
startLine: 50, | ||
endLine: 50, | ||
t: checker.DependencyUseTypePipCommand, | ||
}, | ||
{ | ||
snippet: "pip install --no-deps -e git+https://github.com/username/[email protected]", | ||
startLine: 51, | ||
endLine: 51, | ||
t: checker.DependencyUseTypePipCommand, | ||
}, | ||
{ | ||
snippet: "pip install --no-deps -e git+https://github.com/username/[email protected]#egg=package", | ||
startLine: 52, | ||
endLine: 52, | ||
t: checker.DependencyUseTypePipCommand, | ||
}, | ||
{ | ||
snippet: "pip install -e git+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package", | ||
startLine: 60, | ||
endLine: 60, | ||
t: checker.DependencyUseTypePipCommand, | ||
}, | ||
{ | ||
snippet: "pip install --no-deps -e . git+https://github.com/username/repo.git", | ||
startLine: 61, | ||
endLine: 61, | ||
t: checker.DependencyUseTypePipCommand, | ||
}, | ||
{ | ||
snippet: "python -m pip install --no-deps -e git+https://github.com/username/repo.git", | ||
startLine: 64, | ||
endLine: 64, | ||
t: checker.DependencyUseTypePipCommand, | ||
}, | ||
}, | ||
}, | ||
{ | ||
|
@@ -699,6 +759,66 @@ func TestShellscriptInsecureDownloadsLineNumber(t *testing.T) { | |
endLine: 31, | ||
t: checker.DependencyUseTypeChocoCommand, | ||
}, | ||
{ | ||
snippet: "pip install --no-deps -e hg+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package", | ||
startLine: 38, | ||
endLine: 38, | ||
t: checker.DependencyUseTypePipCommand, | ||
}, | ||
{ | ||
snippet: "pip install --no-deps -e svn+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package", | ||
startLine: 39, | ||
endLine: 39, | ||
t: checker.DependencyUseTypePipCommand, | ||
}, | ||
{ | ||
snippet: "pip install --no-deps -e bzr+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package", | ||
startLine: 40, | ||
endLine: 40, | ||
t: checker.DependencyUseTypePipCommand, | ||
}, | ||
{ | ||
snippet: "pip install --no-deps -e git+https://github.com/username/repo.git", | ||
startLine: 41, | ||
endLine: 41, | ||
t: checker.DependencyUseTypePipCommand, | ||
}, | ||
{ | ||
snippet: "pip install --no-deps -e git+https://github.com/username/repo.git#egg=package", | ||
startLine: 42, | ||
endLine: 42, | ||
t: checker.DependencyUseTypePipCommand, | ||
}, | ||
{ | ||
snippet: "pip install --no-deps -e git+https://github.com/username/[email protected]", | ||
startLine: 43, | ||
endLine: 43, | ||
t: checker.DependencyUseTypePipCommand, | ||
}, | ||
{ | ||
snippet: "pip install --no-deps -e git+https://github.com/username/[email protected]#egg=package", | ||
startLine: 44, | ||
endLine: 44, | ||
t: checker.DependencyUseTypePipCommand, | ||
}, | ||
{ | ||
snippet: "pip install -e git+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package", | ||
startLine: 52, | ||
endLine: 52, | ||
t: checker.DependencyUseTypePipCommand, | ||
}, | ||
{ | ||
snippet: "pip install --no-deps -e . git+https://github.com/username/repo.git", | ||
startLine: 53, | ||
endLine: 53, | ||
t: checker.DependencyUseTypePipCommand, | ||
}, | ||
{ | ||
snippet: "python -m pip install --no-deps -e git+https://github.com/username/repo.git", | ||
startLine: 56, | ||
endLine: 56, | ||
t: checker.DependencyUseTypePipCommand, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
@@ -851,7 +971,7 @@ func TestDockerfileScriptDownload(t *testing.T) { | |
{ | ||
name: "pkg managers", | ||
filename: "./testdata/Dockerfile-pkg-managers", | ||
warns: 47, | ||
warns: 57, | ||
}, | ||
{ | ||
name: "download with some python", | ||
|
@@ -969,7 +1089,7 @@ func TestShellScriptDownload(t *testing.T) { | |
{ | ||
name: "pkg managers", | ||
filename: "./testdata/script-pkg-managers", | ||
warns: 43, | ||
warns: 53, | ||
}, | ||
{ | ||
name: "invalid shell script", | ||
|
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 |
---|---|---|
|
@@ -90,6 +90,44 @@ jobs: | |
run: pip3 install somepkg==1.2.3 | ||
- name: | ||
run: /bin/pip3 install -X -H somepkg | ||
- name: | ||
run: pip install --no-deps --editable . | ||
- name: | ||
run: pip install --no-deps -e . | ||
- name: | ||
run: pip install --no-deps -e hg+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
- name: | ||
run: pip install --no-deps -e svn+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
- name: | ||
run: pip install --no-deps -e bzr+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
- name: | ||
run: pip install --no-deps -e git+https://github.com/username/repo.git | ||
- name: | ||
run: pip install --no-deps -e git+https://github.com/username/repo.git#egg=package | ||
- name: | ||
run: pip install --no-deps -e git+https://github.com/username/[email protected] | ||
- name: | ||
run: pip install --no-deps -e git+https://github.com/username/[email protected]#egg=package | ||
- name: | ||
run: pip install --no-deps -e git+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567 | ||
- name: | ||
run: pip install --no-deps -e git+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
- name: | ||
run: pip install --no-deps -e git+https://github.com/username/repo@0123456789abcdef0123456789abcdef01234567#egg=package | ||
- name: | ||
run: pip install --no-deps -e git+http://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
- name: | ||
run: pip install --no-deps -e git+ssh://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
- name: | ||
run: pip install --no-deps -e git+git://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
- name: | ||
run: pip install --no-deps -e git://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
- name: | ||
run: pip install -e git+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
- name: | ||
run: pip install --no-deps -e . git+https://github.com/username/repo.git | ||
- name: | ||
run: pip install --no-deps -e . git+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
- name: | ||
run: python -m notpip -X bla | ||
- name: | ||
|
@@ -108,6 +146,10 @@ jobs: | |
run: python -m pip install 'some-pkg==1.2.3' | ||
- name: | ||
run: python -m pip install 'some-pkg>1.2.3' | ||
- name: | ||
run: python -m pip install --no-deps -e git+https://github.com/username/repo.git | ||
- name: | ||
run: python -m pip install --no-deps -e git+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
- name: | ||
run: pip3 install -r bla-requirements.txt --require-hashes && pip3 install --require-hashes -r bla-requirements.txt | ||
- name: | ||
|
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 |
---|---|---|
|
@@ -39,4 +39,27 @@ RUN echo hello && \ | |
#RUN curl -s ifconfig.co/json | grep "China" > /dev/null && \ | ||
# pip install -r requirements.txt -i https://pypi.doubanio.com/simple --trusted-host pypi.doubanio.com || \ | ||
RUN bla && \ | ||
pip install -r requirements.txt | ||
pip install -r requirements.txt | ||
|
||
RUN pip install --no-deps --editable . | ||
RUN pip install --no-deps -e . | ||
RUN pip install --no-deps -e hg+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
RUN pip install --no-deps -e svn+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
RUN pip install --no-deps -e bzr+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
RUN pip install --no-deps -e git+https://github.com/username/repo.git | ||
RUN pip install --no-deps -e git+https://github.com/username/repo.git#egg=package | ||
RUN pip install --no-deps -e git+https://github.com/username/[email protected] | ||
RUN pip install --no-deps -e git+https://github.com/username/[email protected]#egg=package | ||
RUN pip install --no-deps -e git+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567 | ||
RUN pip install --no-deps -e git+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
RUN pip install --no-deps -e git+https://github.com/username/repo@0123456789abcdef0123456789abcdef01234567#egg=package | ||
RUN pip install --no-deps -e git+http://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
RUN pip install --no-deps -e git+ssh://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
RUN pip install --no-deps -e git+git://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
RUN pip install --no-deps -e git://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
RUN pip install -e git+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
RUN pip install --no-deps -e . git+https://github.com/username/repo.git | ||
RUN pip install --no-deps -e . git+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
|
||
RUN python -m pip install --no-deps -e git+https://github.com/username/repo.git | ||
RUN python -m pip install --no-deps -e git+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package |
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 |
---|---|---|
|
@@ -61,6 +61,26 @@ RUN pip install somepkg | |
RUN pip3 install somepkg==1.2.3 | ||
RUN /bin/pip3 install -X -H somepkg | ||
|
||
RUN pip install --no-deps --editable . | ||
RUN pip install --no-deps -e . | ||
RUN pip install --no-deps -e hg+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
RUN pip install --no-deps -e svn+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
RUN pip install --no-deps -e bzr+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
RUN pip install --no-deps -e git+https://github.com/username/repo.git | ||
RUN pip install --no-deps -e git+https://github.com/username/repo.git#egg=package | ||
RUN pip install --no-deps -e git+https://github.com/username/[email protected] | ||
RUN pip install --no-deps -e git+https://github.com/username/[email protected]#egg=package | ||
RUN pip install --no-deps -e git+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567 | ||
RUN pip install --no-deps -e git+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
RUN pip install --no-deps -e git+https://github.com/username/repo@0123456789abcdef0123456789abcdef01234567#egg=package | ||
RUN pip install --no-deps -e git+http://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
RUN pip install --no-deps -e git+ssh://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
RUN pip install --no-deps -e git+git://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
RUN pip install --no-deps -e git://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
RUN pip install -e git+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
RUN pip install --no-deps -e . git+https://github.com/username/repo.git | ||
RUN pip install --no-deps -e . git+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
|
||
RUN python -m notpip -X bla | ||
|
||
RUN python2.7 -m pip install -X -H somepkg \ | ||
|
@@ -84,6 +104,9 @@ RUN python -m pip install -r file | |
RUN python -m pip install 'some-pkg==1.2.3' | ||
RUN python -m pip install 'some-pkg>1.2.3' | ||
|
||
RUN python -m pip install --no-deps -e git+https://github.com/username/repo.git | ||
RUN python -m pip install --no-deps -e git+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567#egg=package | ||
|
||
RUN npm install typescript | ||
RUN npm install -g typescript | ||
RUN npm i typescript | ||
|
Oops, something went wrong.