Skip to content

Commit f18e860

Browse files
authored
Merge pull request #1161 from peterjaap/patch-2
Add allow-list functionality to securitychecker_enlightn
2 parents fed00cb + eda6d36 commit f18e860

3 files changed

Lines changed: 33 additions & 0 deletions

File tree

doc/tasks/securitychecker/enlightn.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ grumphp:
1919
securitychecker_enlightn:
2020
lockfile: ./composer.lock
2121
run_always: false
22+
allow_list:
23+
- CVE-2018-15133
24+
- CVE-2024-51755
25+
- CVE-2024-45411
2226
```
2327
2428
**lockfile**
@@ -32,3 +36,17 @@ If your `composer.lock` file is located in an exotic location, you can specify t
3236
*Default: false*
3337

3438
When this option is set to `false`, the task will only run when the `composer.lock` file has changed. If it is set to `true`, the `composer.lock` file will be checked on every commit.
39+
40+
**allow_list**
41+
42+
*Default: []*
43+
44+
This option allows you to specify a list of CVE identifiers that should be ignored during the security check. This is useful if you have assessed certain vulnerabilities and determined that they do not pose a risk to your project. The CVE identifiers should be provided as an array of strings. For example:
45+
46+
```yaml
47+
allow_list:
48+
- CVE-2018-15133
49+
- CVE-2024-51755
50+
- CVE-2024-45411
51+
```
52+

src/Task/SecurityCheckerEnlightn.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ public static function getConfigurableOptions(): ConfigOptionsResolver
2424
$resolver->setDefaults([
2525
'lockfile' => './composer.lock',
2626
'run_always' => false,
27+
'allow_list' => []
2728
]);
2829

2930
$resolver->addAllowedTypes('lockfile', ['string']);
3031
$resolver->addAllowedTypes('run_always', ['bool']);
32+
$resolver->addAllowedTypes('allow_list', ['array']);
3133

3234
return ConfigOptionsResolver::fromOptionsResolver($resolver);
3335
}
@@ -50,6 +52,7 @@ public function run(ContextInterface $context): TaskResultInterface
5052
$arguments = $this->processBuilder->createArgumentsForCommand('security-checker');
5153
$arguments->add('security:check');
5254
$arguments->addOptionalArgument('%s', $config['lockfile']);
55+
$arguments->addOptionalCommaSeparatedArgument('--allow-list=%s', $config['allow_list']);
5356

5457
$process = $this->processBuilder->buildProcess($arguments);
5558
$process->run();

test/Unit/Task/SecurityCheckerEnlightnTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public function provideConfigurableOptions(): iterable
2727
[
2828
'lockfile' => './composer.lock',
2929
'run_always' => false,
30+
'allow_list' => [],
3031
]
3132
];
3233
}
@@ -107,5 +108,16 @@ public function provideExternalTaskRuns(): iterable
107108
'./composer.lock',
108109
]
109110
];
111+
112+
yield 'with_allow_list' => [
113+
['allow_list' => ['allow_advisory_1', 'allow_advisory_2']],
114+
$this->mockContext(RunContext::class, ['composer.lock']),
115+
'security-checker',
116+
[
117+
'security:check',
118+
'./composer.lock',
119+
'--allow-list=allow_advisory_1,allow_advisory_2'
120+
]
121+
];
110122
}
111123
}

0 commit comments

Comments
 (0)