You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here are some key observations to aid the review process:
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 Security concerns
Path Traversal: The DownloadFile method accepts a fileName and targetDirectory parameter without validation. This could potentially allow downloading files to unauthorized locations if the parameters contain path traversal sequences (../). Consider adding path sanitization.
-object?[] namesArray = (object?[])value["names"]!;+if (!value.TryGetValue("names", out var namesObj) || namesObj is not object?[] namesArray)+{+ throw new WebDriverException("Missing or invalid 'names' array in response");+}
return namesArray.Select(obj => obj!.ToString()!).ToList();
Apply this suggestion
Suggestion importance[1-10]: 8
__
Why: The suggestion adds crucial defensive programming to handle potential null or invalid responses from the API, preventing runtime exceptions and improving error handling with a more descriptive message.
Medium
General
Document null parameter validation
Add null check for the 'fileName' parameter in the DownloadFile method, similar to how targetDirectory is documented. Both parameters are required for the operation to succeed.
/// <param name="fileName">The name of the file to be downloaded.</param>
/// <param name="targetDirectory">The target directory where the file should be downloaded to.</param>
-/// <exception cref="ArgumentNullException">If <paramref name="targetDirectory"/> is null.</exception>+/// <exception cref="ArgumentNullException">If <paramref name="fileName"/> or <paramref name="targetDirectory"/> is null.</exception>
public void DownloadFile(string fileName, string targetDirectory)
Apply this suggestion
Suggestion importance[1-10]: 7
__
Why: The suggestion improves API documentation by making null parameter validation explicit for both parameters, which is important for API consumers and consistent with C# best practices.
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
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.
User description
Description
Enable nullability on remote file download APIs, ie. the
IHasDownloadsinterface.Motivation and Context
Contributes to #14640
Types of changes
Checklist
PR Type
Enhancement, Bug fix
Description
Enabled nullability annotations in
IHasDownloadsinterface and related APIs.Improved type safety in
RemoteWebDrivermethods by handling nullable types.Added exception documentation for
DownloadFilemethod.Changes walkthrough 📝
IHasDownloads.cs
Enable nullability in `IHasDownloads` interfacedotnet/src/webdriver/IHasDownloads.cs
RemoteWebDriver.cs
Improve type safety in `RemoteWebDriver` methodsdotnet/src/webdriver/Remote/RemoteWebDriver.cs
GetDownloadableFilesmethod to handle nullable object arrays.DownloadFilemethod.