Skip to content

[Process] ExecutableFinder::find() method will execute exec() by passed the name parameter #53479

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

Closed
kayw-geek opened this issue Jan 10, 2024 · 0 comments · Fixed by #53481 or #54006
Closed

Comments

@kayw-geek
Copy link
Contributor

kayw-geek commented Jan 10, 2024

Symfony version(s) affected

v6.4.2

How to reproduce

In my Laravel project composer.json file, script defined a few script like that

"post-update-cmd": [
            "@php -r \"file_put_contents('storage/local/last-composer-lock-hash', md5_file('composer.lock'));\""
        ],

when I run composer run script post-update-cmd the composer package will remove the prefix @php and extract -r to determine if the file is executable, and then the exec('command -v') will execute -r that exec('command -v -r') and output a message that "sh: line 0: command: -r: invalid option
command: usage: command [-pVv] command [arg ...]
"

Possible Solution

I want to pull a PR to update the exec() function, What do you think about that?

Additional Context

No response

@kayw-geek kayw-geek added the Bug label Jan 10, 2024
nicolas-grekas added a commit that referenced this issue Jan 11, 2024
…th a dash (kayw-geek)

This PR was submitted for the 7.1 branch but it was merged into the 5.4 branch instead.

Discussion
----------

[Process] Fix executable finder when the command starts with a dash

| Q             | A
| ------------- | ---
| Branch?       |  5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #53479
| License       | MIT

Commits
-------

8ceaa8e [Process] Fix executable finder when the command starts with a dash
nicolas-grekas added a commit that referenced this issue Feb 20, 2024
This PR was submitted for the 7.1 branch but it was merged into the 6.4 branch instead.

Discussion
----------

[Process] Fix the `command -v` exception

| Q             | A
| ------------- | ---
| Branch?       |  6.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #53479
| License       | MIT

This PR is a continuation of the fixes made in PR #53481 to address the issue. The previous PR partially addressed the problem, but after further review and testing, it was determined that additional changes were needed.

Fix the `command -v` exception when the command option with a dash prefix.

Commits
-------

2b73f0c Fix the `command -v` exception when the command option with a dash prefix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment