Skip to content

Commit

Permalink
Found a bug regarding the RemovedCharacterMutator where it doesn't re…
Browse files Browse the repository at this point in the history
…move the first character in the name. (microsoft#296)
  • Loading branch information
jpinz authored Jan 18, 2022
1 parent e51b545 commit b872870
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class RemovedCharacterMutator : IMutator

public IEnumerable<Mutation> Generate(string arg)
{
for (int i = 1; i < arg.Length; i++)
for (int i = 0; i < arg.Length; i++)
{
yield return new Mutation(
mutated: $"{arg[..i]}{arg[(i + 1)..]}",
Expand Down
3 changes: 2 additions & 1 deletion src/oss-tests/FindSquatsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public async Task DetectSquats(string packageUrl, bool expectedToHaveSquats)
}

[DataTestMethod]
[DataRow("pkg:npm/foo", "foojs")]
[DataRow("pkg:npm/foo", "foojs")] // SuffixAdded, js
[DataRow("pkg:npm/lodash", "odash")] // RemovedCharacter, first character
[DataRow("pkg:nuget/Microsoft.CST.OAT", "microsoft.cst.oat.net")]
public void GenerateManagerSpecific(string packageUrl, string expectedToFind)
{
Expand Down

0 comments on commit b872870

Please sign in to comment.