Commit Graph

60738 Commits

Author SHA1 Message Date
Martin Renvoize 47a28d62f9
Bug 38365: Integrate CSP middleware into Plack apps
Add Koha::Middleware::ContentSecurityPolicy to the middleware chain
in both app.psgi and the Debian plack.psgi template.

Without this integration, the CSP feature would not work - the
middleware was created but never activated. This adds it to:
- app.psgi (development/git install)
- debian/templates/plack.psgi (opac, intranet, and intranet_svc mounts)

Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Lari Taskula <lari.taskula@hypernova.fi>
Signed-off-by: David Cook <dcook@prosentient.com.au>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2026-03-16 11:57:12 +01:00
David Cook 4301202a2d
Bug 38365: Add "style-src-attr 'unsafe-inline';" to default policy
This change adds "style-src-attr 'unsafe-inline';" to the default CSP policy.

The reason is that we have a lot of inline styles throughout Koha,
and it will take a long time to clean those up. Also, the WYSIWYG/TinyMCE
editor injects inline styles, so it might not be possible to forbid
unsafe inline styles in Koha.

Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lari Taskula <lari.taskula@hypernova.fi>
Signed-off-by: David Cook <dcook@prosentient.com.au>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2026-03-16 11:57:11 +01:00
Lari Taskula e750e6d1f5
Bug 38365: Add Koha::Template::Plugin::Koha::CSPNonce
This patch adds a new Template plugin method, Koha.CSPNonce, that can be used to
attach the Content Security Policy nonce into our templates.

To test:
1. prove t/Koha/Middleware/ContentSecurityPolicy.t
2. prove t/db_dependent/Koha/Template/Plugin/Koha.t

Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: David Cook <dcook@prosentient.com.au>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2026-03-16 11:57:10 +01:00
Lari Taskula e160ed8b06
Bug 38365: Add Koha::Middleware::ContentSecurityPolicy
This patch adds a new Perl package, Koha::Middleware::ContentSecurityPolicy.

It is called for each Plack requests, and its job is to add the
Content-Security-Policy[-Report-Only] header with the configured value.

To test:
1. prove t/Koha/Middleware/ContentSecurityPolicy.t
2. prove t/db_dependent/Koha/Middleware/ContentSecurityPolicy.t

Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: David Cook <dcook@prosentient.com.au>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2026-03-16 11:57:09 +01:00
Lari Taskula b2fcc61bda
Bug 38365: Add Koha::ContentSecurityPolicy
This patch adds a new Perl package, Koha::ContentSecurityPolicy.

It provides the following methods:

  $csp->header_name

Returns the name of the CSP header, based on koha-conf configuration.

  $csp->header_value

Returns the value of the CSP header, based on koha-conf configuration.

  $csp->is_enabled

Returns true or false, based on koha-conf configuration.

  $csp->nonce

Generates or sets, and returns the nonce. A CSP nonce is a random token that is
used both in the inline scripts and the Content-Security-Policy[-Report-Only]
response header.

To test:
1. prove t/Koha/ContentSecurityPolicy.t

Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: David Cook <dcook@prosentient.com.au>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2026-03-16 11:57:08 +01:00
David Cook 7fcae0c823
Bug 38365: Remove unsafe CSP rules
Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lari Taskula <lari.taskula@hypernova.fi>
Signed-off-by: David Cook <dcook@prosentient.com.au>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2026-03-16 11:57:07 +01:00
David Cook 65873238ce
Bug 38365: add nonce to style-src and add default csp to Debian koha-conf.xml template
Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lari Taskula <lari.taskula@hypernova.fi>
Signed-off-by: David Cook <dcook@prosentient.com.au>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2026-03-16 11:57:07 +01:00
Lari Taskula 3dd4cdc3f5
Bug 38365: Add content_security_policy section to koha-conf.xml
To test:
1. xmllint --noout --nonet etc/koha-conf.xml; echo $?
2. Observe 0

Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: David Cook <dcook@prosentient.com.au>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2026-03-16 11:57:06 +01:00
Jonathan Druart 2a6316e462
Bug 41830: Fix Vendors_spec.ts
I think this happens because we select an option that didn't exist in
the dropdown, and "Sorry, there is no matching options" from select2 is
covering the discount input that is right under "Tax rates"

09:45:36     <testcase name="Vendor CRUD operations should add a vendor" time="0.000" classname="should add a vendor">
09:45:36       <failure message="Timed out retrying after 10000ms: `cy.type()` failed because this element:
09:45:36
09:45:36 `&lt;input data-v-2a08b27a=&quot;&quot; id=&quot;discount&quot; inputmode=&quot;numeric&quot; placeholder=&quot;Discount (%)&quot; size=&quot;6&quot;&gt;`
09:45:36
09:45:36 is being covered by another element:
09:45:36
09:45:36 `&lt;li class=&quot;vs__no-options&quot;&gt;Sorry, ...&lt;/li&gt;`
09:45:36
09:45:36 Fix this problem, or use {force: true} to disable error checking.
09:45:36
09:45:36 https://on.cypress.io/element-cannot-be-interacted-with" type="CypressError"><![CDATA[CypressError: Timed out retrying after 10000ms: `cy.type()` failed because this element:
09:45:36
09:45:36 `<input data-v-2a08b27a="" id="discount" inputmode="numeric" placeholder="Discount (%)" size="6">`
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2026-03-16 11:57:05 +01:00
Jonathan Druart 8aa600c880
Bug 41579: (follow-up) Tidy kohaTable - suggestion/suggestion.tt
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2026-03-16 11:57:04 +01:00
Jonathan Druart a1c7b7062c
Bug 41324: Adjust test for bug 38365
The script tags now contain a TT tag
  <script nonce="[% Koha.CSPNonce | $raw %]">

It's not a problem.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:48:19 -06:00
Jonathan Druart 62ca5e0eac
Bug 41324: Add a xt test
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:48:19 -06:00
Jonathan Druart 66d75e9561
Bug 41564: Fix conflict with 41798
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:48:12 -06:00
Lisette Scheer a28cbfd39e
Bug 42071: Add 'show' to options that load a single suggestion
Test plan:

Before applying the patch:
1. Go to acquisitions
2. Go to Purchase Suggestions
3. Create a purchase suggestion (for ease of testing, select Centerville for the library)
4. On the table, click on the suggestion number
5. Observe the suggestion does not populate, including the breadcrumbs, but the url does contain the suggestion number.
6. Apply the patch
7. restart_all
8. Rpeat steps 1-4
9. Observe the suggestion now populates and can be edited.

Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:19:46 -06:00
Jonathan Druart f2425666c9
Bug 41579: suggestions - auto tidy
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:19:45 -06:00
Jonathan Druart 8f7e3d85f9
Bug 41579: Tidy kohaTable - suggestion/suggestion.tt
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:19:45 -06:00
Paul Derscheid 8d86a4c211
Bug 41573: (QA follow-up) Use var instead of const for dynamically loaded template
- patron-lists-tab.tt is loaded dynamically via jQuery .load()
- Using const for patron_id and cardnumber causes a redeclaration
  error when the tab reloads after adding/removing a patron
- Change to var which allows redeclaration in the global scope

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:19:44 -06:00
Paul Derscheid d5c93d917f
Bug 41573: (QA follow-up) Fix missing closing backtick in template literal
- The conversion from string concatenation to a template literal
  in addToList() missed the closing backtick
- This causes a syntax error breaking the add-to-list functionality
  on the patron lists tab

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:19:44 -06:00
Jonathan Druart ea59367794
Bug 41573: patron_lists - auto tidy
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:19:43 -06:00
Jonathan Druart 2aadd46d8d
Bug 41573: Tidy kohaTable - patron_lists/patron-lists-tab.tt
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:19:43 -06:00
Jonathan Druart 49ff9c7199
Bug 41573: Tidy kohaTable - patron_lists/lists.tt
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:19:42 -06:00
Jonathan Druart 15ae4719fe
Bug 41573: Tidy kohaTable - patron_lists/list.tt
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:19:35 -06:00
Lucas Gass 9346a3a722
Bug 41582: (RM follow-up) Add missing aria-hidden attribute to FA icon
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:03:46 -06:00
Lucas Gass 62a66d5fa1
Bug 41582: (RM follow-up) Tidy opac-detail.tt
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:03:46 -06:00
Jonathan Druart 024d9a18ba
Bug 41568: Tidy kohaTable - circ/branchtransfers.tt - fix conflict with 41134
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:03:45 -06:00
Owen Leonard 897c8c7944
Bug 41568: (follow-up) Fix minor JS error
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:03:45 -06:00
Jonathan Druart efb7754c8f
Bug 41568: circ - auto tidy
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:03:44 -06:00
Jonathan Druart a1d951b591
Bug 41568: Tidy kohaTable - circ/waitingreserves.tt
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:03:44 -06:00
Jonathan Druart 261008fb7f
Bug 41568: Tidy kohaTable - circ/view_holdsqueue.tt
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:03:43 -06:00
Jonathan Druart bc6c7b0398
Bug 41568: Tidy kohaTable - circ/transferstoreceive.tt
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:03:43 -06:00
Jonathan Druart 5ab1ea2813
Bug 41568: Tidy kohaTable - circ/transfers_to_send.tt
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:03:42 -06:00
Jonathan Druart a27d8ad394
Bug 41568: Tidy kohaTable - circ/returns.tt
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:03:42 -06:00
Jonathan Druart b6ab1f8f84
Bug 41568: Tidy kohaTable - circ/reserverations.tt
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:03:41 -06:00
Jonathan Druart ef58cbee21
Bug 41568: Tidy kohaTable - circ/pendingreserves.tt
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:03:41 -06:00
Jonathan Druart 2379623013
Bug 41568: Tidy kohaTable - circ/pendingbookings.tt
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:03:40 -06:00
Jonathan Druart fca228fddd
Bug 41568: Tidy kohaTable - circ/overdue.tt
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:03:40 -06:00
Jonathan Druart 751b89ebaf
Bug 41568: Tidy kohaTable - circ/curbside_pickups.tt
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:03:39 -06:00
Jonathan Druart 323833364d
Bug 41568: Tidy kohaTable - circ/circulation_batch_checkouts.tt
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:03:39 -06:00
Jonathan Druart 1ddbe2d136
Bug 41568: Tidy kohaTable - circ/article-requests.tt
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:03:38 -06:00
Jonathan Druart 10ddff6f8d
Bug 41569: (follow-up) Fix conflict with 39698
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:03:38 -06:00
Owen Leonard 13d10ffd2d
Bug 41569: (follow-up) Prevent variable redeclaration warnings
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:03:37 -06:00
Jonathan Druart aac1aaacc9
Bug 41569: clubs - auto tidy
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:03:37 -06:00
Jonathan Druart 940d1eea6d
Bug 41569: Fix conflict with 39698
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:03:36 -06:00
Jonathan Druart 7b63190947
Bug 41569: Tidy kohaTable - clubs/clubs-tab.tt
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:03:36 -06:00
Jonathan Druart 0a1913116a
Bug 41569: Tidy kohaTable - clubs/patron-clubs-tab.tt
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:03:35 -06:00
Paul Derscheid 844bebb17c
Bug 41580: (QA follow-up) Fix variable name mismatch in batch delete records
- The tidy declared const record_type but the code references
  recordtype (no underscore), causing a ReferenceError
- Rename to match the existing usage

To test:
- Go to Tools → Batch delete records
- Upload/select bibliographic records with checked out items
- Verify the red cross and yellow highlight appear for
  non-deletable records

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:03:35 -06:00
Paul Derscheid 745d176e2f
Bug 41580: (QA follow-up) Fix suspend status check in batch modify holds
- Fix typo: hold.suspened → hold.suspended, the suspension check
  never fired because the property name was misspelled
- Restore DOM update: the tidy replaced
  \$("#new_suspend_status").val("1") with a local variable assignment
  that had no effect on the submitted form data

To test:
- Go to Tools → Batch modify holds
- Load holds that are not suspended
- Set a suspend date without changing suspend status
- Submit and verify the suspend status is automatically set to 1

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:03:34 -06:00
Paul Derscheid b536f6ef6c
Bug 41580: (QA follow-up) Fix syntax error in holidays calendar options
- The tidy introduced a semicolon inside the flatpickr options
  object literal which is a syntax error, breaking the calendar
  widget entirely
- The syntax error also prevented the auto tidy from normalizing
  the surrounding code formatting
- Replace with comma to match object property separator syntax

To test:
- Go to Tools → Calendar
- Verify the calendar widget renders without JS errors

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:03:34 -06:00
Owen Leonard 5c150230a7
Bug 41580: (follow-up) More tidy
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:03:33 -06:00
Owen Leonard 1a3927fe1e
Bug 41580: (follow-up) Fixes for errors
- In Cataloging -> Manage staged MARC records: the logic around showing
  the "Edit" button was not correct
- In Tools -> Batch patron modification: There was sometimes an error in
  the console about a variable not existing which can be resolved by
  moving the corresponding (and related) JS into the conditional which
  depends on the table of results existing.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-03-12 15:03:33 -06:00