Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/vul inputs #57

Merged
merged 3 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading