File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 5
5
namespace Dazz \PhpMcpTools \Tool ;
6
6
7
7
use Dazz \PhpMcpTools \Exception \InvalidArgumentException ;
8
+ use PhpLlm \LlmChain \Chain \JsonSchema \Attribute \With ;
8
9
use PhpLlm \LlmChain \Chain \Toolbox \Attribute \AsTool ;
9
10
use Webmozart \Assert \Assert ;
10
11
@@ -17,6 +18,9 @@ public function __construct(
17
18
) {
18
19
}
19
20
21
+ /**
22
+ * @return string Result of checking if executable exists
23
+ */
20
24
public function exists (): string
21
25
{
22
26
return $ this ->isExecutableExisting () ? 'composer executable exists ' : 'composer executable not found ' ;
@@ -33,6 +37,7 @@ public function exists(): string
33
37
* @throws \InvalidArgumentException If composer executable is not found
34
38
*/
35
39
public function execute (
40
+ #[With(pattern: '/^[a-z\-]+$/ ' )]
36
41
string $ command = 'list ' ,
37
42
array $ options = [],
38
43
array $ arguments = [],
@@ -42,7 +47,7 @@ public function execute(
42
47
throw new InvalidArgumentException ('Composer executable not found. Please install Composer. ' );
43
48
}
44
49
45
- if (!preg_match ('/^[a-zA-Z0-9_ \-]+$/ ' , $ command )) {
50
+ if (!preg_match ('/^[a-z \-]+$/ ' , $ command )) {
46
51
throw new InvalidArgumentException ('Invalid Composer command. Only alphanumeric characters, underscores, and hyphens are allowed. ' );
47
52
}
48
53
You can’t perform that action at this time.
0 commit comments