Commit graph

54 commits

Author SHA1 Message Date
574d48362d Bug 18124: Change the calls to generate and check CSRF tokens
The parameter change in Koha::Token should be applied to the calling
scripts.

Test plan:
Confirm that the different forms of the scripts modified by this patch
still work correctly.

Test the problematic behavior:
Open 2 tabs with in same user's session, go on the edit patron page
(memberentry.pl).
Log out and log in from the other tab.
Submit the form
=> Wrong CSRF token should be raised

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2017-03-30 09:07:09 +00:00
4e40339db3 Bug 17830: CSRF - Handle unicode characters in userid
If the userid of the logged in user contains unicode characters, the token
will not be generated correctly and Koha will crash with:
  Wide character in subroutine entry at /usr/share/perl5/Digest/HMAC.pm line 63.

Test plan:
- Edit a superlibrarian user and set his/her userid to '❤' or any other strings
with unicode characters.
- Login using this patron
- Search for patrons and click on a result.

=> Without this patch, you will get a software error (with "Wide
character in subroutine entry" in the logs).
=> With this patch, everything will go fine

You can also test the other files modified by this patch.

Signed-off-by: Karam Qubsi <karamqubsi@gmail.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-12-30 17:47:18 +00:00
8edb7f6fb9 Bug 17720: CSRF - Handle unicode characters
From the pod of Digest::MD5:
"""
Since the MD5 algorithm is only defined for strings of bytes, it can not
be used on strings that contains chars with ordinal number above 255
(Unicode strings). The MD5 functions and methods will croak if you try
to feed them such input data.
What you can do is calculate the MD5 checksum of the UTF-8
representation of such strings.
"""

Test plan:
- Set a MySQL/MariaDB password with unicode characters:
  UPDATE user SET password=PASSWORD('❤') WHERE USER='koha_kohadev';
  FLUSH PRIVILEGES
- Update your $KOHA_CONF file
- Restart Memcached
- Hit the files modified by this patch

=> Without this patch, you will get a software error (with "Wide
character in subroutine entry" in the logs).
=> With this patch, everything will go fine

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Edit: removed debugging leftover

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-12-05 15:20:18 +00:00
be2b61f9e5 Bug 17146: Raise Wrong CSRF token warnin for the 'Delete' action
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-09-15 13:33:58 +00:00
11bf7e7bef Bug 17146: Fix CSRF in picture-upload.pl
If an attacker can get an authenticated Koha user to visit their page
with the
url below, they can change or delete patrons' images
/tools/picture-upload.pl?op=Delete&borrowernumber=42

Test plan:
1/ Hit /tools/picture-upload.pl?op=Delete&borrowernumber=42
And confirm that you get a "Wrong CSRF token" error
2/ Go on the patron detail page with a patron's image
3/ Click on the Delete link (note the csrf_token param)
4/ The image will be deleted and you are redirected to the patron detail
page.

Regression tests:
Upload an image from the patron detail page and from the "upload patron
images" tool.

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-09-15 13:33:58 +00:00
762415a2ff Bug 16886: Make the 'Upload patron images' tool plack safe
Some vars are accessed from subroutine, but defined with my.
It causes at least the 2 followings errors:
Variable "$filetype" is not available at
/home/koha/src/tools/picture-upload.pl line 240.
Variable "$uploadfilename" is not available at
/home/koha/src/tools/picture-upload.pl line 241.

To avoid that, they are now declared with our.

Test plan:
Upload image for a patron and confirm that you get a "Result" table and
the errors do not longer appear in the logs.

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Katrin Fischer  <katrin.fischer@bsz-bw.de>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-09-02 14:21:51 +00:00
545b64f869 Bug 15635: Koha::Patron::Images - Remove GetPatronImage
To retrieve a patron image, we can call Koha::Patron::Images->find or
Koha::Patrons->find->image
Both will return a Koha::Patron::Image object.

Test plan:
1/ From the patron/member module, open all tabs on the left (Checkouts,
detail, fines, etc.)
The image should be correctly displayed.
2/ At the OPAC, on the patron details page (opac-memberentry.pl) the
image should be displayed as well.
3/ Same on the sco module.

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-03-04 12:54:15 +00:00
85633155f4 Bug 15635: Koha::Patron::Images - Remove RmPatronImage
The C4::Members::RmPatronImage just removed a row in patronimage.
This can be accomplished using the delete method of Koha::Patron::Image.

Test plan:
From the patron defail page, try to delete the image of a patron.

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-03-04 12:53:01 +00:00
d8980b60ee Bug 15635: Koha::Patron::Images - Remove PutPatronImage
The C4::Members::PutPatronImage inserted/updated the image of a patron.
This can be done easily with ->find->set->store or ->new->store

Test plan:
1/ Modify the image of a patron from the patron detail page
2/ Add an image to a new patron
3/ Use the "Upload patron images" tools (tools/picture-upload.pl) to add
or modify the image of a patron
4/ Use the "Upload patron images" tools (tools/picture-upload.pl) to add
or modify the image of several patrons, using a zip file.
Stress the script trying to get as many errors as possible (wrong
cardnumber, wrong mimetype, file does not exist, etc.)
With this patch, if the cardnumber does not exist, you will get a
specific error "Image not imported because this patron does not exist in
the database"

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-03-04 12:53:00 +00:00
b6aa77ac49 Bug 15635: Koha::Patron::Images - Add new classes
There are 3 subroutines in C4::Members to get, add and delete patron
images:
- GetPatronImage
- PutPatronImage
- RmPatronImage

By creating these 2 Koha::Patron::Image[s] classes, we could remove them easily.

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-03-04 12:53:00 +00:00
721a77e669 Bug 14338: Unable to delete patron images
The call to RmPatronImage is still passing cardnumber as its parameter
instead of borrowernumber.

Test Plan:
1) Upload a patron image
2) Ensure the card number is not the same as the borrower number
3) Attempt to delete patron image
   -- Image will remain
4) Apply this patch
5) Attempt to delete patron image
   -- Image will be removed
6) run koha qa test tools

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
2015-06-11 10:08:59 -03:00
Jonathan Druart
ba0f84b46c Bug 9978: (followup) Replace license header with the correct license (GPLv3+)
There was another form of the v2.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
2015-04-20 09:59:43 -03:00
Jonathan Druart
e20270fec4 Bug 11944: use CGI( -utf8 ) everywhere
Signed-off-by: Paola Rossi <paola.rossi@cineca.it>
Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Signed-off-by: Dobrica Pavlinusic <dpavlin@rot13.org>

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
2015-01-13 13:07:21 -03:00
Mark Tompsett
81445f9e88 Bug 9312: Resolve error triggered by mutli-type return value.
$results is 1 upon success or a hash on failure.
Rather than check %$results || %error, I changed it to
$results!=1 || %error. Strangely, this works without
messy warnings. I believe this resolves the problem Katrin
mentions in comment #43.

TEST PLAN
---------
0) Make sure the system preference patronimages is set to Allow.
1) Apply all the patches
2) Login to staff client
3) Tools -> Upload patron images (it's in the bottom left)
4) Choose an image file, browse for a photo, enter a patron #.
5) Click Upload
6) Click the card number link
   -- the uploaded photo should be visible on the left side of
      the screen.
7) Run koha qa test tools.

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>

Image uploaded without problems
No koha-qa errors

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
2014-11-07 11:30:27 -03:00
4997454606 Bug 9312: Followup for one tab character
To satisfy qa tools, removing one tab somewhere..

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>

Sometimes our QA tools are pretty annoying, in cases like this, when its a
tab in a comment, .. I don't think we really need to hold up a patch
set for it

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
2014-11-07 11:30:23 -03:00
Galen Charlton
6f17c68a24 Bug 9312: fix a couple more uninitialized variable warnings
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
2014-11-07 11:30:21 -03:00
Fridolyn SOMERS
694b56a9ce Bug 9312: Perltidying picture-upload.pl
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
2014-11-07 11:30:19 -03:00
Fridolyn SOMERS
696c9feee2 Bug 9312: strict perl for picture-upload.pl
Testing - this is a code-cleanup patch, so the purpose
of testing is to ensure that patron image upload functionality
still works.  To test:

- Turn on the patronimages system preference
- Go to Tools | Upload patron images and import a suitable image
  for a test patron.
- Bring up the test patron and verify that the image is attached.
- From the patron details page, upload a replacement image.
- Create a patron image ZIP file containing at least two images (
  per the documentation of the patron image feature) and load it
  via the patron image import tool.
- Verfiy that the test patrons now have images.
- Verify that tools/picture-upload.pl didn't report any errors
  in the Apache error log.

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
2014-11-07 11:30:17 -03:00
afd2418d73 Bug 11349: Change .tmpl -> .tt in scripts using templates
Since we switched to Template Toolkit we don't need to stick with the
sufix we used for HTML::Template::Pro.

This patch changes the occurences of '.tmpl' in favour of '.tt'.

To test:
- Apply the patch
- Install koha, and verify that every page can be accesed

Regards
To+

P.S. a followup will remove the glue code.

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
2014-07-17 11:05:49 -03:00
09b8ce2a5f Bug 10636 - patronimage should have borrowernumber as PK, not cardnumber
Test Plan:
1) Apply this patch
2) Run updatedatabase.pl
3) Enable patronimages
4) Verify patron images are still displaying correctly
5) Test deleting a patron image
6) Test adding a patron image from moremember.pl
7) Test adding a patron image from tools/picture-upload.pl

Signed-off-by: Srdjan <srdjan@catalyst.net.nz>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
2013-10-14 21:08:02 +00:00
Jared Camins-Esakov
75703cf604 Bug 9421: tools/picture-upload.pl not Plack-compatible
This patch avoids using file-level private variables in subroutines
by passing the needed variables as parameters to the subroutines.

To test (under Plack):
1) Try uploading a patron image without applying the patch. Notice
   it fails.
2) Apply patch.
3) Try uploading a patron image again, noticing this time it succeeds.

To test (under Apache):
1) Apply patch.
2) Try uploading a patron image, confirm that it works.

Signed-off-by: Mirko Tietgen <mirko@abunchofthings.net>
Fixes Plack, does not break Apache. Works as expected.

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
2013-02-06 12:35:46 -05:00
Ivan Brown
065acad78f Bug 7643 - Can't upload and import zipped file of patron images
Fixed problem with re-declaration of $filesuffix

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
patch pushed onto master directly, doesn't merge properly from
new/bug_7643 branch
2012-10-12 16:31:46 +02:00
Colin Campbell
b5b71339f3 Bug 5453 Move declarations out of conditionals
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
2011-07-15 15:50:23 +12:00
Andrew Elwell
efa66f1f55 Bug 5385: POD Cleanups (part 2)
More podchecker cleanups to eliminate warnings / errors

Signed-off-by: Andrew Elwell <Andrew.Elwell@gmail.com>
Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
2010-11-12 10:06:56 +13:00
8eb7e1cbf7 further correction to the invocation of unzip
Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
2010-10-06 19:55:01 -04:00
Ian Walls
1125f4f432 Tighten system call to unzip
Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
2010-10-06 19:22:41 -04:00
Donovan Jones
44201a54e1 Bug 2505 - Add commented use warnings where missing in the tools/ directory 2010-04-21 20:26:38 +12:00
Chris Nighswonger
f86b788e3b Bugfix: Upping the byte size limit of patron images
This brings it more in line with the size limit placed on other images
uploaded for use on patron cards.

Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
2010-02-03 15:11:23 -05:00
Chris Nighswonger
3b1d56ccb5 [4/30] Modifications to picture upload script to accommodate image sizes up to 200 X 300 pixel dimesions.
This also changes the storage image format to PNG which is lossless (an important factor when using these
images for patroncards).

NOTE: In the end, this script was *not* used for uploading images for patron cards. However, these changes
are left as an improvement upon this script which is used for patron image uploads.

This script could be greatly reduced in size by using Graphics::Magick and working along the same lines
as the upload code found in patroncards/image-manage.pl
2010-01-11 18:16:17 -05:00
Ryan Higgins
04c4be5b48 Bug 2622 & 2623 : tools permissions for edit notice triggers and picture upload overly restrictive
removing requirements for parameters &  management respectively for these two tools.

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
2008-10-16 14:47:31 -05:00
Chris Nighswonger
1baf6348cc kohabug 2404 This patch removes Image::Magick and adds GD
This patch removes Image::Magick as a dependency and replaces it with
the (much) lighter GD. Functionality of patronimage code has not changed with
this conversion.

Adding errorhandling for corrupted image file and link to return to moremember.pl when called from there

Added notes about supported image mime types.

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
2008-07-30 03:38:18 -05:00
Chris Nighswonger
af288205f5 kohabug 2154 Modifying form input controls to accomodate translations
Due to the logic of the underlying picture-upload.pl depending upon the "value" of the
form input controls and this value being translated, the script then failed to function.
This patch changes the input controls so that this should not be an issue.

This issue should be kept in mind, though, so that it can be avoided in the future.

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
2008-07-25 08:56:10 -05:00
Chris Nighswonger
e15e2f9118 Bugfix: Handling cases where the image is the correct pixel dimensions
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
2008-04-11 16:54:54 -05:00
Galen Charlton
fc6ccb1a61 granular permissions - updated Tools
Updated all scripts appearing on the tools page
to respect a granular permission defined for
each of them.

The tools menu and home page have been changed so
that only the specific tools that a user has
access are displayed.  This is simple, but depending on
the module and circumstance, it may be better to
display functions that the user has does not have
access to, but disable the links and do some sort
of visual styling to indicate that a function exists
but requires additional privileges to access.

Signed-off-by: Joshua Ferraro <jmf@liblime.com>
2008-04-10 15:53:30 -05:00
Chris Nighswonger
7fbcb6a784 Bugfix: Correcting misspelled variable
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
2008-04-10 02:59:22 -05:00
Chris Nighswonger
a16d450555 Adding use of C4::Debug for debugging
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
2008-04-10 02:59:21 -05:00
Chris Nighswonger
9a55637760 NOTE: REQUIRES INSTALLATION OF Image::Magick; Adding image scaling/resizing capability to picture-upload.pl
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
2008-04-08 17:00:05 -05:00
Chris Nighswonger
b626a8bb9a Adding file size limit to picture-upload.pl
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
2008-04-01 06:44:17 -05:00
Chris Nighswonger
55b353f79a Adding Update/Delete functions to patron image management on Details page
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
2008-03-06 12:14:44 -06:00
Chris Nighswonger
cbc5bbccdd Correction to handle errors processing image file passed in from the patron details screen.
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
2008-03-06 06:25:15 -06:00
Chris Nighswonger
6b89cda969 Completing adding patronimage upload form to patron details screen.
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
2008-03-06 06:25:13 -06:00
bfbae81162 Some changes related to recent commits to patron images: Markup and javascript changes for upload form; Enabling passing of cardnumber and filetype variable to picture upload form; changes to picture display to handle missing image; Adding link to picture upload form from missing image display in circ and moremember; Removal of English text from 'no patron image' file.
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
2008-02-27 09:02:37 -06:00
Chris Nighswonger
9771c038b0 Bugfix: Removing Dumper() call
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
2008-02-23 11:08:43 -06:00
Chris Nighswonger
de1754d68d Third installment on moving patronimages into the database.
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
2008-02-23 10:55:44 -06:00
Chris Nighswonger
06575bbcb8 Fixing error trap routine in picture-upload.pl
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
2008-02-23 10:55:43 -06:00
Chris Nighswonger
4b232a0c36 Second installment on moving patronimages into the database
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
2008-02-23 10:55:41 -06:00
Chris Nighswonger
1c1cb10e5e First installment on moving patronimages into the database.
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
2008-02-23 10:55:37 -06:00
Chris Nighswonger
e4b90465a8 Second fix for bug 1848 correcting bad conditional
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
2008-02-20 05:41:39 -06:00
Chris Nighswonger
5e90496cad Making picture-upload.pl case insensitive when looking for DATALINK.TXT or IDLINK.TXT
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
2008-02-18 16:44:04 -06:00
Chris Nighswonger
a0b51ee25f Correcting DEBUG var
Signed-off-by: Chris Cormack <crc@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
2008-02-03 07:23:46 -06:00