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

Usage of __file__ Throwing Warnings #249

Closed
ryanohoro opened this issue Dec 16, 2022 · 2 comments
Closed

Usage of __file__ Throwing Warnings #249

ryanohoro opened this issue Dec 16, 2022 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@ryanohoro
Copy link
Collaborator

Describe the bug

Tests use the __file__ variable, easy_install does not like.

Steps to reproduce

docker-compose build

...

strelka.tests.__pycache__.test_scan_docx.cpython-310: module references __file__
strelka.tests.__pycache__.test_scan_gif.cpython-310: module references __file__
strelka.tests.__pycache__.test_scan_html.cpython-310: module references __file__
strelka.tests.__pycache__.test_scan_iso.cpython-310: module references __file__
strelka.tests.__pycache__.test_scan_jpeg.cpython-310: module references __file__
strelka.tests.__pycache__.test_scan_msi.cpython-310: module references __file__
strelka.tests.__pycache__.test_scan_pe.cpython-310: module references __file__
strelka.tests.__pycache__.test_scan_png_eof.cpython-310: module references __file__
strelka.tests.__pycache__.test_scan_vhd.cpython-310: module references __file__

...

Expected behavior

Tests should not throw warnings.

Screenshots
N/A

Release

  • Release: 0.22.12.08

Additional context

@phutelmyer phutelmyer added the bug Something isn't working label Dec 20, 2022
@phutelmyer phutelmyer self-assigned this Dec 20, 2022
@phutelmyer
Copy link
Contributor

phutelmyer commented Dec 23, 2022

__file__ is a global variable that contains the name of the file in which it is used. This warning is probably because using a reference like that may lead to import issues.

To avoid this warning, we can try to remove any references and replace with the __name__ attribute instead, as this attribute contains the name of the module rather than the file path.

For example:
https://github.com/target/strelka/blob/master/src/python/strelka/tests/test_scan_bzip2.py#L19, would change __file__ to __name__, using the name of the module rather than the file path.

Not sure that will work in this context, but I will give this a test in the near future.

@phutelmyer
Copy link
Contributor

The above method could work, but would require refactoring. In the application's current state and based on how Strelka is built, this will warning will not cause issues.

The following PR was submitted to silence this warning: #272 (comment)

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
None yet
Development

No branches or pull requests

2 participants