Skip to content

Commit d572434

Browse files
committed
fix(release): snyk security issues
1 parent 8c2e2ed commit d572434

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

scripts/publish-gotrue-legacy.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@ async function publishGotrueLegacy(): Promise<void> {
9999
fs.writeFileSync(authJsPackageLockJson, modifiedPackageLock)
100100
}
101101

102+
// Validate tag to prevent command injection
103+
const validTags = ['latest', 'canary', 'beta', 'alpha', 'next', 'rc']
104+
if (!validTags.includes(tag)) {
105+
log(`❌ Error: Invalid tag '${tag}'. Must be one of: ${validTags.join(', ')}`, colors.red)
106+
process.exit(1)
107+
}
108+
102109
// Publish to npm from the auth-js directory
103110
const publishCommand = `npm publish --provenance --tag ${tag}`
104111

scripts/release-stable.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ if (!versionSpecifier) {
2222
process.exit(1)
2323
}
2424

25+
// Validate versionSpecifier to prevent command injection
26+
const validSpecifiers = ['patch', 'minor', 'major', 'prepatch', 'preminor', 'premajor', 'prerelease']
27+
const isValidVersion = /^v?\d+\.\d+\.\d+(-[a-zA-Z0-9.-]+)?$/.test(versionSpecifier)
28+
if (!validSpecifiers.includes(versionSpecifier) && !isValidVersion) {
29+
console.error(`❌ Invalid version specifier: ${versionSpecifier}`)
30+
console.error(`Must be one of: ${validSpecifiers.join(', ')} or a valid semver version`)
31+
process.exit(1)
32+
}
33+
2534
;(async () => {
2635
const { workspaceVersion, projectsVersionData } = await releaseVersion({
2736
verbose: true,
@@ -66,6 +75,14 @@ if (!versionSpecifier) {
6675

6776
// ---- Create release branch + PR ----
6877
const version = result.workspaceChangelog?.releaseVersion.rawVersion || workspaceVersion
78+
79+
// Validate version to prevent command injection
80+
// Version should match semver pattern or be a valid npm version specifier
81+
if (!version || !/^(v?\d+\.\d+\.\d+(-[a-zA-Z0-9.-]+)?|patch|minor|major|prepatch|preminor|premajor|prerelease)$/.test(version)) {
82+
console.error(`❌ Invalid version format: ${version}`)
83+
process.exit(1)
84+
}
85+
6986
const branchName = `release-${version}`
7087

7188
try {

0 commit comments

Comments
 (0)