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

Command make add-snippet can fail in some cases #3249

Closed
krysgor opened this issue Sep 19, 2024 · 1 comment
Closed

Command make add-snippet can fail in some cases #3249

krysgor opened this issue Sep 19, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@krysgor
Copy link
Contributor

krysgor commented Sep 19, 2024

Adding a new binary catalog using the make add-snippet command fails in some cases.

The reason for this problem is here: capture-snippet.sh:119. In cases where the input variable SELECTED_RESULT contains leading blanks, the OFFSET calculation will lead to an empty result.

Steps to reproduce the issue:

cd syft/pkg/cataloger/binary/test-fixtures
make
make add-snippet

Then select: classifiers/bin/curl/8.9.1/linux-amd64/curl and choose one of the found maches:

1) 167585 curl/8.9.1
2) 174376 curl 8.9.1 (x86_64-pc-linux-musl) %s

Then the process fails with:

Pattern not found.
Error: command execution failed: exit status 1
Usage:
  manager add-snippet [flags]

Flags:
  -h, --help                help for add-snippet
      --length int          the length of the snippet to capture (default 100)
      --prefix-length int   number of bytes before the search hit to capture (default 20)
      --search-for string   the pattern to search for in the binary (defaults to the version)

command execution failed: exit status 1
exit status 1
make: *** [Makefile:23: add-snippet] Error 1

What you expected to happen:
The process contiues wihout error, like this:

1) 167585 curl/8.9.1
2) 174376 curl 8.9.1 (x86_64-pc-linux-musl) %s

Please select a match: 2

0002a914: 616c 206f 7220 222d 2d68 656c 7020 616c  al or "--help al
0002a924: 6c22 2e00 6375 726c 2038 2e39 2e31 2028  l"..curl 8.9.1 (
0002a934: 7838 365f 3634 2d70 632d 6c69 6e75 782d  x86_64-pc-linux-
0002a944: 6d75 736c 2920 2573 0a00 0000 5741 524e  musl) %s....WARN
0002a954: 494e 473a 2063 7572 6c20 616e 6420 6c69  ING: curl and li
0002a964: 6263 7572 6c20 7665 7273 696f 6e73 2064  bcurl versions d
0002a974: 6f20 6e6f 7420 6d61 7463 682e 2046 756e  o not match. Fun
0002a984: 6374 696f 6e61 6c69                      ctionali

Does this snippet capture what you need? (Y/n/q) y
wrote snippet to "classifiers/snippets/curl/8.9.1/linux-amd64/curl"

Environment:

  • syft main branch latest
@krysgor krysgor added the bug Something isn't working label Sep 19, 2024
krysgor pushed a commit to krysgor/syft that referenced this issue Sep 19, 2024
)

Signed-off-by: Gorny Krystian <krystian.gorny@wipotec.com>
wagoodman pushed a commit that referenced this issue Sep 19, 2024
…3250)

Signed-off-by: Gorny Krystian <krystian.gorny@wipotec.com>
Co-authored-by: Gorny Krystian <krystian.gorny@wipotec.com>
@krysgor
Copy link
Contributor Author

krysgor commented Sep 19, 2024

Thanks for fast merge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

No branches or pull requests

1 participant