Skip to content

A version part too large for Int64 ends Test-IntuneAssignmentFilter with a conversion error #106

Backlog

Description

@fadwen-ai

A version in an assignment filter rule with a part too large for a 64-bit integer ends Test-IntuneAssignmentFilter with a conversion error, where it should return a verdict.

Reproduction

On main (3b82ba2), under PowerShell 7.6 and Windows PowerShell 5.1:

$rule = '(device.operatingSystemVersion -ge "10.0.99999999999999999999")'
Test-IntuneAssignmentFilter -Rule $rule -Device @{ operatingSystemVersion = '10.0.22631' } -ErrorAction Stop

The command ends with InvalidCastFromStringToInteger,Test-IntuneAssignmentFilter: Cannot convert value "99999999999999999999" to type "System.Int64". The same happens when the device's version has such a part.

Expected

The text is not a version the evaluator can order, so -gt, -ge, -lt and -le do not match, as they already do not for any other text that is not a version. The command returns Matched = $false.

Cause

The version reader accepts any number of digits in a part (^\s*\d+(\.\d+){0,3}\s*$) and then casts each part with [long]$part, which throws on overflow. The code is the nested Get-VersionPart of Test-IntuneAssignmentFilter on main and Get-IslVersionPart on the #65 branches.

This is not a finding against ai-powershell-standards 2.0.0. It was found in a review of #102.

Discovered and written up with Claude Code.

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions