Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Messenger][Process] addfromShellCommandline toRunProcessMessage#59768

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

Staormin
Copy link
Contributor

QA
Branch?7.3
Bug fix?no
New feature?yes
Deprecations?no
Issues
LicenseMIT

TheRunProcess::fromShellCommandline() method can be useful when using pipes or redirection.
This feature allow the use of this method when using a RunProcessMessage.

@StaorminStaorminforce-pushed therunprocessmessage-fromshellcommandline branch from243baf1 to5746aabCompareFebruary 13, 2025 14:37
@ro0NL
Copy link
Contributor

What aboutarray|string $command instead?

@stof
Copy link
Member

the Process component has explicitly rejected the usage ofarray|string (we deprecated passing a string to the constructor when introducing the distinction) because the security considerations are totally different between the array of arguments (where escaping is handled internally) and the command line (where the code building the command line is responsible for all required escaping).
So I would vote against an API usingarray|string for theRunProcessMessage.

@ro0NL
Copy link
Contributor

ro0NL commentedFeb 13, 2025
edited
Loading

i mean if it's a string useProcess static constructor, otherwise its regular constructor

having both $command and $commandLine in a regular constructor here, bugs me more :)

@Staormin
Copy link
ContributorAuthor

What aboutarray|string $command instead?

the Process component has explicitly rejected the usage ofarray|string (we deprecated passing a string to the constructor when introducing the distinction) because the security considerations are totally different between the array of arguments (where escaping is handled internally) and the command line (where the code building the command line is responsible for all required escaping). So I would vote against an API usingarray|string for theRunProcessMessage.

Also I find the dedicated method approach more explicit for developper, parameters with multiple type aren't as clear for me.

@Staormin
Copy link
ContributorAuthor

i mean if it's a string useProcess static constructor, otherwise its regular constructor

having both $command and $commandLine in a regular constructor here, bugs me more :)

Yeah that's a good point, maybe a whole other message (RunProcessMessageFromCommandLine ?) would be cleaner ?
Then we could make an abstract that'll be used by both RunProcessMessage and this new message.

@ro0NL
Copy link
Contributor

personallynew RunProcessMessage('ls -a') vsnew RunProcessMessage(['ls', '-a']) conveys fine to me.

Otheriwse i'd prefer the current approach yes over a new class.

@stof
Copy link
Member

@ro0NL The case of static command is not the one having security issues.

newRunProcessMessage(['ls',$folder]);// SecurenewRunProcessMessage(\sprintf('ls %s',$folder));// InsecurenewRunProcessMessage(\sprintf('ls %s',escapeshellarg($folder)));// Secure on Unix system (and partially secure on Windows)

@ro0NL
Copy link
Contributor

new RunProcessMessage(\sprintf('ls %s', $folder)); // Insecure

It would be passed toProcess::fromShellCommandline

@Staormin
Copy link
ContributorAuthor

Staormin commentedFeb 13, 2025
edited
Loading

new RunProcessMessage(\sprintf('ls %s', $folder)); // Insecure

It would be passed toProcess::fromShellCommandline

Yes but the point here is that the user won't know that the call is inherently unsecure, having a dedicated method that is documented as such is better imo

@StaorminStaorminforce-pushed therunprocessmessage-fromshellcommandline branch from5746aab to4afeaeeCompareFebruary 13, 2025 17:13
Allows using the Process::fromShellCommandline when using a RunProcessMessage
@StaorminStaorminforce-pushed therunprocessmessage-fromshellcommandline branch from4afeaee toe448596CompareFebruary 14, 2025 16:23
@Staormin
Copy link
ContributorAuthor

BTW@nicolas-grekas I bisected the php-src to find out why the unit tests fails with php 8.5 and i narrowed it down to those change to reflection:php/php-src#17755
Should I open an issue or should we wait for 8.5 to stabilise before adressing broken components?

@nicolas-grekas
Copy link
Member

Ah nice! Please report to php-src. The earlier the better.

Staormin and noname007 reacted with thumbs up emoji

@fabpot
Copy link
Member

Thank you@Staormin.

Staormin reacted with thumbs up emoji

@fabpotfabpot merged commit6fe4cb5 intosymfony:7.3Feb 15, 2025
6 of 10 checks passed
@StaorminStaormin deleted the runprocessmessage-fromshellcommandline branchFebruary 17, 2025 09:25
@fabpotfabpot mentioned this pull requestMay 2, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@stofstofstof left review comments

@ro0NLro0NLro0NL left review comments

@fabpotfabpotfabpot approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
7.3
Development

Successfully merging this pull request may close these issues.

6 participants
@Staormin@ro0NL@stof@nicolas-grekas@fabpot@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp