Skip to content

Commit

Permalink
MSHARED-1130: Sanitised value nullability in match(Pattern, boolean, …
Browse files Browse the repository at this point in the history
…String)
  • Loading branch information
andrzejj0 committed Sep 8, 2022
1 parent 37ea472 commit 6aaeffe
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ public boolean matches( Artifactoid artifactoid )
private static boolean match( final String pattern, final boolean containsAsterisk, final String value )
{
char[] patArr = pattern.toCharArray();
char[] strArr = value.toCharArray();
char[] strArr = value != null ? value.toCharArray() : new char[0];
int patIdxStart = 0;
int patIdxEnd = patArr.length - 1;
int strIdxStart = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -579,4 +579,26 @@ public void testmassembly955()
assertTrue( filter.include( artifact2 ) );
}
}

@Test
public void testPartialWildcardShouldNotMatchEmptyComponent()
{
Artifact artifact = mock( Artifact.class );
when( artifact.getGroupId() ).thenReturn( "test-group" );
when( artifact.getArtifactId() ).thenReturn( "test-artifact" );
when( artifact.getVersion() ).thenReturn( "test-version" );
when( artifact.getType() ).thenReturn( null );

final ArtifactFilter filter = createFilter(
Collections.singletonList( "test-group:test-artifact:*:ERROR*" ) );

if ( isInclusionNotExpected() )
{
assertTrue( filter.include( artifact ) );
}
else
{
assertFalse( filter.include( artifact ) );
}
}
}

0 comments on commit 6aaeffe

Please sign in to comment.