-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement index parameter on api/create issue #7876
Conversation
Note: I should write an integration test for this. Will do tomorrow. Changed to WIP. |
Codecov Report
@@ Coverage Diff @@
## master #7876 +/- ##
==========================================
+ Coverage 41.43% 41.47% +0.03%
==========================================
Files 478 478
Lines 63943 63945 +2
==========================================
+ Hits 26492 26518 +26
+ Misses 34001 33981 -20
+ Partials 3450 3446 -4
Continue to review full report at Codecov.
|
I feel it's dangerous to let user give an index but I haven't read the codes carefully. |
@lunny For what I've seen, there should be no side-effects. Just as @argv-minus-one, the index column is calculated from a query (
This will of course depend on the database locking model. And this is for current code. Inserting issues by explicit index will not improve or worsen this situation. Using the API to insert issues is the user's responsibility. The field is uint64, so there will be no negative values, and a
Which they should be expecting, anyway (the actual message could be different for each DB type and version). No intermediate states are kept, so the whole operation fails successfully. 😂 But!The only "danger" I can think of is if the user creates an issue with |
@guillep2k step 6 will failed because we have a unique index with Yes, an index number with 2^64-1 will broken the gitea. It's a security problem if we allow customize index number. |
@lunny The "step 6" problem is independent of this PR. I'll create an issue for it (chances are slim to reproduce this problem in a real-life scenario; even to test it). The "index == 2^64 - 1" problem is contained by allowing only admins to create issues like this; it would be their responsiblity to avoid that. With my last commit, it won't break anything; it will just prevent creating anymore issues with error "Index numbers depleted". |
Created separate issue #7887 to handle the racing condition. |
Thanks for doing this! Some problems I found/thought of:
Suggestions:
Another thing: Should non-admin users be allowed to set explicit issue numbers on repositories they own? If I'm reading the code right, only admin users are allowed to do this right now. This limits the usefulness of the feature, since non-admin users can't use it to import their issues without an admin's assistance. In Gitea 1.9.0, setting an issue number to 2^63-1 in the database blocks creation of new issues on the affected repository, but does not seem to affect the other repository I created in my test instance. Repository owners creating issue #2^63-1 would be blocking only themselves. Of course, there's the possibility of a repository owner's credentials being stolen, and an attacker creating issue #2^63-1 in order to make issue tracking permanently unusable for that repository. Since deleting issues is not allowed, only someone with direct access to the database can fix that. This could be solved by allowing repository owners to delete issues on their repositories. Is there a reason why deleting issues isn't currently allowed? |
I'll fix that.
Good catch. I'll fix that too.
It's a repository admin (e.g. owner, or member of a team with admin rights for that repo), not necessarily the site admin. As I understand it, this modification is only useful for a very small group of Gitea users so, the simpler, the better its chances of seeing the light. |
@guillep2k Maybe even repositories' admin or owner should not use this API. Only site admin. @argv-minus-one This is a http/https request, unrelated with Javascript. You can use any language which support |
@lunny perhaps some front-end will fail if Gitea provides a number larger than supported? I'm not familiar with Gitea's JS code. For instance, when the user is commenting in the issue/PR page and types In my latest commit I allow index == 2^63-1 (max int64), but in the one before it I've set it to 2^53-1 if you want to take a look. We could implement it either way. |
In fact |
@lunny I made one change after your approval. Please review again. |
Having become a bit of an expert on
So, I think this is a no-win in all cases. |
Let's close then. |
Fixes #7790.