Koha-QA

 view release on metacpan or  search on metacpan

lib/Koha/QA/Security/TemplateFilters.pm  view on Meta::CPAN

package Koha::QA::Security::TemplateFilters;

use Modern::Perl;
use base 'Koha::QA::Base';

=head1 NAME

Koha::QA::Security::TemplateFilters - Detect and fix missing filters in Template Toolkit files

=head1 SYNOPSIS

  use Koha::QA::Security::TemplateFilters;

  # With a file
  my $checker = Koha::QA::Security::TemplateFilters->new({file => $file_path});

  # Or with content directly
  my $checker = Koha::QA::Security::TemplateFilters->new({content => $template_content});

  my $is_valid = $checker->check;
  my @errors = $checker->errors;

  # Get fixed content
  my $fixed_content = $checker->fix;

=head1 DESCRIPTION

This module provides functionality to detect and automatically fix missing
filters in Template Toolkit template files.
It helps ensure that variables are properly escaped to prevent XSS vulnerabilities.

=head1 METHODS

=head2 new

  my $checker = Koha::QA::Security::TemplateFilters->new({file => $file_path});

Creates a new TemplateFilters checker instance.

=head2 check

  my $is_valid = $checker->check;

Checks the file for missing filters.

=head2 errors

  my @errors = $checker->errors;

Returns array of error hashrefs, each containing:
  - error: The type of error (asset_must_be_raw, missing_filter, wrong_html_filter, extra_filter_not_needed)
  - line: The line where the error was found
  - line_number: The line number where the error was found

=head2 fix

  my $fixed_content = $checker->fix;

Returns the content with the correct (guessed) filters applied.

=cut

our @tt_directives = (



( run in 1.283 second using v1.01-cache-2.11-cpan-eb134014566 )