Repository navigation
fix(filter): read a version part too large for Int64 as no version #108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: fix/settings-severity-table
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,8 @@ function Get-IslVersionPart { | |
| .DESCRIPTION | ||
| A text of one to four numbers separated by dots, with white space around it allowed, gives | ||
| four numbers, the parts that are missing as 0: '10.0.26100' gives 10, 0, 26100, 0. Any other | ||
| text is not a version, and gives nothing. | ||
| text is not a version, and gives nothing; so does a text with a part too large for a 64-bit | ||
| number, which has no order the comparison could use. | ||
|
|
||
| .PARAMETER Text | ||
| The text to read. | ||
|
|
@@ -34,7 +35,14 @@ function Get-IslVersionPart { | |
| return | ||
| } | ||
| $parts = [System.Collections.Generic.List[long]]::new() | ||
| foreach ($part in ($Text.Trim() -split '\.')) { $parts.Add([long]$part) } | ||
| foreach ($part in ($Text.Trim() -split '\.')) { | ||
| $number = [long]0 | ||
| $style = [System.Globalization.NumberStyles]::None | ||
| if (-not [long]::TryParse($part, $style, [cultureinfo]::InvariantCulture, [ref]$number)) { | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit (optional): the regex above checks with |
||
| return | ||
| } | ||
| $parts.Add($number) | ||
| } | ||
| while ($parts.Count -lt 4) { $parts.Add(0) } | ||
| $parts.ToArray() | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit (optional): the entry gets the old behaviour wrong. The cast error didn't end the command. It ended only the
foreachstatement, the missing parts were filled with zeros, and the command went on with a wrong verdict. I measured onmain:Test-IntuneAssignmentFilter -Rule '(device.operatingSystemVersion -ge "10.0.99999999999999999999")' -Device @{ operatingSystemVersion = '10.0.22631' }writes oneInvalidCastFromStringToIntegererror and returnsMatched = True, because the rule's version was read as10.0.0.0. The wrong match is what a user would act on, so it belongs in the entry. Fix: say something like "It was read as10.0with the rest of the version dropped, so the clause could match, and a conversion error was written."