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

feat: helper_script: try without lib prefix. update name detect #2962

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bcieszko
Copy link
Contributor

@bcieszko
Copy link
Contributor Author

bcieszko commented May 1, 2023

updated commit - cleanup black/isort/flake8

@bcieszko bcieszko changed the title feat: helper_script: try without lib prefix. Different flow in name detection feat: helper_script: try without lib prefix. update name detect May 18, 2023
* fixes intel#2918

Signed-off-by: Przemyslaw Romaniak <[email protected]>
Signed-off-by: Bartlomiej Cieszkowski <[email protected]>
@bcieszko
Copy link
Contributor Author

updated branch
@terriko

@terriko terriko changed the title feat: helper_script: try without lib prefix. update name detect feat: helper_script: try without lib prefix. update name detect May 22, 2023
@bcieszko
Copy link
Contributor Author

@terriko can we merge this?

Copy link
Contributor

@terriko terriko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're getting a bunch of test fails:

=========================== short test summary info ============================
FAILED test/test_helper_script.py::TestHelperScript::test_parse_filename[libsndfile-1.0.25-12.el7.x86_64.rpm-libsndfile-1.0.25] - AssertionError: assert ('libsndfile', '1.0.25') == None
 +  where None = <bound method HelperScript.parse_filename of <cve_bin_tool.helper_script.HelperScript object at 0x7f72e0895cd0>>('libsndfile-1.0.25-12.el7.x86_64.rpm')
 +    where <bound method HelperScript.parse_filename of <cve_bin_tool.helper_script.HelperScript object at 0x7f72e0895cd0>> = <cve_bin_tool.helper_script.HelperScript object at 0x7f72e0895cd0>.parse_filename
FAILED test/test_helper_script.py::TestHelperScript::test_parse_filename[libsndfile-1.0.31-1-aarch64.pkg.tar.xz-libsndfile-1.0.31] - AssertionError: assert ('libsndfile', '1.0.31') == None
 +  where None = <bound method HelperScript.parse_filename of <cve_bin_tool.helper_script.HelperScript object at 0x7f72e1897bd0>>('libsndfile-1.0.31-1-aarch64.pkg.tar.xz')
 +    where <bound method HelperScript.parse_filename of <cve_bin_tool.helper_script.HelperScript object at 0x7f72e1897bd0>> = <cve_bin_tool.helper_script.HelperScript object at 0x7f72e1897bd0>.parse_filename
FAILED test/test_helper_script.py::TestHelperScript::test_parse_filename[logrotate_3.14.0-4ubuntu5_amd64.deb-logrotate-3.14.0] - AssertionError: assert ('logrotate', '3.14.0') == None
 +  where None = <bound method HelperScript.parse_filename of <cve_bin_tool.helper_script.HelperScript object at 0x7f72e1897890>>('logrotate_3.14.0-4ubuntu5_amd64.deb')
 +    where <bound method HelperScript.parse_filename of <cve_bin_tool.helper_script.HelperScript object at 0x7f72e1897890>> = <cve_bin_tool.helper_script.HelperScript object at 0x7f72e1897890>.parse_filename
FAILED test/test_helper_script.py::TestHelperScript::test_parse_filename[libarchive_3.4.2-1_aarch64_cortex-a72.ipk-libarchive-3.4.2] - AssertionError: assert ('libarchive', '3.4.2') == None
 +  where None = <bound method HelperScript.parse_filename of <cve_bin_tool.helper_script.HelperScript object at 0x7f72e1897a90>>('libarchive_3.4.2-1_aarch64_cortex-a72.ipk')
 +    where <bound method HelperScript.parse_filename of <cve_bin_tool.helper_script.HelperScript object at 0x7f72e1897a90>> = <cve_bin_tool.helper_script.HelperScript object at 0x7f72e1897a90>.parse_filename
FAILED test/test_helper_script.py::TestHelperScript::test_parse_filename[tomcat9_9.0.37-3_all.deb-tomcat9-9.0.37] - AssertionError: assert ('tomcat9', '9.0.37') == None
 +  where None = <bound method HelperScript.parse_filename of <cve_bin_tool.helper_script.HelperScript object at 0x7f72e188f850>>('tomcat9_9.0.37-3_all.deb')
 +    where <bound method HelperScript.parse_filename of <cve_bin_tool.helper_script.HelperScript object at 0x7f72e188f850>> = <cve_bin_tool.helper_script.HelperScript object at 0x7f72e188f850>.parse_filename
FAILED test/test_helper_script.py::TestHelperScript::test_parse_filename[openssh-client_8.4p1-5ubuntu1_amd64.deb-openssh-client-8.4p1] - AssertionError: assert ('openssh-client', '8.4p1') == None
 +  where None = <bound method HelperScript.parse_filename of <cve_bin_tool.helper_script.HelperScript object at 0x7f72e16db390>>('openssh-client_8.4p1-5ubuntu1_amd64.deb')
 +    where <bound method HelperScript.parse_filename of <cve_bin_tool.helper_script.HelperScript object at 0x7f72e16db390>> = <cve_bin_tool.helper_script.HelperScript object at 0x7f72e16db390>.parse_filename
FAILED test/test_helper_script.py::TestHelperScript::test_parse_filename[./Packages/bash-4.2.46-34.el7.x86_64.rpm-bash-4.2.46] - AssertionError: assert ('bash', '4.2.46') == None
 +  where None = <bound method HelperScript.parse_filename of <cve_bin_tool.helper_script.HelperScript object at 0x7f72e16e4210>>('./Packages/bash-4.2.46-34.el7.x86_64.rpm')
 +    where <bound method HelperScript.parse_filename of <cve_bin_tool.helper_script.HelperScript object at 0x7f72e16e4210>> = <cve_bin_tool.helper_script.HelperScript object at 0x7f72e16e4210>.parse_filename
===== 7 failed, 1628 passed, 59 skipped, 33 warnings in 977.54s (0:16:17) ======

At a glance: there is a test for libsndfile that might need to be updated before it can pass because of the lib prefix change, but some of the others look like they shouldn't have changed behaviour so there may be some code tweaking that needs to happen to get them passing again so we can get this merged.

@ffontaine
Copy link
Contributor

All those failures are raised because this PR replaces this line:

            elif filename.endswith(".deb") or filename.endswith(".ipk"):

by this one:

            elif "_" in filename:

As a result, parse_filename will set product_name for libsndfile-1.0.25-12.el7.x86_64.rpm to libsndfile-1.0.25-12.el7.x86. Even when removing digits with remove_digits, the product_name will still be plain wrong: libsndfile-..-.el.x

The issue can easily be reproduced outside of unit tests through:

python cve_bin_tool/helper_script.py /tmp/libsndfile-1.0.25-12.el7.x86_64.rpm

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.

feat: let helper_script.py search for both libXYZ and XYZ
4 participants