Fix out-of-bounds safety in BlobToFileNameResolver
Description
This pull request resolves two safety-critical TODO items in the filename conflict resolution logic of the Azure Storage module (BlobToFileNameResolver.cs):
- MaxFileNameLength Guard Clause: Added validation to check if
maxFileNameLengthis non-positive (<= 0). If so, the code now throws a clearArgumentOutOfRangeExceptioninstead of proceeding with invalid dimensions. - Bounds Protection during Truncation: Implemented defensive boundaries when calculating
trimLength. If the required trimming size exceeds the actual length of the filename base (which previously caused out-of-boundsRemove()index exceptions), the start index is now safely clamped to0to clear the base filename and return the postfix and extension safely.
No changes were made to cmdlet interfaces or public API signatures.
Mandatory Checklist
-
Please choose the target release of Azure PowerShell. (⚠️Target release is a different concept from API readiness. Please click below links for details.)
- [x] General release
- [ ] Public preview
- [ ] Private preview
- [ ] Engineering build
- [ ] No need for a release
-
[x] Check this box to confirm: I have read the Submitting Changes section of
CONTRIBUTING.mdand reviewed the following information:
- SHOULD update
ChangeLog.mdfile(s) appropriately- Update
src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md.- A snippet outlining the change(s) made in the PR should be written under the
## Upcoming Releaseheader in the past tense.
- A snippet outlining the change(s) made in the PR should be written under the
- Should not change
ChangeLog.mdif no new release is required, such as fixing test case only.
- Update
- SHOULD regenerate markdown help files if there is cmdlet API change. Instruction
- SHOULD have proper test coverage for changes in pull request.
- SHOULD NOT adjust version of module manually in pull request
@renish-patel thank you for testing and giving me help to write
Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status.
Thank you for your contribution @Ronitsabhaya75! We will review the pull request and get back to you soon.
Commenter does not have sufficient privileges for PR 29672 in repo Azure/azure-powershell
/azp run
Azure Pipelines successfully started running 3 pipeline(s).
@thomas-temby can you please review this.