Parse PowerShell user agent and match as CLI - #205
Open
kimsondrup wants to merge 1 commit into
Open
kimsondrup wants to merge 1 commit into
kimsondrup wants to merge 1 commit into
Conversation
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.
PowerShell's
Invoke-WebRequestandInvoke-RestMethodsend a browser-like,Mozilla-prefixed User-Agent with their own product appended last:
Mozilla/5.0 (Linux; Fedora Linux 44 (WSL); en-US) PowerShell/7.6.5Parseonly reads the leading product, so it returnsMozillaand PowerShellcallers get the HTML page instead of their IP. PowerShell's own tracker still has
this as an open issue: PowerShell/PowerShell#24425.
The browser-like default makes the website return interactive HTML instead of
machine-readable output.
Now
ParsereportsPowerShellandWindowsPowerShell(separate products) andcliMatchermatches both./jsongets more accurate for these clients too:productisPowerShellandversionis7.6.5, instead of a misleadingMozilla/5.0.