diff --git a/.gitignore b/.gitignore index 477cd785c0072721008da2f85ccfa2c14f31d05b..14982fa1d6b8456ee4b58a04f2f4c9ad1264993a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ bootstrap.json coverage.xml /htmlcov node_modules/ +/bin/accesslog.csv diff --git a/api/handlers/reporthandler.py b/api/handlers/reporthandler.py index dd7210729a2793efcd8dbf5d69ab044f6137c9fb..f935f0e2588ecce56872c3357c9a98fa62bc11aa 100644 --- a/api/handlers/reporthandler.py +++ b/api/handlers/reporthandler.py @@ -522,6 +522,8 @@ class AccessLogReport(Report): raise APIReportParamsException('Limit must be an integer greater than 0.') if limit < 1: raise APIReportParamsException('Limit must be an integer greater than 0.') + elif limit > 10000: + raise APIReportParamsException('Limit exceeds 10,000 entries, please contact admin to run script.') for access_type in access_types: if access_type not in AccessTypeList: raise APIReportParamsException('Not a valid access type') diff --git a/test/integration_tests/python/test_reports.py b/test/integration_tests/python/test_reports.py index d3cfa0b742eef69b80db3248e159156e5b6a9df3..17ba54e1de3f59cea6f408201ab927292a05b6f5 100644 --- a/test/integration_tests/python/test_reports.py +++ b/test/integration_tests/python/test_reports.py @@ -116,6 +116,12 @@ def test_access_log_report(data_builder, with_user, as_user, as_admin): r = as_admin.get('/report/accesslog', params={'limit': 0}) assert r.status_code == 400 + # try to get report w/ limit == 1000 and limit > 1000 + r = as_admin.get('/report/accesslog', params={'limit': 10000}) + assert r.ok + r = as_admin.get('/report/accesslog', params={'limit': 10001}) + assert r.status_code == 400 + # get access log report for user r = as_admin.get('/report/accesslog', params={ 'start_date': yesterday_ts, 'end_date': tomorrow_ts, 'user': with_user.user