-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(python): skip dev group's deps for poetry (#8106)
Signed-off-by: nikpivkin <[email protected]>
- Loading branch information
Showing
11 changed files
with
650 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,9 @@ package poetry | |
import ftypes "github.com/aquasecurity/trivy/pkg/fanal/types" | ||
|
||
var ( | ||
// docker run --name pipenv --rm -it python@sha256:e1141f10176d74d1a0e87a7c0a0a5a98dd98ec5ac12ce867768f40c6feae2fd9 sh | ||
// docker run --name poetry --rm -it python@sha256:e1141f10176d74d1a0e87a7c0a0a5a98dd98ec5ac12ce867768f40c6feae2fd9 sh | ||
// apk add curl | ||
// curl -sSL https://install.python-poetry.org | python3 - | ||
// curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.1.7 python3 - | ||
// export PATH=/root/.local/bin:$PATH | ||
// poetry new normal && cd normal | ||
// poetry add [email protected] | ||
|
@@ -14,9 +14,9 @@ var ( | |
{ID: "[email protected]", Name: "pypi", Version: "2.1"}, | ||
} | ||
|
||
// docker run --name pipenv --rm -it python@sha256:e1141f10176d74d1a0e87a7c0a0a5a98dd98ec5ac12ce867768f40c6feae2fd9 sh | ||
// docker run --name poetry --rm -it python@sha256:e1141f10176d74d1a0e87a7c0a0a5a98dd98ec5ac12ce867768f40c6feae2fd9 sh | ||
// apk add curl | ||
// curl -sSL https://install.python-poetry.org | python3 - | ||
// curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.1.7 python3 - | ||
// export PATH=/root/.local/bin:$PATH | ||
// poetry new many && cd many | ||
// curl -o poetry.lock https://raw.githubusercontent.com/python-poetry/poetry/c8945eb110aeda611cc6721565d7ad0c657d453a/poetry.lock | ||
|
@@ -108,9 +108,9 @@ var ( | |
{ID: "[email protected]", DependsOn: []string{"[email protected]"}}, | ||
} | ||
|
||
// docker run --name pipenv --rm -it python@sha256:e1141f10176d74d1a0e87a7c0a0a5a98dd98ec5ac12ce867768f40c6feae2fd9 sh | ||
// docker run --name poetry --rm -it python@sha256:e1141f10176d74d1a0e87a7c0a0a5a98dd98ec5ac12ce867768f40c6feae2fd9 sh | ||
// apk add curl | ||
// curl -sSL https://install.python-poetry.org | python3 - | ||
// curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.1.7 python3 - | ||
// export PATH=/root/.local/bin:$PATH | ||
// poetry new web && cd web | ||
// poetry add [email protected] | ||
|
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,14 @@ | ||
package python | ||
|
||
import "strings" | ||
|
||
// NormalizePkgName normalizes the package name based on pep-0426 | ||
func NormalizePkgName(name string) string { | ||
// The package names don't use `_`, `.` or upper case, but dependency names can contain them. | ||
// We need to normalize those names. | ||
// cf. https://peps.python.org/pep-0426/#name | ||
name = strings.ToLower(name) // e.g. https://github.com/python-poetry/poetry/blob/c8945eb110aeda611cc6721565d7ad0c657d453a/poetry.lock#L819 | ||
name = strings.ReplaceAll(name, "_", "-") // e.g. https://github.com/python-poetry/poetry/blob/c8945eb110aeda611cc6721565d7ad0c657d453a/poetry.lock#L50 | ||
name = strings.ReplaceAll(name, ".", "-") // e.g. https://github.com/python-poetry/poetry/blob/c8945eb110aeda611cc6721565d7ad0c657d453a/poetry.lock#L816 | ||
return 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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package python_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/aquasecurity/trivy/pkg/dependency/parser/python" | ||
) | ||
|
||
func Test_NormalizePkgName(t *testing.T) { | ||
tests := []struct { | ||
pkgName string | ||
expected string | ||
}{ | ||
{ | ||
pkgName: "SecretStorage", | ||
expected: "secretstorage", | ||
}, | ||
{ | ||
pkgName: "pywin32-ctypes", | ||
expected: "pywin32-ctypes", | ||
}, | ||
{ | ||
pkgName: "jaraco.classes", | ||
expected: "jaraco-classes", | ||
}, | ||
{ | ||
pkgName: "green_gdk", | ||
expected: "green-gdk", | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.pkgName, func(t *testing.T) { | ||
assert.Equal(t, tt.expected, python.NormalizePkgName(tt.pkgName)) | ||
}) | ||
} | ||
} |
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
Oops, something went wrong.