fix issues raised by bandit
This commit is contained in:
parent
78013ed1e9
commit
2c4d6b9f63
|
@ -63,8 +63,9 @@ def decompose_interval(attrname):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
value = int(value)
|
value = int(value)
|
||||||
assert value >= 0
|
if not value >= 0:
|
||||||
except (ValueError, AssertionError) as e:
|
raise ValueError(value)
|
||||||
|
except ValueError as e:
|
||||||
raise ValueError("Incorrect time interval", e)
|
raise ValueError("Incorrect time interval", e)
|
||||||
setattr(self, attrname, value * getattr(self, scl_name))
|
setattr(self, attrname, value * getattr(self, scl_name))
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,9 @@ def twitter_login_step2():
|
||||||
except (TwitterError, URLError):
|
except (TwitterError, URLError):
|
||||||
return redirect(url_for('index', twitter_login_error='', _anchor='log_in'))
|
return redirect(url_for('index', twitter_login_error='', _anchor='log_in'))
|
||||||
|
|
||||||
|
class TweetArchiveEmptyException(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
@app.route('/upload_tweet_archive', methods=('POST',))
|
@app.route('/upload_tweet_archive', methods=('POST',))
|
||||||
@limiter.limit('10/10 minutes')
|
@limiter.limit('10/10 minutes')
|
||||||
@require_auth
|
@require_auth
|
||||||
|
@ -111,14 +114,15 @@ def upload_tweet_archive():
|
||||||
ta.chunks = len(files)
|
ta.chunks = len(files)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
assert ta.chunks > 0
|
if not ta.chunks > 0:
|
||||||
|
raise TweetArchiveEmptyException()
|
||||||
|
|
||||||
for filename in files:
|
for filename in files:
|
||||||
tasks.import_twitter_archive_month.s(ta.id, filename).apply_async()
|
tasks.import_twitter_archive_month.s(ta.id, filename).apply_async()
|
||||||
|
|
||||||
|
|
||||||
return redirect(url_for('index', _anchor='recent_archives'))
|
return redirect(url_for('index', _anchor='recent_archives'))
|
||||||
except (BadZipFile, AssertionError):
|
except (BadZipFile, TweetArchiveEmptyException):
|
||||||
return redirect(url_for('index', tweet_archive_failed='', _anchor='tweet_archive_import'))
|
return redirect(url_for('index', tweet_archive_failed='', _anchor='tweet_archive_import'))
|
||||||
|
|
||||||
@app.route('/settings', methods=('POST',))
|
@app.route('/settings', methods=('POST',))
|
||||||
|
|
2
tasks.py
2
tasks.py
|
@ -179,7 +179,7 @@ def delete_from_account(account_id):
|
||||||
account.touch_delete()
|
account.touch_delete()
|
||||||
action(post)
|
action(post)
|
||||||
else:
|
else:
|
||||||
post = random.choice(eligible)
|
post = random.choice(eligible) # nosec
|
||||||
print("deleting {}".format(post))
|
print("deleting {}".format(post))
|
||||||
account.touch_delete()
|
account.touch_delete()
|
||||||
action(post)
|
action(post)
|
||||||
|
|
Loading…
Reference in New Issue