Bugzilla – Attachment 126432 Details for
Bug 29264
SIP config allows use of non-branchcode institution ids causes workers to die without responding
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29264: SIP config allows use of non-branchcode institution ids causes workers to die without responding
Bug-29264-SIP-config-allows-use-of-non-branchcode-.patch (text/plain), 2.90 KB, created by
Kyle M Hall (khall)
on 2021-10-18 12:32:06 UTC
(
hide
)
Description:
Bug 29264: SIP config allows use of non-branchcode institution ids causes workers to die without responding
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2021-10-18 12:32:06 UTC
Size:
2.90 KB
patch
obsolete
>From 8a56be522c9f54ec790b4b0cf41153ea48153378 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Mon, 18 Oct 2021 12:28:27 +0000 >Subject: [PATCH] Bug 29264: SIP config allows use of non-branchcode > institution ids causes workers to die without responding > >If is entirely possible to create an SIP institution whose ID does not match a valid branchcode in Koha's SIP config. In fact, Koha's example SIP config contains an example of this ( kohalibrary / kohalibrary2 ). > >If a SIP login uses an institution with an id that doesn't match a valid branchcode, everything will appear to work, but the SIP worker will die anywhere that Koha gets the branch from the userenv and assumes it is valid. > >The repercussions of this are that actions such as the checkout message simply die and do not return a response message to the requestor. > >At the very least, we should output a warning to the SIP log. > >I think we should strongly consider disallowing institution ids in the SIP config that do not match valid branchcodes. In this scenario, attempting to start the SIP server should result in a error message with the SIP server exiting immediately. > >Test Plan: >1) Apply this patch >2) Make a sip login that uses an instution whose id is *not* a valid branchcode >3) Start the SIP server >4) Check sip.log, you should see a warning similar to the following: >[2021/10/18 12:18:29] [2068079] [ERROR] ERROR: Institution kohalibrary does does not match a branchcode. This can cause unexpected behavior. C4::SIP::Sip::siplog /kohadevbox/koha/C4/SIP/Sip.pm (220) >--- > C4/SIP/SIPServer.pm | 3 +++ > C4/SIP/Sip/Configuration.pm | 8 ++++++++ > 2 files changed, 11 insertions(+) > >diff --git a/C4/SIP/SIPServer.pm b/C4/SIP/SIPServer.pm >index f1c1ae448b3..3bb7301a54d 100644 >--- a/C4/SIP/SIPServer.pm >+++ b/C4/SIP/SIPServer.pm >@@ -30,6 +30,9 @@ use base qw(Net::Server::PreFork); > > use constant LOG_SIP => "local6"; # Local alias for the logging facility > >+ >+set_logger( Koha::Logger->get( { interface => 'sip' } ) ); >+ > # > # Main # not really, since package SIPServer > # >diff --git a/C4/SIP/Sip/Configuration.pm b/C4/SIP/Sip/Configuration.pm >index 3f5bdaaa4bd..006d6b5cf33 100644 >--- a/C4/SIP/Sip/Configuration.pm >+++ b/C4/SIP/Sip/Configuration.pm >@@ -9,8 +9,10 @@ package C4::SIP::Sip::Configuration; > use strict; > use warnings; > use XML::Simple qw(:strict); >+use List::Util qw(uniq); > > use C4::SIP::Sip qw(siplog); >+use Koha::Libraries; > > my $parser = XML::Simple->new( > KeyAttr => { >@@ -47,6 +49,12 @@ sub new { > } > $cfg->{listeners} = \%listeners; > >+ my @branchcodes = Koha::Libraries->search()->get_column('branchcode'); >+ my @institutions = uniq( keys %{ $cfg->{institutions} } ); >+ foreach my $i ( @institutions ) { >+ siplog("LOG_ERR", "ERROR: Institution $i does does not match a branchcode. This can cause unexpected behavior.") unless grep( /^$i$/, @branchcodes ); >+ } >+ > return bless $cfg, $class; > } > >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29264
:
126432
|
127425
|
127606