Skip to content

Commit a732a50

Browse files
authored
also check policy on key updates
so far, the policy was only checked when adding new entries. now the policy is also checked when updating entries. otherwise it is easy to get non-policy conforming entries into the database
1 parent 5368288 commit a732a50

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

server.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,13 @@ def replace_entry(key):
249249
if not ok:
250250
return jsonify(reason)
251251

252+
if policy and "force" not in request.json:
253+
accept, reason = policy.check(request.json["entry"], bib_database.entries)
254+
if not accept:
255+
entry = request.json["entry"]
256+
entry["reason"] = reason
257+
return jsonify({"success": False, "reason": "policy", "entries": [entry]})
258+
252259
for (idx, entry) in enumerate(bib_database.entries):
253260
if entry["ID"] == key:
254261
bib_database.entries[idx] = request.json["entry"]

0 commit comments

Comments
 (0)