Skip to content

Commit

Permalink
Merge pull request #1164 from luckyraul/composer_audit_abandoned
Browse files Browse the repository at this point in the history
Add composer audit abandoned behavior
  • Loading branch information
veewee authored Dec 12, 2024
2 parents 6e95a02 + 1725b76 commit 3018636
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
7 changes: 7 additions & 0 deletions doc/tasks/securitychecker/composeraudit.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,20 @@ The task lives under the `securitychecker_composeraudit` namespace and has the f
grumphp:
tasks:
securitychecker_composeraudit:
abandoned: null
format: null
locked: true
no_dev: false
run_always: false
working_dir: null
```
**abandoned**
*Default: null*
You can choose the behavior on abandoned packages. The available options are `ignore`, `report` and `fail`. By default, grumphp will use the `fail` behavior.

**format**

*Default: null*
Expand Down
3 changes: 3 additions & 0 deletions src/Task/SecurityCheckerComposeraudit.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ public static function getConfigurableOptions(): ConfigOptionsResolver
{
$resolver = new OptionsResolver();
$resolver->setDefaults([
'abandoned' => null,
'format' => null,
'locked' => true,
'no_dev' => false,
'run_always' => false,
'working_dir' => null,
]);

$resolver->addAllowedTypes('abandoned', ['null', 'string']);
$resolver->addAllowedTypes('format', ['null', 'string']);
$resolver->addAllowedTypes('locked', ['bool']);
$resolver->addAllowedTypes('no_dev', ['bool']);
Expand All @@ -55,6 +57,7 @@ public function run(ContextInterface $context): TaskResultInterface

$arguments = $this->processBuilder->createArgumentsForCommand('composer');
$arguments->add('audit');
$arguments->addOptionalArgument('--abandoned=%s', $config['abandoned']);
$arguments->addOptionalArgument('--format=%s', $config['format']);
$arguments->addOptionalArgument('--locked', $config['locked']);
$arguments->addOptionalArgument('--no-dev', $config['no_dev']);
Expand Down
14 changes: 14 additions & 0 deletions test/Unit/Task/SecurityCheckerComposerauditTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function provideConfigurableOptions(): iterable
yield 'defaults' => [
[],
[
'abandoned' => null,
'format' => null,
'locked' => true,
'no_dev' => false,
Expand Down Expand Up @@ -148,6 +149,19 @@ public function provideExternalTaskRuns(): iterable
]
];

yield 'abandoned' => [
[
'abandoned' => 'ignore',
],
$this->mockContext(RunContext::class, ['composer.lock']),
'composer',
[
'audit',
'--abandoned=ignore',
'--locked',
]
];

yield 'working-dir' => [
[
'working_dir' => 'dir',
Expand Down

0 comments on commit 3018636

Please sign in to comment.