-
Notifications
You must be signed in to change notification settings - Fork 88
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
Fix false positives for 'SARIF1002.UrisMustBeValid' due to Uri.IsWellFormedUriString bug #2501
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
60bb414
Replace Uri.IsWellFormedUri with SarifValidationSkimmerBase.IsWellFor…
marmegh 4bb9461
Updated method name to standard
marmegh ebc734c
Fixed unhandled exception.
marmegh 83c2349
Resolve merge conflict.
marmegh f288136
Added unit test for UriIsWellFormedUriString
marmegh 04fe163
Applied PR feedback.
marmegh 6c908c3
Fixed missing whitespace in test.
marmegh 976f073
Remove unneeded file and automatically generated code update from run…
marmegh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
23 changes: 23 additions & 0 deletions
23
src/Test.UnitTests.Sarif.Multitool.Library/Rules/SARIF1002.UrisMustBeValidTests.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System.Text; | ||
|
||
using FluentAssertions; | ||
|
||
using Microsoft.CodeAnalysis.Sarif.Multitool.Rules; | ||
|
||
using Xunit; | ||
|
||
namespace Microsoft.CodeAnalysis.Sarif.Multitool | ||
{ | ||
public class UrisMustBeValidTests | ||
{ | ||
[Fact] | ||
public void UrisMustBeValid_ShouldProduceExpectedResults() | ||
{ | ||
var testSkimmer = new UrisMustBeValid(); | ||
|
||
|
||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Text; | ||
|
||
using FluentAssertions; | ||
|
@@ -76,5 +77,86 @@ public void SarifValidationSkimmerBase_JsonPointerToJavaScript_ProducesExpectedR | |
string errorMessage = sb.ToString(); | ||
errorMessage.Should().BeEmpty(); | ||
} | ||
|
||
[Fact] | ||
public void SarifValidationSkimmerBase_UriIsWellFormedUriString_ShouldReturnTrueIfWellFormedUri() | ||
{ | ||
var testCases = new[] | ||
{ | ||
new | ||
{ | ||
uriKind = UriKind.Absolute, | ||
uriString = "file:///c:/Code/sarif-sdk/src/" | ||
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. |
||
}, | ||
new | ||
{ | ||
uriKind = UriKind.Absolute, | ||
uriString = "https://example.com/my-project" | ||
}, | ||
new | ||
{ | ||
uriKind = UriKind.Absolute, | ||
uriString = "file:/c:/src/file.c" | ||
}, | ||
new | ||
{ | ||
uriKind = UriKind.Absolute, | ||
uriString = "file:/C:/src/file.c" | ||
}, | ||
new | ||
{ | ||
uriKind = UriKind.Absolute, | ||
uriString = "FILE:/C:/SRC/FILE.c" | ||
}, | ||
new | ||
{ | ||
uriKind = UriKind.RelativeOrAbsolute, | ||
uriString = "file:///c:/Code/sarif-sdk/src/" | ||
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. |
||
}, | ||
new | ||
{ | ||
uriKind = UriKind.RelativeOrAbsolute, | ||
uriString = "https://example.com/my-project" | ||
}, | ||
new | ||
{ | ||
uriKind = UriKind.RelativeOrAbsolute, | ||
uriString = "file:/c:/src/file.c" | ||
}, | ||
new | ||
{ | ||
uriKind = UriKind.RelativeOrAbsolute, | ||
uriString = "file://networkLocation/folder/someDoc.txt" | ||
}, | ||
}; | ||
|
||
foreach (var testCase in testCases) | ||
{ | ||
SarifValidationSkimmerBase.IsWellFormedUriString(testCase.uriString, testCase.uriKind).Should().BeTrue(); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void SarifValidationSkimmerBase_UriIsWellFormedUriString_ShouldReturnFalseIfNotWellFormedUri() | ||
{ | ||
var testCases = new[] | ||
{ | ||
new | ||
{ | ||
uriKind = UriKind.Absolute, | ||
uriString = "ht%tp://www.example.com/rules/tst0001.html" | ||
}, | ||
new | ||
{ | ||
uriKind = UriKind.RelativeOrAbsolute, | ||
uriString = "ht%tp://www.example.com/rules/tst0001.html" | ||
}, | ||
}; | ||
|
||
foreach (var testCase in testCases) | ||
{ | ||
SarifValidationSkimmerBase.IsWellFormedUriString(testCase.uriString, testCase.uriKind).Should().BeFalse(); | ||
} | ||
} | ||
} | ||
} |
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.
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.
Put this information in the helper.
#Pending