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

I want a rule that will check that aren't parenthesis opening characters in tests ids #256

Open
mondeja opened this issue Aug 31, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@mondeja
Copy link
Contributor

mondeja commented Aug 31, 2023

Rule request

Description

When you put a parenthesis opening character ( inside a test id and you execute that test via command line directly without wrapping it by single quotes it leads a subshell execution in unix-like shells.

This typically raises a syntax error and the command is not executed. But if you put a dollar sign character $ before the opening parenthesis, it always leads to a real subshell execution and replacing, which could be a serious security problem.

$ pytest test.py::my_test[foo(echo malicious)]
bash: syntax error near unexpected element '('
$ pytest test.py::my_test[foo$(echo malicious)]
=== test session starts ===
...
collected 0 items                                                                                                                  

=== no tests ran in 0.00s ===
ERROR: file or directory not found: test.py::my_test[foomalicious]

$ pytest 'test.py::my_test[foo$(echo malicious)]'
=== test session starts ===
...
collected 0 items                                                                                                                  

=== no tests ran in 0.00s ===
ERROR: file or directory not found: test.py::my_test[foo$(echo malicious)]

Rationale

Commonly, you are executing certain tests changing between them and you forget to wrap test identificators by single quotes.

@mondeja mondeja added the enhancement New feature or request label Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant