Add WPT for multiple navigation-source attributions

We modify the store_report Python handler utility to ensure that the
take and put stash operations from multiple report POST requests cannot
be interleaved, which would cause them to clobber each other's updates.

Change-Id: I342b65ff0fb799f84766e8e9382b0d4c29af0f9e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3757905
Commit-Queue: Andrew Paseltiner <apaseltiner@chromium.org>
Reviewed-by: Nan Lin <linnan@chromium.org>
Quick-Run: Andrew Paseltiner <apaseltiner@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1023302}
diff --git a/attribution-reporting/resources/reports.py b/attribution-reporting/resources/reports.py
index 4af2b6a..5959343 100644
--- a/attribution-reporting/resources/reports.py
+++ b/attribution-reporting/resources/reports.py
@@ -69,11 +69,12 @@
 
 def store_report(stash: Stash, report: str) -> None:
   """Stores the report in the stash. Report here is a JSON."""
-  reports = stash.take(REPORTS)
-  if not reports:
-    reports = []
-  reports.append(report)
-  stash.put(REPORTS, reports)
+  with stash.lock:
+    reports = stash.take(REPORTS)
+    if not reports:
+      reports = []
+    reports.append(report)
+    stash.put(REPORTS, reports)
   return None