Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved UID check in API #772

Merged
merged 2 commits into from
Apr 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Changelog

**Fixed**

- #772 Improved UID check in API


**Security**

Expand Down
6 changes: 6 additions & 0 deletions bika/lims/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# Copyright 2018 by it's authors.
# Some rights reserved. See LICENSE.rst, CONTRIBUTORS.rst.

import re

from Acquisition import aq_base
from AccessControl.PermissionRole import rolesForPermissionOn

Expand Down Expand Up @@ -67,6 +69,8 @@

_marker = object()

UID_RX = re.compile("[a-z0-9]{32}$")


class BikaLIMSError(Exception):
"""Base exception class for bika.lims errors."""
Expand Down Expand Up @@ -1161,6 +1165,8 @@ def is_uid(uid, validate=False):
return False
if len(uid) != 32:
return False
if not UID_RX.match(uid):
return False
if not validate:
return True

Expand Down