NAME
Koha::QA::Security::CSRF - Check for missing CSRF tokens and op parameters in forms
SYNOPSIS
use Koha::QA::Security::CSRF;
# With a file
my $checker = Koha::QA::Security::CSRF->new({file => $file_path});
# Or with content directly
my $checker = Koha::QA::Security::CSRF->new({content => $template_content});
my $is_valid = $checker->check;
my @errors = $checker->errors;
DESCRIPTION
This module checks Template Toolkit files for forms that are missing CSRF tokens or have missing/improper op parameters.
METHODS
new
my $checker = Koha::QA::Security::CSRF->new({file => $file_path});
Creates a new CSRF checker instance.
check
my $is_valid = $checker->check;
Checks the file for missing CSRF tokens and op parameters.
errors
my @errors = $checker->errors;
Returns array of error hashrefs, each containing: - line: the form tag content - line_number: the line number - error: the error type (missing_csrf_token, missing_op, invalid_op_value)
AUTHORS
Jonathan Druart <jonathan.druart@bugs.koha-community.org>
COPYRIGHT
Copyright 2026 Koha Development Team
LICENSE
This file is part of Koha.
Koha is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.