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 55namespace Dazz \PhpMcpTools \Tool ;
66
77use Dazz \PhpMcpTools \Exception \InvalidArgumentException ;
8+ use PhpLlm \LlmChain \Chain \JsonSchema \Attribute \With ;
89use PhpLlm \LlmChain \Chain \Toolbox \Attribute \AsTool ;
910use Webmozart \Assert \Assert ;
1011
@@ -17,6 +18,9 @@ public function __construct(
1718 ) {
1819 }
1920
21+ /**
22+ * @return string Result of checking if executable exists
23+ */
2024 public function exists (): string
2125 {
2226 return $ this ->isExecutableExisting () ? 'composer executable exists ' : 'composer executable not found ' ;
@@ -33,6 +37,7 @@ public function exists(): string
3337 * @throws \InvalidArgumentException If composer executable is not found
3438 */
3539 public function execute (
40+ #[With(pattern: '/^[a-z\-]+$/ ' )]
3641 string $ command = 'list ' ,
3742 array $ options = [],
3843 array $ arguments = [],
@@ -42,7 +47,7 @@ public function execute(
4247 throw new InvalidArgumentException ('Composer executable not found. Please install Composer. ' );
4348 }
4449
45- if (!preg_match ('/^[a-zA-Z0-9_ \-]+$/ ' , $ command )) {
50+ if (!preg_match ('/^[a-z \-]+$/ ' , $ command )) {
4651 throw new InvalidArgumentException ('Invalid Composer command. Only alphanumeric characters, underscores, and hyphens are allowed. ' );
4752 }
4853
You can’t perform that action at this time.
0 commit comments