Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: guard for locations < 1 in alpmdb parse #1366

Merged
merged 1 commit into from
Nov 28, 2022

Conversation

spiffcs
Copy link
Contributor

@spiffcs spiffcs commented Nov 28, 2022

Summary

Attempts to address #1094 - syft would continue to try and resolve file contents when no locations were found for FilesByPath causing a panic when trying to access position 0 of an empty slice.

Error message just before panic on windows:

DEBUG directory resolver unable to evaluate symlink for 
path="C:\msys64\var\lib\pacman\local\libp11-kit-0.24.1-4\mtree" : 
CreateFile C:\C:: The filename, directory name, or volume label syntax is incorrect.

This fix removes the possibility of panic by checking the locations found before FilesBypath is called.

It does not address the fact that C:\msys64\var\lib\pacman\local\libp11-kit-0.24.1-4\mtree is a valid path that should be able to be parsed.

Also note: this error will eventually surface to:

packages, relationships, err := c.Catalog(resolver)
if err != nil {
errs = multierror.Append(errs, err)
continue
}

This is an error condition for syft and will result in the program status code 1.

A follow-up PR will be made that can address the correct parsing of the above mtree file on windows.

Signed-off-by: Christopher Phillips [email protected]

Signed-off-by: Christopher Phillips <[email protected]>
@github-actions
Copy link

Benchmark Test Results

Benchmark results from the latest changes vs base branch
name                                                       old time/op    new time/op    delta
ImagePackageCatalogers/alpmdb-cataloger-2                    11.5ms ± 1%    11.2ms ± 1%  -2.34%  (p=0.016 n=4+5)
ImagePackageCatalogers/ruby-gemspec-cataloger-2              1.25ms ± 0%    1.28ms ± 1%  +2.01%  (p=0.016 n=5+4)
ImagePackageCatalogers/python-package-cataloger-2            3.25ms ± 0%    3.27ms ± 1%  +0.80%  (p=0.016 n=5+5)
ImagePackageCatalogers/php-composer-installed-cataloger-2    1.03ms ± 0%    1.07ms ± 2%  +3.88%  (p=0.008 n=5+5)
ImagePackageCatalogers/javascript-package-cataloger-2         712µs ± 0%     744µs ± 1%  +4.49%  (p=0.008 n=5+5)
ImagePackageCatalogers/node-binary-cataloger-2               6.71µs ± 1%    6.32µs ± 2%  -5.78%  (p=0.008 n=5+5)
ImagePackageCatalogers/dpkgdb-cataloger-2                     816µs ± 1%     846µs ± 2%  +3.77%  (p=0.008 n=5+5)
ImagePackageCatalogers/rpm-db-cataloger-2                    1.20ms ± 1%    1.27ms ± 2%  +5.51%  (p=0.016 n=4+5)
ImagePackageCatalogers/java-cataloger-2                      13.9ms ± 1%    14.1ms ± 1%  +1.99%  (p=0.016 n=5+5)
ImagePackageCatalogers/apkdb-cataloger-2                     1.24ms ± 2%    1.26ms ± 3%    ~     (p=0.421 n=5+5)
ImagePackageCatalogers/go-module-binary-cataloger-2          6.76µs ± 1%    6.46µs ± 1%  -4.50%  (p=0.008 n=5+5)
ImagePackageCatalogers/dotnet-deps-cataloger-2               1.32ms ± 1%    1.34ms ± 2%    ~     (p=0.095 n=5+5)
ImagePackageCatalogers/portage-cataloger-2                    670µs ± 1%     704µs ± 1%  +5.11%  (p=0.008 n=5+5)
ImagePackageCatalogers/sbom-cataloger-2                      4.21ms ± 0%    4.39ms ± 1%  +4.21%  (p=0.016 n=4+5)

name                                                       old alloc/op   new alloc/op   delta
ImagePackageCatalogers/alpmdb-cataloger-2                    5.26MB ± 0%    5.26MB ± 0%    ~     (p=0.690 n=5+5)
ImagePackageCatalogers/ruby-gemspec-cataloger-2               205kB ± 0%     205kB ± 0%    ~     (p=0.095 n=5+5)
ImagePackageCatalogers/python-package-cataloger-2             963kB ± 0%     962kB ± 0%  -0.14%  (p=0.008 n=5+5)
ImagePackageCatalogers/php-composer-installed-cataloger-2     218kB ± 0%     217kB ± 0%  -0.12%  (p=0.008 n=5+5)
ImagePackageCatalogers/javascript-package-cataloger-2         159kB ± 0%     159kB ± 0%    ~     (p=0.310 n=5+5)
ImagePackageCatalogers/node-binary-cataloger-2               1.12kB ± 0%    1.12kB ± 0%    ~     (all equal)
ImagePackageCatalogers/dpkgdb-cataloger-2                     199kB ± 0%     199kB ± 0%  -0.13%  (p=0.032 n=5+5)
ImagePackageCatalogers/rpm-db-cataloger-2                     303kB ± 0%     303kB ± 0%    ~     (p=1.000 n=5+5)
ImagePackageCatalogers/java-cataloger-2                      3.49MB ± 0%    3.49MB ± 0%    ~     (p=0.548 n=5+5)
ImagePackageCatalogers/apkdb-cataloger-2                     1.26MB ± 0%    1.26MB ± 0%  -0.08%  (p=0.008 n=5+5)
ImagePackageCatalogers/go-module-binary-cataloger-2          1.12kB ± 0%    1.12kB ± 0%    ~     (all equal)
ImagePackageCatalogers/dotnet-deps-cataloger-2                374kB ± 0%     374kB ± 0%    ~     (p=0.389 n=5+5)
ImagePackageCatalogers/portage-cataloger-2                    139kB ± 0%     138kB ± 0%    ~     (p=0.056 n=5+5)
ImagePackageCatalogers/sbom-cataloger-2                       722kB ± 0%     721kB ± 0%  -0.04%  (p=0.008 n=5+5)

name                                                       old allocs/op  new allocs/op  delta
ImagePackageCatalogers/alpmdb-cataloger-2                     85.7k ± 0%     85.7k ± 0%    ~     (p=0.484 n=5+5)
ImagePackageCatalogers/ruby-gemspec-cataloger-2               4.24k ± 0%     4.24k ± 0%    ~     (all equal)
ImagePackageCatalogers/python-package-cataloger-2             16.5k ± 0%     16.5k ± 0%    ~     (p=1.000 n=5+5)
ImagePackageCatalogers/php-composer-installed-cataloger-2     5.50k ± 0%     5.50k ± 0%    ~     (p=1.000 n=5+5)
ImagePackageCatalogers/javascript-package-cataloger-2         3.33k ± 0%     3.33k ± 0%    ~     (all equal)
ImagePackageCatalogers/node-binary-cataloger-2                 38.0 ± 0%      38.0 ± 0%    ~     (all equal)
ImagePackageCatalogers/dpkgdb-cataloger-2                     4.46k ± 0%     4.46k ± 0%    ~     (all equal)
ImagePackageCatalogers/rpm-db-cataloger-2                     8.11k ± 0%     8.11k ± 0%    ~     (all equal)
ImagePackageCatalogers/java-cataloger-2                       57.5k ± 0%     57.5k ± 0%    ~     (p=1.000 n=5+5)
ImagePackageCatalogers/apkdb-cataloger-2                      5.45k ± 0%     5.45k ± 0%    ~     (all equal)
ImagePackageCatalogers/go-module-binary-cataloger-2            38.0 ± 0%      38.0 ± 0%    ~     (all equal)
ImagePackageCatalogers/dotnet-deps-cataloger-2                7.12k ± 0%     7.12k ± 0%    ~     (all equal)
ImagePackageCatalogers/portage-cataloger-2                    3.58k ± 0%     3.58k ± 0%    ~     (all equal)
ImagePackageCatalogers/sbom-cataloger-2                       24.4k ± 0%     24.4k ± 0%    ~     (all equal)

@spiffcs spiffcs marked this pull request as ready for review November 28, 2022 15:31
@spiffcs spiffcs enabled auto-merge (squash) November 28, 2022 15:40
@spiffcs spiffcs merged commit 0cbd0cc into main Nov 28, 2022
@spiffcs spiffcs deleted the 1094-panic-alpm-file-panic branch November 28, 2022 15:43
GijsCalis pushed a commit to GijsCalis/syft that referenced this pull request Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants