Opened 18 years ago
Closed 18 years ago
#3679 closed enhancement (fixed)
Validate ticket "select" fields
Reported by: | Matthew Good | Owned by: | Christian Boos |
---|---|---|---|
Priority: | highest | Milestone: | 0.10 |
Component: | ticket system | Version: | devel |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
The spammers seem to have grown fond of submitting tickets with a blank "type". It may be good to start validating that the values submitted for "select" fields actually contain a valid value. This component provides that basic functionality:
class FieldOptionsValidator(Component): implements(ITicketManipulator) def prepare_ticket(self, req, ticket, fields, action): pass def validate_ticket(self, req, ticket): for field in ticket.fields: if 'options' not in field: continue value = ticket[field['name']] if value not in field['options']: yield field['name'], '"%s" is not a valid value' % value
If it's too close to the 0.10 release to add this maybe we can stick it in the SpamFilter since that seems to be it's main purpose ATM.
Attachments (2)
Change History (13)
comment:1 by , 18 years ago
Milestone: | → 0.10 |
---|---|
Owner: | changed from | to
Priority: | normal → high |
Version: | 0.9.6 → devel |
follow-up: 3 comment:2 by , 18 years ago
I definitely agree with the idea, but don't see why that validation logic should be in a separate component. If that's just to share between TicketModule
/NewticketModule
, we could simply add the code to TicketModuleBase._validate_ticket()
, no?
follow-ups: 4 6 comment:3 by , 18 years ago
Owner: | changed from | to
---|
Replying to cmlenz:
I definitely agree with the idea, but don't see why that validation logic should be in a separate component. If that's just to share between
TicketModule
/NewticketModule
, we could simply add the code toTicketModuleBase._validate_ticket()
, no?
Yes, it would work there, but I was figuring that it should use the validation API in case some other component would want to use the validation in the future.
cboos: I don't understand why you assigned this to yourself. I guess I should've set myself as the owner when I created it, but I don't think you need to take it over.
comment:4 by , 18 years ago
Replying to mgood:
cboos: I don't understand why you assigned this to yourself. I guess I should've set myself as the owner when I created it, but I don't think you need to take it over.
As the owner was jonas, it wasn't obvious that you intended to complete the implementation yourself, so I volunteered to finish it. No harm done, I hope ;)
comment:6 by , 18 years ago
Priority: | high → highest |
---|
See #1744 recent changes and there are lots of similar spam that could have been prevented by the above changes. I'll propose an updated patch shortly, as I think we need this to get done for 0.10 and tested a.s.a.p on t.e.o before the release.
by , 18 years ago
Attachment: | always_validate_fields-r3739.patch added |
---|
Moved the validation of ticket fields in TicketModuleBase._validate_ticket
follow-up: 9 comment:7 by , 18 years ago
Please double check that everything is OK with attachment:always_validate_fields-r3739.patch, so that we can integrate it and upgrade.
One issue I've come across with this change however was that if Trac is configured with
[ticket] restrict_owner = true
then an attempt to modify a ticket assigned to someone being no longer a valid owner will fail. Not an issue with t.e.o, but must be addressed before 0.10.
comment:8 by , 18 years ago
Keywords: | review added |
---|
by , 18 years ago
Attachment: | validate_field_options.patch added |
---|
skips validation on unmodified fields
comment:9 by , 18 years ago
Replying to cboos:
One issue I've come across with this change however was that if Trac is configured with
[ticket] restrict_owner = truethen an attempt to modify a ticket assigned to someone being no longer a valid owner will fail. Not an issue with t.e.o, but must be addressed before 0.10.
The new patch I attached should fix that since it skips validation on fields that were unmodified. I had to move the validation check after the processing of the "Action" items, since otherwise it didn't check changes to the owner.
comment:10 by , 18 years ago
Owner: | changed from | to
---|
cboos: I think this is ok, so unless someone else finds a bug, go ahead and commit it.
comment:11 by , 18 years ago
Keywords: | review removed |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Well, spammers will quickly learn to get around that, but OTOH I don't see in which case it would make sense to accept invalid field values, so my take would be to put it in trunk, for milestone:0.10 as the lack of checking looks more like a defect to me.
I tested the
FieldOptionsValidator
and had to make a few changes in order to make it work, please test further.