From 18cf79c3889e14b4140d5acff8db6ae3e03d7536 Mon Sep 17 00:00:00 2001 From: Adam Rauch Date: Tue, 28 Jul 2026 14:31:10 -0700 Subject: [PATCH 1/2] Parse report-to CSP reports --- src/org/labkey/test/util/CspLogUtil.java | 31 ++++++++++++------------ 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/org/labkey/test/util/CspLogUtil.java b/src/org/labkey/test/util/CspLogUtil.java index d3b2b01262..d98da24d4b 100644 --- a/src/org/labkey/test/util/CspLogUtil.java +++ b/src/org/labkey/test/util/CspLogUtil.java @@ -41,8 +41,8 @@ public class CspLogUtil { private static final List ignoredViolations = List.of( - "/_rstudio/", - "/_rstudioReport/" + "/_rstudio/", + "/_rstudioReport/" ); private static final Set ignoredDirectives = Collections.emptySet(); @@ -124,7 +124,7 @@ public static void checkNewCspWarnings(ArtifactCollector artifactCollector) } boolean foundVioloation = false; - MultiValuedMap violoations = new HashSetValuedHashMap<>(); + MultiValuedMap violations = new HashSetValuedHashMap<>(); List cspReports = new ArrayList<>(); StringBuilder sb = new StringBuilder(); for (String line : warningLines) @@ -148,7 +148,7 @@ public static void checkNewCspWarnings(ArtifactCollector artifactCollector) for (CspReport cspReport : cspReports) { - String url = cspReport.getDocumentUri(); + String url = cspReport.getDocumentUrl(); String violatedDirective = cspReport.getViolatedDirective(); if (ignoredViolations.stream().anyMatch(url::contains) || ignoredDirectives.contains(violatedDirective)) { @@ -157,20 +157,20 @@ public static void checkNewCspWarnings(ArtifactCollector artifactCollector) else { Crawler.ControllerActionId actionId = new Crawler.ControllerActionId(url); - violoations.put(actionId, cspReport.toString()); + violations.put(actionId, cspReport.toString()); } } - if (!violoations.isEmpty()) + if (!violations.isEmpty()) { StringBuilder errorMessage = new StringBuilder() .append("Detected CSP violations on the following actions (See log for more detail: ") .append(recentWarningsFile.getAbsolutePath()) .append("):"); - for (Crawler.ControllerActionId actionId : violoations.keySet()) + for (Crawler.ControllerActionId actionId : violations.keySet()) { errorMessage.append("\n\t"); - Collection urls = violoations.get(actionId); + Collection urls = violations.get(actionId); errorMessage.append(actionId); if (urls.size() > 1) { @@ -221,13 +221,14 @@ public CspWarningDetectedException(Object detailMessage) class CspReport { private final String _violatedDirective; - private final String _documentUri; + private final String _documentUrl; CspReport(String reportStr) { - JSONObject report = new JSONObject(reportStr).getJSONObject("csp-report"); - _violatedDirective = report.getString("violated-directive"); - _documentUri = report.getString("document-uri"); + // Support report-to reports only. GitHub Issue #900 + JSONObject report = new JSONObject(reportStr).getJSONObject("body"); + _violatedDirective = report.getString("effectiveDirective"); + _documentUrl = report.getString("documentURL"); } public String getViolatedDirective() @@ -235,14 +236,14 @@ public String getViolatedDirective() return _violatedDirective; } - public String getDocumentUri() + public String getDocumentUrl() { - return _documentUri; + return _documentUrl; } @Override public String toString() { - return getViolatedDirective() + ": " + getDocumentUri(); + return getViolatedDirective() + ": " + getDocumentUrl(); } } From 9fe2b59b70de189bf06344d1929c601adc64fde4 Mon Sep 17 00:00:00 2001 From: Adam Rauch Date: Tue, 28 Jul 2026 15:00:24 -0700 Subject: [PATCH 2/2] Bag -> MultiSet --- src/org/labkey/test/tests/elispotassay/ElispotAssayTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/org/labkey/test/tests/elispotassay/ElispotAssayTest.java b/src/org/labkey/test/tests/elispotassay/ElispotAssayTest.java index 1cd9b7ecc0..5b7d2b205e 100644 --- a/src/org/labkey/test/tests/elispotassay/ElispotAssayTest.java +++ b/src/org/labkey/test/tests/elispotassay/ElispotAssayTest.java @@ -757,7 +757,7 @@ public void testMeanAndMedian() List expected4FMedians = Arrays.asList("0.0", "0.0", "6666.7", "0.0"); List expected6FMeans = Arrays.asList("0.0", "0.0", "0.0", "0.0"); List expected6FMedians = Arrays.asList("0.0", "0.0", "0.0", "0.0"); - Bag> expectedRows = new HashBag<>(DataRegionTable.collateColumnsIntoRows( + MultiSet> expectedRows = new HashMultiSet<>(DataRegionTable.collateColumnsIntoRows( expectedPtids, expected2FMeans, expected2FMedians, @@ -766,7 +766,7 @@ public void testMeanAndMedian() expected6FMeans, expected6FMedians)); - Bag> actualRows = new HashBag<>(table.getRows( + MultiSet> actualRows = new HashMultiSet<>(table.getRows( "ParticipantID", "Atg2FMean", "Atg2FMedian",