Only analyze requests belonging to the navigated url's page#16
Merged
Conversation
A browsertime HAR can contain more than one page, for example when a concurrent browsertime run on the same host races for the same Chrome DevTools port and its crossed CDP session records another website's page load into this run's recording (see Webperf-se/webperf_core#1557). This analyzer scanned every entry in the whole HAR, and its first-html-as-primary fallback could pick another website's document, so a crossed-in recording could contaminate the robots.txt, security .txt, sitemap and feed analysis of the tested website. Filter entries to the ones belonging to the first page in the HAR's pages array, and verify that the recording's first request matches the navigated url's hostname (the URL API normalizes IDN hostnames to punycode on both sides). The check is per navigated url, so sitemaps legitimately hosted on another domain keep working. On mismatch nothing is analyzed. HARs without a pages array and entries without pageref behave as before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of a sweep across the HAR-consuming plugins; same problem class as Webperf-se/webperf_core#1557 / #1558, Webperf-se/plugin-pagenotfound#156, Webperf-se/plugin-css#159, Webperf-se/plugin-html#130 and Webperf-se/plugin-javascript#130.
Problem
Concurrent browsertime runs on one host can race for the same Chrome DevTools port; the crossed CDP session records the other run's page navigation into this run's HAR, so the HAR can contain more than one page.
transform2SimplifiedDatascanned every entry in the whole HAR. Its first-html-as-primary fallback could even pick another website's document as the analyzed page, contaminating the robots.txt/security.txt/sitemap/feed analysis.Fix
New
getFirstPageEntries(navUrl, harData):pagerefbelongs to the first page in the HAR'spagesarray;new URL(...)punycodes IDN hostnames on both sides) — on mismatch nothing is analyzed.The origin check is against the navigated url of each message (robots.txt, sitemap, etc.), so sitemaps legitimately hosted on another domain keep working. HARs without a
pagesarray and entries withoutpagerefbehave exactly as before.Validation
Synthetic crossed HARs: primary anchors to the navigated url and foreign HTML never becomes the primary fallback; foreign pages excluded from
htmls; origin mismatch yields an empty analysis; legacy HAR withoutpagesunchanged;eslintclean.