I have published my first stable module and would like to apply for security advisory coverage.

Project link

https://www.drupal.org/project/views_nl_filter

Comments

sanju_bera created an issue. See original summary.

vishal.kadam’s picture

Title: Module Security Coverage Request » [1.0.x] Views Natural Language Filter
Assigned: sanju_bera » Unassigned
Issue summary: View changes
Priority: Major » Normal
avpaderno’s picture

Thank you for applying!

Before giving links helpful to understand how the review process works, what to expect from a review, and what to do to avoid a review takes more time than needed, I would like to thank all the reviewers for the work they do.
These applications are volunters-driven, which also means it is not possible to predict when an application will be marked fixed and the applicant will get the permission to opt projects into security advisory policy. While we aim to make an application as quick as possible, it is also important for us that more people review the project used for an application. In this way, we make sure applications do not miss some important points that should be instead reported.
Applications are not meant to be complete debugging sessions that eliminate every existing bug, though. I apologize if sometimes applications seem to go into too-detailed reviews.

Please read Review process for security advisory coverage: What to expect for more details and Security advisory coverage application checklist to understand what reviewers look for. Tips for ensuring a smooth review gives some hints for a smoother review.

The important notes are the following.

  • If you have not done it yet, you should enable GitLab CI for the project and fix the PHP_CodeSniffer errors/warnings it reports.
  • For the time this application is open, only your commits are allowed.
  • The purpose of this application is giving you a new drupal.org role that allows you to opt projects into security advisory coverage, either projects you already created, or projects you will create. The project status will not be changed by this application; once this application is closed, you will be able to change the project status from Not covered to Opt into security advisory coverage. This is possible only 14 days after the project is created.

    Keep in mind that once the project is opted into security advisory coverage, only Security Team members may change coverage.
  • Only the person who created the application will get the permission to opt projects into security advisory coverage. No other person will get the same permission from the same application; that applies also to co-maintainers/maintainers of the project used for the application.
  • We only accept an application per user. If you change your mind about the project to use for this application, or it is necessary to use a different project for the application, please update the issue summary with the link to the correct project and the issue title with the project name and the branch to review.

To the reviewers

Please read How to review security advisory coverage applications, Application workflow, What to cover in an application review, and Tools to use for reviews.

The important notes are the following.

  • It is preferable to wait for a project moderator before posting the first comment on newly created applications. Project moderators will do some preliminary checks that are necessary before any change on the project files is suggested.
  • Reviewers should show the output of a CLI tool only once per application.
  • It may be best to have the applicant fix things before further review.

For new reviewers, I would also suggest to first read In which way the issue queue for coverage applications is different from other project queues.

avpaderno’s picture

Remember to change status, when the project is ready to be reviewed. In this queue, projects are only reviewed when the status is Needs review.

batigolix’s picture

Status: Active » Needs work

Some issues to work on:

  1. Fix XSS in CacheAnalyzerController.php:92 — AI response rendered via #markup with json_encode() which does NOT escape < and >. If prompt injection causes the AI to return HTML in JSON values, this becomes stored XSS. Fix: wrap with htmlspecialchars(json_encode($response, JSON_PRETTY_PRINT), ENT_QUOTES, 'UTF-8').
  2. Fix logger string concatenation in QueryParser.php — Lines 242 and 293 concatenate raw strings/exception messages into log calls. Use @message placeholders instead: $this->logger->error('AI Parsing Error: @message', ['@message' => $e->getMessage()]). This follows Drupal logging best practices and prevents potential log injection.
  3. Verify GitLab CI pipeline passes — PHPCS is clean locally (0 errors, 0 warnings), but the CI pipeline status needs to be confirmed at GitLab Pipelines. The initial reviewer feedback specifically mentioned enabling CI.
  4. Add functional/kernel tests — The 74% unit test coverage ratio is excellent (QueryParserTest, EntityResolverTest, SchemaGeneratorTest). However, there are no integration tests for the Views exposed form workflow, filter application, or the CacheAnalyzerController.
avpaderno’s picture

Status: Needs work » Active

Applicants are allowed to set the initial status to Active. Reviews should be done when they set the status to Needs review.

sanju_bera’s picture

Status: Active » Needs review
vishal.kadam’s picture

Status: Needs review » Needs work

1. FILE: views_nl_filter.info.yml

- drupal:ai

The dependencies follow the format <project name>:<module name>. What used for the AI module is not correct.

2. FILE: views_nl_filter.module and views_nl_filter.views.inc

A new module that aims to be compatible with latest Drupal releases is expected to implement hooks as class methods as described in Support for object oriented hook implementations using autowired services.

3. FILE: src/Controller/CacheAnalyzerController.php

  /**
   * The database connection.
   *
   * @var \Drupal\Core\Database\Connection
   */
  protected $database;

  /**
   * The date formatter service.
   *
   * @var \Drupal\Core\Datetime\DateFormatterInterface
   */
  protected $dateFormatter;

  /**
   * Constructs a CacheAnalyzerController object.
   *
   * @param \Drupal\Core\Database\Connection $database
   *   The database connection.
   * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
   *   The date formatter service.
   */
  public function __construct(Connection $database, DateFormatterInterface $date_formatter) {
    $this->database      = $database;
    $this->dateFormatter = $date_formatter;
  }

FILE: src/Form/NlFilterSettingsForm.php

  /**
   * The AI provider plugin manager.
   *
   * @var \Drupal\ai\AiProviderPluginManager
   */
  protected $aiProviderManager;

  /**
   * The AI provider form helper.
   *
   * @var \Drupal\ai\Service\AiProviderFormHelper
   */
  protected $aiProviderFormHelper;

  /**
   * The logger channel.
   *
   * @var \Drupal\Core\Logger\LoggerChannelInterface
   */
  protected $logger;

  /**
   * Constructs a NlFilterSettingsForm object.
   *
   * @param \Drupal\ai\AiProviderPluginManager $ai_provider_manager
   *   The AI provider plugin manager.
   * @param \Drupal\ai\Service\AiProviderFormHelper $ai_form_helper
   *   The AI provider form helper.
   * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $logger_factory
   *   The logger factory.
   */
  public function __construct(
    AiProviderPluginManager $ai_provider_manager,
    AiProviderFormHelper $ai_form_helper,
    LoggerChannelFactoryInterface $logger_factory,
  ) {
    $this->aiProviderManager    = $ai_provider_manager;
    $this->aiProviderFormHelper = $ai_form_helper;
    $this->logger               = $logger_factory->get('views_nl_filter');
  }

FILE: src/Service/EntityResolver.php

  /**
   * The entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * Constructs an EntityResolver object.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager.
   */
  public function __construct(EntityTypeManagerInterface $entity_type_manager) {
    $this->entityTypeManager = $entity_type_manager;
  }

FILE: src/Service/QueryParser.php

  /**
   * The AI provider plugin manager.
   *
   * @var \Drupal\ai\AiProviderPluginManager
   */
  protected $aiProviderManager;

  /**
   * The logger channel.
   *
   * @var \Drupal\Core\Logger\LoggerChannelInterface
   */
  protected $logger;

  /**
   * The config factory.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * The cache interface.
   *
   * @var \Drupal\Core\Cache\CacheBackendInterface
   */
  protected $cache;

  /**
   * Constructs a QueryParser object.
   *
   * @param \Drupal\ai\AiProviderPluginManager $ai_provider_manager
   *   The AI provider manager.
   * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $logger_factory
   *   The logger factory.
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   The config factory.
   * @param \Drupal\Core\Cache\CacheBackendInterface $cache_default
   *   The default cache backend.
   */
  public function __construct(
    AiProviderPluginManager $ai_provider_manager,
    LoggerChannelFactoryInterface $logger_factory,
    ConfigFactoryInterface $config_factory,
    CacheBackendInterface $cache_default,
  ) {
    $this->aiProviderManager = $ai_provider_manager;
    $this->logger            = $logger_factory->get('views_nl_filter');
    $this->configFactory     = $config_factory;
    $this->cache             = $cache_default;
  }

FILE: src/Service/SchemaGenerator.php

  /**
   * The entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * Constructs a SchemaGenerator object.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager.
   */
  public function __construct(EntityTypeManagerInterface $entity_type_manager) {
    $this->entityTypeManager = $entity_type_manager;
  }

New modules, which are compatible with Drupal 10 and higher versions are expected to use constructor property promotion.

4. FILE: src/Form/NlFilterSettingsForm.php

With Drupal 10 and Drupal 11, there is no longer need to use #default_value for each form element, when the parent class is ConfigFormBase: It is sufficient to use #config_target, as in the following code.

    $form['image_toolkit'] = [
      '#type' => 'radios',
      '#title' => $this->t('Select an image processing toolkit'),
      '#config_target' => 'system.image:toolkit',
      '#options' => [],
    ];

Using that code, it is no longer needed to save the configuration values in the form submission handler: The parent class will take care of that.

5. FILE: src/Plugin/views/filter/NaturalLanguageFilter.php

Projects that are compatible with Drupal 10 or higher versions should use attributes instead of annotations.

6. FILE: src/Service/QueryParser.php

$this->logger->error('AI Parsing Error: ' . $e->getMessage());

$this->logger->error('AI Parsing Error (no temperature): ' . $e->getMessage());

$this->logger->error('Invalid JSON received from AI: ' . $content);

The $message parameter passed to the LoggerInterface methods must be a literal string that uses placeholders. It is not a translatable string returned from t()/$this->t(), a string concatenation, a value returned from a function/method, nor a variable containing an exception object.

avpaderno’s picture

Furthermore, in the case of exceptions, it is probably also important to log the backtrace, which allows understanding what caused the exception. For that, Drupal has Error::logException().