Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 8, 2026

Two off-by-one errors in range calculations were causing incorrect detection of overly broad network segments in Private Access applications.

Changes

  • IP range calculation (line 69): Added +1 to account for inclusive range boundaries. A range like 192.168.1.1-192.168.1.2 represents 2 addresses, not 1.
  • Port range calculation (line 87): Added +1 to account for inclusive range boundaries. A range like 80-90 includes 11 ports (80 through 90), not 10.

Example

# Before: 80-90 would calculate as (90-80) = 10, not triggering threshold
# After: 80-90 correctly calculates as (90-80+1) = 11, properly flagging broad ranges

if ($Port -match '^(\d+)-(\d+)$' -and (([int]$matches[2] - [int]$matches[1] + 1) -gt $BroadPortRangeThreshold)) { 
    return $true 
}

Both functions now correctly identify ranges that exceed their respective thresholds (256 IPs and 10 ports).


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add test for Entra Private Access application Fix off-by-one errors in IP and port range calculations for Test-Assessment.25395 Jan 8, 2026
Copilot AI requested a review from aahmed-spec January 8, 2026 05:37
@aahmed-spec aahmed-spec marked this pull request as ready for review January 8, 2026 05:44
@aahmed-spec aahmed-spec merged commit f4bb78f into test-25395 Jan 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants