Add limits for action functions v2#4484
Conversation
…to be a slip so I fixed.
|
|
||
| params['rows'] = min( | ||
| int(params.get('rows', 10)), | ||
| int(config.get('ckan.search.rows_max', 1000))) |
There was a problem hiding this comment.
I needed to add limit here, because it bypasses the logic function and therefore the validator (which now does the limiting when calling package_search)
e19c3db to
f7f081e
Compare
|
@wardi it would be great to get this merged, if you have a chance to review? |
|
Well done! This change was sorely needed. |
* Add download dropdown * [ckan#4497] connect js, route, form * [ckan#4497] implement download redirect * [ckan#4497] unicode literal * use request.params for 2.7 compatibility * [ckan#4462] _get_types: pass connection instead of context * [ckan#4462] _get_type: pass connection instead of context * [ckan#4462] _get_fields: pass connection, resource_id instead of context, data_dict * [ckan#4462] _get_fields_types: pass connection, resource_id instead of context, data_dict * [ckan#4462] datastore_search: partial result fields fix * [ckan#4462] fix reuse of variable name * [ckan#4462] _textsearch_query: lang, q, plain instead of data_dict * [ckan#4462] datastore_search: exclude rank columns if not in fields * [ckan#4462] _result_fields: remove unused parameter * revert string_types change * revert string_types change * Get visible columns * [ckan#4497] download visible columns * Remove _id column from filtered download * [ckan#4462] _textsearch_query: lang, q, plain instead of data_dict * [ckan#4497] s/const/var for js compatibility * [ckan#4484] manually backported to ckan 2.7.x (#8) Add limits for action functions * Add limits to datastore_search(_sql) (#16) * Backport of 4561-limit-datastore_search 74d8fb2 * CircleCI update from master * Nop * Fix tests for opengov branch The _id column is removed from datastore dumps in this opengov branch because: opengov commit: co0adf16426113394af42bbacc4644f039ebe9e2ec + field_list = [f['id'] for f in rec['fields'] if f['id'] != '_id'] also some minor fixes * Use pop() for efficiency
* Add download dropdown * [ckan#4497] connect js, route, form * [ckan#4497] implement download redirect * [ckan#4497] unicode literal * use request.params for 2.7 compatibility * [ckan#4462] _get_types: pass connection instead of context * [ckan#4462] _get_type: pass connection instead of context * [ckan#4462] _get_fields: pass connection, resource_id instead of context, data_dict * [ckan#4462] _get_fields_types: pass connection, resource_id instead of context, data_dict * [ckan#4462] datastore_search: partial result fields fix * [ckan#4462] fix reuse of variable name * [ckan#4462] _textsearch_query: lang, q, plain instead of data_dict * [ckan#4462] datastore_search: exclude rank columns if not in fields * [ckan#4462] _result_fields: remove unused parameter * revert string_types change * revert string_types change * Get visible columns * [ckan#4497] download visible columns * Remove _id column from filtered download * [ckan#4462] _textsearch_query: lang, q, plain instead of data_dict * [ckan#4497] s/const/var for js compatibility * [ckan#4484] manually backported to ckan 2.7.x (#8) Add limits for action functions * Add limits to datastore_search(_sql) (#16) * Backport of 4561-limit-datastore_search 74d8fb2 * CircleCI update from master * Nop * Fix tests for opengov branch The _id column is removed from datastore dumps in this opengov branch because: opengov commit: co0adf16426113394af42bbacc4644f039ebe9e2ec + field_list = [f['id'] for f in rec['fields'] if f['id'] != '_id'] also some minor fixes * Use pop() for efficiency
|
@ThrawnCA I have sympathy for this point of view - it does break functionality. However we were keen to add it as a patch for earlier versions, because it was seen as a DOS vector. The default limits are so low, as to try and make it obvious they are limited. |
That's a nice thought, but since it still truncates silently, and still allows enough to eg populate a dropdown list enough to need significant scrolling down, it really isn't obvious unless someone was already specifically looking for it. |
|
Agreed, it's problematic for the use case you describe. We had some awareness of this sort of thing when we designed it, balanced against the other concerns mentioned. The questions are whether that balance is wrong and what might be done now. |
Fixes #4480
Limits added
This PR adds limits to the following logic functions, configurable with the given configuration option:
ckan.search.rows_maxckan.search.rows_maxckan.group_and_organization_list_max/ckan.group_and_organization_list_all_fields_maxckan.activity_list_limit_maxckan.activity_list_limit_maxckan.activity_list_limit_maxI've also done a backport for CKAN 2.7, should anyone want to apply it to their own ckan fork:
2.7...4484-limits-backport-2.7
Features:
Please [X] all the boxes above that apply