diff --git a/syft/cataloger/python/parse_wheel_egg_metadata.go b/syft/cataloger/python/parse_wheel_egg_metadata.go index 00abd4909..4c6a880f1 100644 --- a/syft/cataloger/python/parse_wheel_egg_metadata.go +++ b/syft/cataloger/python/parse_wheel_egg_metadata.go @@ -8,6 +8,7 @@ import ( "strings" "github.com/anchore/syft/internal/file" + "github.com/anchore/syft/internal/log" "github.com/mitchellh/mapstructure" @@ -56,7 +57,7 @@ func parseWheelOrEggMetadata(path string, reader io.Reader) (pkg.PythonPackageMe fields[key] = val } else { - return pkg.PythonPackageMetadata{}, fmt.Errorf("cannot parse field from line: '%s'", line) + log.Warnf("cannot parse field from path: %q from line: %q", path, line) } } } diff --git a/syft/cataloger/python/parse_wheel_egg_metadata_test.go b/syft/cataloger/python/parse_wheel_egg_metadata_test.go index ac6465198..737da67f9 100644 --- a/syft/cataloger/python/parse_wheel_egg_metadata_test.go +++ b/syft/cataloger/python/parse_wheel_egg_metadata_test.go @@ -117,3 +117,37 @@ func TestDetermineSitePackagesRootPath(t *testing.T) { }) } } + +func TestParseWheelEggMetadataInvalid(t *testing.T) { + tests := []struct { + Fixture string + ExpectedMetadata pkg.PythonPackageMetadata + }{ + { + Fixture: "test-fixtures/egg-info/PKG-INFO-INVALID", + ExpectedMetadata: pkg.PythonPackageMetadata{ + Name: "mxnet", + Version: "1.8.0", + SitePackagesRootPath: "test-fixtures", + }, + }, + } + + for _, test := range tests { + t.Run(test.Fixture, func(t *testing.T) { + fixture, err := os.Open(test.Fixture) + if err != nil { + t.Fatalf("failed to open fixture: %+v", err) + } + + actual, err := parseWheelOrEggMetadata(test.Fixture, fixture) + if err != nil { + t.Fatalf("failed to parse: %+v", err) + } + + for _, d := range deep.Equal(actual, test.ExpectedMetadata) { + t.Errorf("diff: %+v", d) + } + }) + } +} diff --git a/syft/cataloger/python/test-fixtures/egg-info/PKG-INFO-INVALID b/syft/cataloger/python/test-fixtures/egg-info/PKG-INFO-INVALID new file mode 100644 index 000000000..173d8c512 --- /dev/null +++ b/syft/cataloger/python/test-fixtures/egg-info/PKG-INFO-INVALID @@ -0,0 +1,69 @@ +Metadata-Version: 1.1 +Name: mxnet +Version: 1.8.0 +Summary: + + + + + + + + + + + + + + + + +MXNet Python Package +==================== +This directory and nested files contain MXNet Python package and language binding. + +## Installation +To install MXNet Python package, visit MXNet [Install Instruction](https://mxnet.apache.org/get_started) + + +## Running the unit tests + +For running unit tests, you will need the [nose PyPi package](https://pypi.python.org/pypi/nose). To install: +```bash +pip install --upgrade nose +``` + +Once ```nose``` is installed, run the following from MXNet root directory (please make sure the installation path of ```nosetests``` is included in your ```$PATH``` environment variable): +``` +nosetests tests/python/unittest +nosetests tests/python/train + +``` + +Home-page: https://github.com/apache/incubator-mxnet +Author: UNKNOWN +Author-email: UNKNOWN +License: UNKNOWN +Description: UNKNOWN +Platform: UNKNOWN +Classifier: Development Status :: 5 - Production/Stable +Classifier: Intended Audience :: Developers +Classifier: Intended Audience :: Education +Classifier: Intended Audience :: Science/Research +Classifier: License :: OSI Approved :: Apache Software License +Classifier: Programming Language :: C++ +Classifier: Programming Language :: Cython +Classifier: Programming Language :: Other +Classifier: Programming Language :: Perl +Classifier: Programming Language :: Python +Classifier: Programming Language :: Python :: 2.7 +Classifier: Programming Language :: Python :: 3.4 +Classifier: Programming Language :: Python :: 3.5 +Classifier: Programming Language :: Python :: 3.6 +Classifier: Programming Language :: Python :: Implementation :: CPython +Classifier: Topic :: Scientific/Engineering +Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence +Classifier: Topic :: Scientific/Engineering :: Mathematics +Classifier: Topic :: Software Development +Classifier: Topic :: Software Development :: Libraries +Classifier: Topic :: Software Development :: Libraries :: Python Modules