|
37 | 37 | import java.nio.file.Path;
|
38 | 38 | import java.text.SimpleDateFormat;
|
39 | 39 | import java.util.*;
|
| 40 | +import java.util.regex.Pattern; |
40 | 41 |
|
41 | 42 | import static java.util.Arrays.asList;
|
42 | 43 | import static org.assertj.core.api.Assertions.assertThat;
|
43 | 44 | import static org.assertj.core.api.Assertions.entry;
|
| 45 | +import static org.junit.Assert.assertFalse; |
| 46 | +import static org.junit.Assert.assertTrue; |
44 | 47 |
|
45 | 48 | @RunWith(JUnitParamsRunner.class)
|
46 | 49 | public class GitCommitIdPluginIntegrationTest {
|
@@ -1505,6 +1508,21 @@ public void shouldGeneratePropertiesWithMultiplePrefixesAndReactorProject(boolea
|
1505 | 1508 | }
|
1506 | 1509 | }
|
1507 | 1510 |
|
| 1511 | + @Test |
| 1512 | + public void verifyAllowedCharactersForEvaluateOnCommit() { |
| 1513 | + Pattern p = GitCommitIdPlugin.allowedCharactersForEvaluateOnCommit; |
| 1514 | + assertTrue(p.matcher("5957e419d").matches()); |
| 1515 | + assertTrue(p.matcher("my_tag").matches()); |
| 1516 | + assertTrue(p.matcher("my-tag").matches()); |
| 1517 | + assertTrue(p.matcher("my.tag").matches()); |
| 1518 | + assertTrue(p.matcher("HEAD^1").matches()); |
| 1519 | + assertTrue(p.matcher("feature/branch").matches()); |
| 1520 | + |
| 1521 | + assertFalse(p.matcher("; CODE INJECTION").matches()); |
| 1522 | + assertFalse(p.matcher("|exit").matches()); |
| 1523 | + assertFalse(p.matcher("&&cat /etc/passwd").matches()); |
| 1524 | + } |
| 1525 | + |
1508 | 1526 | private GitDescribeConfig createGitDescribeConfig(boolean forceLongFormat, int abbrev) {
|
1509 | 1527 | GitDescribeConfig gitDescribeConfig = new GitDescribeConfig();
|
1510 | 1528 | gitDescribeConfig.setTags(true);
|
|
0 commit comments