Skip to content

Commit e2b09d9

Browse files
committed
use hash for more security
1 parent 424106b commit e2b09d9

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

src/DrupalIssueForkCommand.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
3131
return 1;
3232
}
3333
['project' => $project, 'url' => $url, 'branch' => $branch] = $matches;
34+
$url .= '.git';
3435
$project = "drupal/$project";
3536
$forkRepository = [
3637
'type' => 'git',
37-
'url' => "$url.git",
38+
'url' => $url,
3839
];
3940
$found = FALSE;
4041
$fileName = Factory::getComposerFile();
@@ -50,12 +51,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5051
if (!$found) {
5152
$config['repositories'][] = $forkRepository;
5253
}
53-
if (isset($config['require-dev'][$project])) {
54-
$config['require-dev'][$project] = "dev-$branch";
55-
}
56-
else {
57-
$config['require'][$project] = "dev-$branch";
54+
$constraint = "dev-$branch";
55+
exec("git ls-remote -h $url", $output);
56+
foreach ($output as $line) {
57+
[$ref, $name] = explode("\t", $line);
58+
if ($name === "refs/heads/$branch") {
59+
$constraint .= "#$ref";
60+
break;
61+
}
5862
}
63+
$key = isset($config['require-dev'][$project]) ? 'require-dev' : 'require';
64+
$config[$key][$project] = $constraint;
5965
$this->writeConfig($file, $config);
6066
$io->writeError('<info>'.$fileName.' has been updated</info>');
6167
return 0;

0 commit comments

Comments
 (0)