Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add allow-list functionality to securitychecker_enlightn #1161

Open
wants to merge 5 commits into
base: v2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/tasks/securitychecker/enlightn.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ grumphp:
securitychecker_enlightn:
lockfile: ./composer.lock
run_always: false
allow_list:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This configuraiton option should be explained in more details underneath.

- CVE-2018-15133
- CVE-2024-51755
- CVE-2024-45411
```

**lockfile**
Expand Down
3 changes: 3 additions & 0 deletions src/Task/SecurityCheckerEnlightn.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ public static function getConfigurableOptions(): ConfigOptionsResolver
$resolver->setDefaults([
'lockfile' => './composer.lock',
'run_always' => false,
'allow_list' => []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method provideConfigurableOptions in the test should be altered to cover this newly added default.

]);

$resolver->addAllowedTypes('lockfile', ['string']);
$resolver->addAllowedTypes('run_always', ['bool']);
$resolver->addAllowedTypes('allow_list', ['array']);

return ConfigOptionsResolver::fromOptionsResolver($resolver);
}
Expand All @@ -50,6 +52,7 @@ public function run(ContextInterface $context): TaskResultInterface
$arguments = $this->processBuilder->createArgumentsForCommand('security-checker');
$arguments->add('security:check');
$arguments->addOptionalArgument('%s', $config['lockfile']);
$arguments->addArgumentArrayWithSeparatedValue('--allow-list', $config['allow_list'] ?? []);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allow_list is not nullable since it has a default of []


$process = $this->processBuilder->buildProcess($arguments);
$process->run();
Expand Down
11 changes: 11 additions & 0 deletions test/Unit/Task/SecurityCheckerEnlightnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,16 @@ public function provideExternalTaskRuns(): iterable
'./composer.lock',
]
];

yield 'with_allow_list' => [
['allow_list' => ['allow_advisory_1', 'allow_advisory_2']],
$this->mockContext(RunContext::class, ['composer.lock']),
'security-checker',
[
'security:check',
'./composer.lock',
'--allow-list=allow_advisory_1,allow_advisory_2'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not how addArgumentArrayWithSeparatedValue works.
If you want this output, you could use something like:

addOptionalCommaSeparatedArgument('--allow-list=%s', $config['allow_list']);

]
];
}
}
Loading