Skip to content

Commit

Permalink
build: release version 2.1.2
Browse files Browse the repository at this point in the history
 - security: escape regex expression in project keys
 - security: escape regex expression in separator
  • Loading branch information
ryanvade committed Jul 9, 2024
1 parent a73031b commit c5eacd1
Show file tree
Hide file tree
Showing 10 changed files with 578 additions and 91 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ Note that `projectKey` and `projectKeys` works same under the hood. You can pass

```
- name: Enforce Jira Issue Key in Pull Request Title
uses: ryanvade/[email protected].1
uses: ryanvade/[email protected].2
```

## Example Usage with a specific Project Key

```
- name: Enforce Jira Issue Key in Pull Request Title
uses: ryanvade/[email protected].1
uses: ryanvade/[email protected].2
with:
projectKey: 'AB'
```
Expand All @@ -92,7 +92,7 @@ Note that `projectKey` and `projectKeys` works same under the hood. You can pass

```
- name: Enforce Jira Issue Key in Pull Request Title
uses: ryanvade/[email protected].1
uses: ryanvade/[email protected].2
with:
projectKeys: |
'AB'
Expand All @@ -104,7 +104,7 @@ Note that `projectKey` and `projectKeys` works same under the hood. You can pass

```
- name: Enforce Jira Issue Key in Pull Request Title
uses: ryanvade/[email protected].1
uses: ryanvade/[email protected].2
with:
projectKey: 'AB'
separator: ':'
Expand All @@ -114,7 +114,7 @@ Note that `projectKey` and `projectKeys` works same under the hood. You can pass

```
- name: Enforce Jira Issue Key in Pull Request Title
uses: ryanvade/[email protected].1
uses: ryanvade/[email protected].2
with:
projectKey: 'AB'
keyAnywhereInTitle: 'true'
Expand Down
26 changes: 13 additions & 13 deletions __tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe("index", () => {
process.env[
`INPUT_${projectKeyInputName.replace(/ /g, "_").toUpperCase()}`
] = "aB";
expect(getRegex).toThrow('ProjectKey aB is not valid');
expect(getRegex).toThrow("ProjectKey aB is not valid");
});

it("uses a project key and a colon separator if they exist", () => {
Expand Down Expand Up @@ -159,14 +159,14 @@ describe("index", () => {
process.env[
`INPUT_${projectKeysInputName.replace(/ /g, "_").toUpperCase()}`
] = "aB";
expect(getRegex).toThrow('ProjectKey aB is not valid');
expect(getRegex).toThrow("ProjectKey aB is not valid");
});

it("throws an exception if one of the provided project key is not valid", () => {
process.env[
`INPUT_${projectKeysInputName.replace(/ /g, "_").toUpperCase()}`
] = "AB\naB\nCD";
expect(getRegex).toThrow('ProjectKey aB is not valid');
expect(getRegex).toThrow("ProjectKey aB is not valid");
});

it("uses a project key and a colon separator if they exist", () => {
Expand Down Expand Up @@ -283,27 +283,27 @@ describe("index", () => {
it("uses a project key and a colon separator if they exist with single tick in string", () => {
const projectNames: string[] = ["AB", "CD", "EF", "GH"];
process.env[
`INPUT_${projectKeysInputName.replace(/ /g, "_").toUpperCase()}`
] = "'AB'\n'CD'\n'EF'\n'GH'";
`INPUT_${projectKeysInputName.replace(/ /g, "_").toUpperCase()}`
] = "'AB'\n'CD'\n'EF'\n'GH'";
process.env[
`INPUT_${separatorKeyInputName.replace(/ /g, "_").toUpperCase()}`
] = ":";
`INPUT_${separatorKeyInputName.replace(/ /g, "_").toUpperCase()}`
] = ":";
process.env[
`INPUT_${keyAnywhereInTitle.replace(/ /g, "_").toUpperCase()}`
] = "false";
`INPUT_${keyAnywhereInTitle.replace(/ /g, "_").toUpperCase()}`
] = "false";
const regexCollection = getRegex();
regexCollection.forEach((regex: RegExp, index: number) => {
expect(regex).toEqual(
new RegExp(`(^${projectNames[index]}-){1}(\\d)+(:)+(\\S)+(.)+`),
new RegExp(`(^${projectNames[index]}-){1}(\\d)+(:)+(\\S)+(.)+`),
);
expect(
regex.test(`${projectNames[index]}-43: stuff and things`),
regex.test(`${projectNames[index]}-43: stuff and things`),
).toBe(false);
expect(regex.test(`${projectNames[index]}-123: PR Title`)).toBe(
false,
false,
);
expect(regex.test(`${projectNames[index]}-43:stuff and things`)).toBe(
true,
true,
);
expect(regex.test(`${projectNames[index]}-123:PR Title`)).toBe(true);
});
Expand Down
Loading

0 comments on commit c5eacd1

Please sign in to comment.