Skip to content

Commit

Permalink
Merge pull request #57 from mercadolibre/fix/vul-inputs
Browse files Browse the repository at this point in the history
Fix/vul inputs
  • Loading branch information
arcticfalcon authored Jun 18, 2024
2 parents a49a59b + c406f97 commit bce30f2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ repos:
stages: [commit]
- id: post_commit_hook
stages: [post-commit]
- repo: https://github.com/melisource/fury_datasec-git-hooks
rev: 1.0.3
hooks:
- id: pre_commit_hook
stages: [commit]
verbose: true
17 changes: 11 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12855,11 +12855,11 @@ const semver = __importStar(__nccwpck_require__(1383));
const fs = __importStar(__nccwpck_require__(7147));
const allowedBaseBranch = /^([\w-]+:)?(?:master|main|develop)$/;
const branchTypes = [
{ pattern: /^(\w*:)?fix\/.*/, bump: "patch", label: "fix" },
{ pattern: /^(\w*:)?feature\/.*/, bump: "minor", label: "feature" },
{ pattern: /^(\w*:)?release\/.*/, bump: "major", label: "release" },
{ pattern: /^(\w*:)?chore\/.*/, bump: "chore", label: "chore" },
{ pattern: /^revert-\d+-.*/, bump: "patch", label: "revert" },
{ pattern: /^(\w*:)?fix\/([\w-]+)$/, bump: "patch", label: "fix" },
{ pattern: /^(\w*:)?feature\/([\w-]+)$/, bump: "minor", label: "feature" },
{ pattern: /^(\w*:)?release\/([\w-]+)$/, bump: "major", label: "release" },
{ pattern: /^(\w*:)?chore\/([\w-]+)$/, bump: "chore", label: "chore" },
{ pattern: /^revert-\d+-([\w-]+)$/, bump: "patch", label: "revert" },
];
const triggerBuild = core.getBooleanInput('trigger-build');
let token = core.getInput('gh_token');
Expand All @@ -12872,6 +12872,11 @@ const { owner, repo } = Github.context.repo;
// most @actions toolkit packages have async methods
async function run() {
try {
// Validate envs and inputs
if (versionPrefix !== "" && /^([\w-]+)$/.test(versionPrefix) === false) {
core.setFailed('Invalid version prefix.');
return;
}
let pr;
// Extract from comment event
if (Github.context.eventName === 'issue_comment') {
Expand Down Expand Up @@ -13052,7 +13057,7 @@ async function createTag(pr) {
core.info(`lastTag: ${lastTag}`);
const bump = `${prefix}${pattern.bump}`;
if (preRelease) {
const rcName = `rc-${branch.replace(/[\/:_]/g, '-')}`;
const rcName = `rc-${branch.replace(/[^a-zA-Z0-9-]/g, '-')}`;
const lastRC = await getLastRC(rcName);
if (lastRC) {
// increase RC number
Expand Down
19 changes: 13 additions & 6 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ declare var process : {
}
}


const allowedBaseBranch = /^([\w-]+:)?(?:master|main|develop)$/
type BranchType = {
pattern: RegExp,
bump: 'patch' | 'minor' | 'major' | 'chore',
label: string
}
const branchTypes: Array<BranchType> = [
{pattern: /^(\w*:)?fix\/.*/, bump: "patch", label: "fix"},
{pattern: /^(\w*:)?feature\/.*/, bump: "minor", label: "feature"},
{pattern: /^(\w*:)?release\/.*/, bump: "major", label: "release"},
{pattern: /^(\w*:)?chore\/.*/, bump: "chore", label: "chore"},
{pattern: /^revert-\d+-.*/, bump: "patch", label: "revert"},
{pattern: /^(\w*:)?fix\/([\w-]+)$/, bump: "patch", label: "fix"},
{pattern: /^(\w*:)?feature\/([\w-]+)$/, bump: "minor", label: "feature"},
{pattern: /^(\w*:)?release\/([\w-]+)$/, bump: "major", label: "release"},
{pattern: /^(\w*:)?chore\/([\w-]+)$/, bump: "chore", label: "chore"},
{pattern: /^revert-\d+-([\w-]+)$/, bump: "patch", label: "revert"},
]

const triggerBuild = core.getBooleanInput('trigger-build')
Expand All @@ -38,6 +39,12 @@ const {owner, repo} = Github.context.repo
// most @actions toolkit packages have async methods
async function run() {
try {
// Validate envs and inputs
if(versionPrefix !== "" && /^([\w-]+)$/.test(versionPrefix) === false) {
core.setFailed('Invalid version prefix.');
return
}

let pr: WebhookPayloadPullRequestPullRequest

// Extract from comment event
Expand Down Expand Up @@ -229,7 +236,7 @@ async function createTag(pr: WebhookPayloadPullRequestPullRequest) {
core.info(`lastTag: ${lastTag}`)
const bump = `${prefix}${pattern.bump}`
if (preRelease) {
const rcName = `rc-${branch.replace(/[\/:_]/g, '-')}`
const rcName = `rc-${branch.replace(/[^a-zA-Z0-9-]/g, '-')}`
const lastRC = await getLastRC(rcName)
if (lastRC) {
// increase RC number
Expand Down

0 comments on commit bce30f2

Please sign in to comment.