Skip to content

Commit 3018636

Browse files
authored
Merge pull request #1164 from luckyraul/composer_audit_abandoned
Add composer audit abandoned behavior
2 parents 6e95a02 + 1725b76 commit 3018636

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

doc/tasks/securitychecker/composeraudit.md

+7
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,20 @@ The task lives under the `securitychecker_composeraudit` namespace and has the f
1111
grumphp:
1212
tasks:
1313
securitychecker_composeraudit:
14+
abandoned: null
1415
format: null
1516
locked: true
1617
no_dev: false
1718
run_always: false
1819
working_dir: null
1920
```
2021
22+
**abandoned**
23+
24+
*Default: null*
25+
26+
You can choose the behavior on abandoned packages. The available options are `ignore`, `report` and `fail`. By default, grumphp will use the `fail` behavior.
27+
2128
**format**
2229

2330
*Default: null*

src/Task/SecurityCheckerComposeraudit.php

+3
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ public static function getConfigurableOptions(): ConfigOptionsResolver
2222
{
2323
$resolver = new OptionsResolver();
2424
$resolver->setDefaults([
25+
'abandoned' => null,
2526
'format' => null,
2627
'locked' => true,
2728
'no_dev' => false,
2829
'run_always' => false,
2930
'working_dir' => null,
3031
]);
3132

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

5658
$arguments = $this->processBuilder->createArgumentsForCommand('composer');
5759
$arguments->add('audit');
60+
$arguments->addOptionalArgument('--abandoned=%s', $config['abandoned']);
5861
$arguments->addOptionalArgument('--format=%s', $config['format']);
5962
$arguments->addOptionalArgument('--locked', $config['locked']);
6063
$arguments->addOptionalArgument('--no-dev', $config['no_dev']);

test/Unit/Task/SecurityCheckerComposerauditTest.php

+14
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function provideConfigurableOptions(): iterable
2525
yield 'defaults' => [
2626
[],
2727
[
28+
'abandoned' => null,
2829
'format' => null,
2930
'locked' => true,
3031
'no_dev' => false,
@@ -148,6 +149,19 @@ public function provideExternalTaskRuns(): iterable
148149
]
149150
];
150151

152+
yield 'abandoned' => [
153+
[
154+
'abandoned' => 'ignore',
155+
],
156+
$this->mockContext(RunContext::class, ['composer.lock']),
157+
'composer',
158+
[
159+
'audit',
160+
'--abandoned=ignore',
161+
'--locked',
162+
]
163+
];
164+
151165
yield 'working-dir' => [
152166
[
153167
'working_dir' => 'dir',

0 commit comments

Comments
 (0)