Bug 37961 - Inventory followup fails by POSTing without an op or csrf_token
Summary: Inventory followup fails by POSTing without an op or csrf_token
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Tools (show other bugs)
Version: Main
Hardware: All All
: P1 - high major
Assignee: Phil Ringnalda
QA Contact: Kyle M Hall (khall)
URL:
Keywords: regression
: 38250 (view as bug list)
Depends on: 36192
Blocks:
  Show dependency treegraph
 
Reported: 2024-09-19 03:35 UTC by Phil Ringnalda
Modified: 2024-10-23 21:49 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.11.00,24.05.05
Circulation function:


Attachments
Bug 37961: Inventory problem resolution fails by POSTing without an op or csrf_token (4.29 KB, patch)
2024-09-19 04:53 UTC, Phil Ringnalda
Details | Diff | Splinter Review
Bug 37961: Inventory problem resolution fails by POSTing without an op or csrf_token (4.34 KB, patch)
2024-09-27 18:24 UTC, Sonia Bouis
Details | Diff | Splinter Review
Bug 37961: Inventory problem resolution fails by POSTing without an op or csrf_token (4.42 KB, patch)
2024-09-27 20:51 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Phil Ringnalda 2024-09-19 03:35:49 UTC
After you upload a file or textarea of barcodes to inventory, the next step is a list of the things that were missing, with checkboxes to check when you find them, and buttons to Mark seen, which send a POST to /cgi-bin/koha/tools/ajax-inventory.pl without an op param (since it doesn't have an $op) and without a csrf_token, so the POST fails with a 403.
Comment 1 Phil Ringnalda 2024-09-19 04:53:20 UTC
Created attachment 171700 [details] [review]
Bug 37961: Inventory problem resolution fails by POSTing without an op or csrf_token

After you upload a file or textarea of barcodes to inventory, the next step is
a list of the things that were missing, with checkboxes to check when you find
them, and buttons to Mark seen, which send a POST to
/cgi-bin/koha/tools/ajax-inventory.pl without an op param (since it doesn't
have an $op) and without a csrf_token, so the POST fails with a 403.

Test plan:
 1. Without the patch, Cataloging - Inventory - in Item location filters
    set Library to Centerville, Shelving location to Audio visual, Collection
    code to Reference, and in Optional filters for inventory list or comparing
    barcodes set Last inventory date to today.
 2. Click Submit, and you'll have a table of 23 items. Check the checkbox for
    the first item, click Mark seen and continue
 3. What was supposed to happen was that you would be taken to the next
    page, but instead you are still in the same page, and if you had the
    browser console open, you would have seen that you sent a POST to
    ajax-inventory.pl, and got a 403 error in response
 4. Apply patch, restart_all
 5. Repeat step 1 and 2, this time getting to the second page. Check the
    checkboxes for the last two items, and click Mark seen and quit
 6. Repeat step 1 and click Submit. You should now have only 20 items, since
    the three you checked now have a Last inventory date of today.

Yeah, when you did Mark seen and continue they ought to have been removed from
the list, I agree. I had to go back to 23.11.x and make sure that was really
how it was supposed to function, but that is the existing behavior. Even
though they get marked as seen, nothing changes about your list until you quit
and go back to it. Maybe because then something that wasn't on the current
page would have moved there. Another bug.

Sponsored-by: Chetco Community Public Library
Comment 2 Sonia Bouis 2024-09-27 16:13:32 UTC
Hi,
I 've tested without the patch and I can see that we are stucked in the list of items even when we tick one of them and click on "mark seen and continue", it's the same page and nothing happen. But I have exactly the same behaviour after installing the patch :(

Sonia
Comment 3 Phil Ringnalda 2024-09-27 16:45:05 UTC
That's odd, I just tried it myself and it still works for me.

Do you have more than 20 items, so there's a second page to go to when you check the first item and Mark seen and continue? That button is still present and enabled even when there isn't another page to continue to, so on the last page it will look like nothing happened.

If you open the browser console, does it show any error when you Mark seen and continue?
Comment 4 Sonia Bouis 2024-09-27 18:24:38 UTC
Created attachment 172150 [details] [review]
Bug 37961: Inventory problem resolution fails by POSTing without an op or csrf_token

After you upload a file or textarea of barcodes to inventory, the next step is
a list of the things that were missing, with checkboxes to check when you find
them, and buttons to Mark seen, which send a POST to
/cgi-bin/koha/tools/ajax-inventory.pl without an op param (since it doesn't
have an $op) and without a csrf_token, so the POST fails with a 403.

Test plan:
 1. Without the patch, Cataloging - Inventory - in Item location filters
    set Library to Centerville, Shelving location to Audio visual, Collection
    code to Reference, and in Optional filters for inventory list or comparing
    barcodes set Last inventory date to today.
 2. Click Submit, and you'll have a table of 23 items. Check the checkbox for
    the first item, click Mark seen and continue
 3. What was supposed to happen was that you would be taken to the next
    page, but instead you are still in the same page, and if you had the
    browser console open, you would have seen that you sent a POST to
    ajax-inventory.pl, and got a 403 error in response
 4. Apply patch, restart_all
 5. Repeat step 1 and 2, this time getting to the second page. Check the
    checkboxes for the last two items, and click Mark seen and quit
 6. Repeat step 1 and click Submit. You should now have only 20 items, since
    the three you checked now have a Last inventory date of today.

Yeah, when you did Mark seen and continue they ought to have been removed from
the list, I agree. I had to go back to 23.11.x and make sure that was really
how it was supposed to function, but that is the existing behavior. Even
though they get marked as seen, nothing changes about your list until you quit
and go back to it. Maybe because then something that wasn't on the current
page would have moved there. Another bug.

Sponsored-by: Chetco Community Public Library
Signed-off-by: Sonia Bouis <sonia.bouis@univ-lyon3.fr>
Comment 5 Sonia Bouis 2024-09-27 18:33:58 UTC
Oh sorry, my fault. I've few data in my ktd database and I didn't see that there are less than 20.

So I tested with more than 20 items in the results and it actually changes to the second page when we click on "click Mark seen and continue".

I know it have to be in another bug, but I would be better if the button "click Mark seen and continue" doesn't appear if there are less than 20 items.

Sonia
Comment 6 Kyle M Hall (khall) 2024-09-27 20:51:36 UTC
Created attachment 172183 [details] [review]
Bug 37961: Inventory problem resolution fails by POSTing without an op or csrf_token

After you upload a file or textarea of barcodes to inventory, the next step is
a list of the things that were missing, with checkboxes to check when you find
them, and buttons to Mark seen, which send a POST to
/cgi-bin/koha/tools/ajax-inventory.pl without an op param (since it doesn't
have an $op) and without a csrf_token, so the POST fails with a 403.

Test plan:
 1. Without the patch, Cataloging - Inventory - in Item location filters
    set Library to Centerville, Shelving location to Audio visual, Collection
    code to Reference, and in Optional filters for inventory list or comparing
    barcodes set Last inventory date to today.
 2. Click Submit, and you'll have a table of 23 items. Check the checkbox for
    the first item, click Mark seen and continue
 3. What was supposed to happen was that you would be taken to the next
    page, but instead you are still in the same page, and if you had the
    browser console open, you would have seen that you sent a POST to
    ajax-inventory.pl, and got a 403 error in response
 4. Apply patch, restart_all
 5. Repeat step 1 and 2, this time getting to the second page. Check the
    checkboxes for the last two items, and click Mark seen and quit
 6. Repeat step 1 and click Submit. You should now have only 20 items, since
    the three you checked now have a Last inventory date of today.

Yeah, when you did Mark seen and continue they ought to have been removed from
the list, I agree. I had to go back to 23.11.x and make sure that was really
how it was supposed to function, but that is the existing behavior. Even
though they get marked as seen, nothing changes about your list until you quit
and go back to it. Maybe because then something that wasn't on the current
page would have moved there. Another bug.

Sponsored-by: Chetco Community Public Library
Signed-off-by: Sonia Bouis <sonia.bouis@univ-lyon3.fr>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 7 Martin Renvoize (ashimema) 2024-09-30 14:34:20 UTC
Thanks for all the hard work!

Pushed to main for the next 24.11.00 release as RM Assistant
Comment 8 Lucas Gass (lukeg) 2024-10-09 21:54:48 UTC
Backported to 24.05.x for upcoming 24.05.05
Comment 9 Fridolin Somers 2024-10-21 13:25:04 UTC
Not for 23.11.x
Comment 10 Phil Ringnalda 2024-10-23 21:49:29 UTC
*** Bug 38250 has been marked as a duplicate of this bug. ***