Commit 4eaa1399 authored by Roman Reva's avatar Roman Reva
Browse files

Issue #389049: Compatibility fix.

parent e3fa24ae
......@@ -259,7 +259,7 @@ class IssueEntity extends RevisionableContentEntityBase implements IssueEntityIn
* {@inheritdoc}
*/
public function getDetails() {
return $this->get('details')->getValue()[0];
return $this->get('details')->getValue()[0] ?? [];
}
/**
......
......@@ -52,7 +52,7 @@ abstract class AuditBasePlugin extends PluginBase implements AuditPluginInterfac
* @param array $plugin_definition
* The plugin implementation definition.
*/
public function __construct(array $configuration, string $plugin_id, array $plugin_definition) {
public function __construct(array $configuration, $plugin_id, array $plugin_definition) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->pluginSettingsStorage = $this->container()
->get('adv_audit.plugin.config')
......@@ -122,7 +122,7 @@ abstract class AuditBasePlugin extends PluginBase implements AuditPluginInterfac
* The Plugin category ID.
*/
public function getCategoryName() {
return $this->pluginDefinition['category'];
return $this->pluginDefinition['category'] ?? '';
}
/**
......
......@@ -153,7 +153,7 @@ class CodeReviewCSPlugin extends AuditBasePlugin implements ContainerFactoryPlug
$url = $wrapper->getExternalUrl() . $file_rel_path;
$drupal_link = URL::fromUri($url)->toString();
$result['issues']['drupal_standard'] = [
'@issue_title' => 'Problems with Drupal coding standards has been found in your code. You can review them by link <a href=":uri">Drupal</a>.',
'@issue_title' => 'Problems with Drupal coding standards has been found in your code. You can review them by link <a href=":uri" target="_blank">Drupal</a>.',
':uri' => $drupal_link,
];
}
......@@ -171,7 +171,7 @@ class CodeReviewCSPlugin extends AuditBasePlugin implements ContainerFactoryPlug
$url = $wrapper->getExternalUrl() . $file_rel_path;
$drupal_practice_link = URL::fromUri($url)->toString();
$result['issues']['drupal_best_practice'] = [
'@issue_title' => 'Problems with Drupal best practices has been found in your code. You can review them by <a href=":uri">DrupalPractice</a>.',
'@issue_title' => 'Problems with Drupal best practices has been found in your code. You can review them by <a href=":uri" target="_blank">DrupalPractice</a>.',
':uri' => $drupal_practice_link,
];
}
......@@ -210,8 +210,7 @@ class CodeReviewCSPlugin extends AuditBasePlugin implements ContainerFactoryPlug
* Path to phpcs script.
*/
private function getCsDir() {
$vendor_dir = is_dir(DRUPAL_ROOT . '/vendor') ? DRUPAL_ROOT . '/vendor' : DRUPAL_ROOT . '/../vendor';
$phpcs_path = $vendor_dir . '/squizlabs/php_codesniffer/scripts/phpcs';
$phpcs_path = $this->getVendorDir() . '/squizlabs/php_codesniffer/bin/phpcs';
return $phpcs_path;
}
......@@ -223,10 +222,21 @@ class CodeReviewCSPlugin extends AuditBasePlugin implements ContainerFactoryPlug
* Path to coder drupal standards.
*/
private function getStandardsDir() {
$vendor_dir = is_dir(DRUPAL_ROOT . '/vendor') ? DRUPAL_ROOT . '/vendor' : DRUPAL_ROOT . '/../vendor';
$phpcs_standards_path = $vendor_dir . '/drupal/coder/coder_sniffer';
$phpcs_standards_path = $this->getVendorDir() . '/drupal/coder/coder_sniffer';
return $phpcs_standards_path;
}
/**
* Return path to vendor.
*
* @return string
* Path to vendor dir.
*/
private function getVendorDir() {
$vendor_dir = is_dir(DRUPAL_ROOT . '/vendor') ? DRUPAL_ROOT . '/vendor' : DRUPAL_ROOT . '/../vendor';
return $vendor_dir;
}
}
......@@ -94,7 +94,12 @@ class SecurityCodeReviewPlugin extends AuditBasePlugin implements ContainerFacto
$app_root = $this->kernel->getAppRoot();
$composer_lock = is_file($app_root . '/composer.lock') ? $app_root . '/composer.lock' : $app_root . '/../composer.lock';
if (is_file($composer_lock)) {
$this->issues = $this->composerCheck->check($composer_lock);
$check_result = $this->composerCheck->check($composer_lock);
$vulnerabilities = $check_result->__toString();
$format = $check_result->getFormat();
if ($format == 'json') {
$this->issues = json_decode($vulnerabilities);
}
return;
}
$this->issues = [];
......@@ -125,13 +130,13 @@ class SecurityCodeReviewPlugin extends AuditBasePlugin implements ContainerFacto
protected function getIssues() {
$result = [];
foreach ($this->issues as $name => $value) {
if (isset($value['advisories'])) {
foreach ($value['advisories'] as $key => $item) {
if (isset($value->advisories)) {
foreach ($value->advisories as $key => $item) {
$result[$name . ' : ' . $key] = [
'@issue_title' => 'Title @title; description @url',
'@version' => $item['cve'],
'@url' => $item['link'],
'@title' => $item['title'],
'@issue_title' => 'Title @title; description @url',
'@version' => isset($item->cve) ? $item->cve : '',
'@url' => isset($item->link) ? $item->link : '',
'@title' => isset($item->title) ? $item->title : '',
];
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment