diff options
Diffstat (limited to 'ishtar_common/views_item.py')
| -rw-r--r-- | ishtar_common/views_item.py | 16 | 
1 files changed, 10 insertions, 6 deletions
diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py index 5947a6798..b2b924992 100644 --- a/ishtar_common/views_item.py +++ b/ishtar_common/views_item.py @@ -9,7 +9,8 @@ import json  import logging  import re  import requests -import subprocess +# nosec: no user input used +import subprocess  # nosec  from tempfile import NamedTemporaryFile  import unidecode @@ -405,12 +406,13 @@ def show_item(model, name, extra_dct=None, model_for_perms=None):                      dct["IS_HISTORY"] = True                      if item.get_last_history_date() != date:                          item = item.get_previous(date=date) -                        assert item is not None +                        if item is None: +                            raise ValueError("No previous history entry.")                          dct["previous"] = item._previous                          dct["next"] = item._next                      else:                          date = None -                except (ValueError, AssertionError): +                except ValueError:                      return HttpResponse("", content_type="text/plain")              if not date:                  historized = item.history.all() @@ -466,7 +468,8 @@ def show_item(model, name, extra_dct=None, model_for_perms=None):                  html_source.name,              ]              try: -                subprocess.check_call( +                # nosec: no user input +                subprocess.check_call(  # nosec                      pandoc_args, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL                  )              except subprocess.CalledProcessError: @@ -1011,7 +1014,7 @@ def _manage_facet_search(model, dct, and_reqs):                  rel = getattr(model, base_k).field.related_model                  if not hasattr(rel, "label") and hasattr(rel, "cached_label"):                      lbl_name = "__cached_label__" -            except: +            except AttributeError:                  pass              suffix = (                  "{}icontains".format(lbl_name) @@ -2311,7 +2314,8 @@ def get_item(              try:                  start = int(request_items.get("start"))                  page_nb = start // row_nb + 1 -                assert page_nb >= 1 +                if page_nb < 1: +                    raise ValueError("Page number is not relevant.")              except (TypeError, ValueError, AssertionError):                  start = 0                  page_nb = 1  | 
