From 9ea6330ebc3a6445e76d2b556eea9a7c2cfbb65e Mon Sep 17 00:00:00 2001 From: Christopher Angelo Phillips <32073428+spiffcs@users.noreply.github.com> Date: Thu, 14 Oct 2021 12:32:06 -0400 Subject: [PATCH] update split in py package_cataloger to cap at 2 (#549) Signed-off-by: Christopher Angelo Phillips --- syft/pkg/cataloger/python/package_cataloger_test.go | 2 ++ syft/pkg/cataloger/python/parse_wheel_egg_record.go | 7 ++++--- syft/pkg/cataloger/python/parse_wheel_egg_record_test.go | 1 + syft/pkg/cataloger/python/test-fixtures/dist-info/RECORD | 3 ++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/syft/pkg/cataloger/python/package_cataloger_test.go b/syft/pkg/cataloger/python/package_cataloger_test.go index 0c4d99f96..4aced6a4d 100644 --- a/syft/pkg/cataloger/python/package_cataloger_test.go +++ b/syft/pkg/cataloger/python/package_cataloger_test.go @@ -78,6 +78,8 @@ func TestPythonPackageWheelCataloger(t *testing.T) { {Path: "Pygments-2.6.1.dist-info/RECORD"}, {Path: "pygments/__pycache__/__init__.cpython-38.pyc"}, {Path: "pygments/util.py", Digest: &pkg.PythonFileDigest{"sha256", "586xXHiJGGZxqk5PMBu3vBhE68DLuAe5MBARWrSPGxA"}, Size: "10778"}, + + {Path: "pygments/x_util.py", Digest: &pkg.PythonFileDigest{"sha256", "qpzzsOW31KT955agi-7NS--90I0iNiJCyLJQnRCHgKI="}, Size: "10778"}, }, TopLevelPackages: []string{"pygments", "something_else"}, }, diff --git a/syft/pkg/cataloger/python/parse_wheel_egg_record.go b/syft/pkg/cataloger/python/parse_wheel_egg_record.go index 4f3e828ac..764b6bf08 100644 --- a/syft/pkg/cataloger/python/parse_wheel_egg_record.go +++ b/syft/pkg/cataloger/python/parse_wheel_egg_record.go @@ -6,6 +6,7 @@ import ( "io" "strings" + "github.com/anchore/syft/internal/log" "github.com/anchore/syft/syft/pkg" ) @@ -38,10 +39,10 @@ func parseWheelOrEggRecord(reader io.Reader) ([]pkg.PythonFileRecord, error) { if item == "" { continue } - fields := strings.Split(item, "=") - + fields := strings.SplitN(item, "=", 2) if len(fields) != 2 { - return nil, fmt.Errorf("unexpected python record digest: %q", item) + log.Warnf("unexpected python record digest: %q", item) + continue } record.Digest = &pkg.PythonFileDigest{ diff --git a/syft/pkg/cataloger/python/parse_wheel_egg_record_test.go b/syft/pkg/cataloger/python/parse_wheel_egg_record_test.go index c0cf578b5..7b178d9f0 100644 --- a/syft/pkg/cataloger/python/parse_wheel_egg_record_test.go +++ b/syft/pkg/cataloger/python/parse_wheel_egg_record_test.go @@ -32,6 +32,7 @@ func TestParseWheelEggRecord(t *testing.T) { {Path: "Pygments-2.6.1.dist-info/RECORD"}, {Path: "pygments/__pycache__/__init__.cpython-38.pyc"}, {Path: "pygments/util.py", Digest: &pkg.PythonFileDigest{"sha256", "586xXHiJGGZxqk5PMBu3vBhE68DLuAe5MBARWrSPGxA"}, Size: "10778"}, + {Path: "pygments/x_util.py", Digest: &pkg.PythonFileDigest{"sha256", "qpzzsOW31KT955agi-7NS--90I0iNiJCyLJQnRCHgKI="}, Size: "10778"}, }, }, } diff --git a/syft/pkg/cataloger/python/test-fixtures/dist-info/RECORD b/syft/pkg/cataloger/python/test-fixtures/dist-info/RECORD index af233f390..b7beac37e 100644 --- a/syft/pkg/cataloger/python/test-fixtures/dist-info/RECORD +++ b/syft/pkg/cataloger/python/test-fixtures/dist-info/RECORD @@ -2,4 +2,5 @@ Pygments-2.6.1.dist-info/AUTHORS,sha256=PVpa2_Oku6BGuiUvutvuPnWGpzxqFy2I8-NIrqCvqUY,8449 Pygments-2.6.1.dist-info/RECORD,, pygments/__pycache__/__init__.cpython-38.pyc,, -pygments/util.py,sha256=586xXHiJGGZxqk5PMBu3vBhE68DLuAe5MBARWrSPGxA,10778 \ No newline at end of file +pygments/util.py,sha256=586xXHiJGGZxqk5PMBu3vBhE68DLuAe5MBARWrSPGxA,10778 +pygments/x_util.py,sha256=qpzzsOW31KT955agi-7NS--90I0iNiJCyLJQnRCHgKI=,10778