semantic-release 25.0.6 → 25.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +3 -0
- package/lib/branches/expand.js +3 -1
- package/lib/branches/get-tags.js +4 -1
- package/lib/definitions/errors.js +15 -0
- package/lib/git.js +18 -12
- package/lib/hide-sensitive.js +4 -1
- package/lib/utils.js +1 -1
- package/lib/verify.js +6 -2
- package/package.json +3 -3
package/index.d.ts
CHANGED
|
@@ -627,6 +627,9 @@ declare module "semantic-release" {
|
|
|
627
627
|
* Any valid git url format is supported (see
|
|
628
628
|
* [git protocols](https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols))
|
|
629
629
|
*
|
|
630
|
+
* The value must not begin with `-`, as it would otherwise be interpreted
|
|
631
|
+
* by `git` as a command-line option rather than a URL.
|
|
632
|
+
*
|
|
630
633
|
* Default: `repository` property in `package.json`, or git origin url.
|
|
631
634
|
*/
|
|
632
635
|
repositoryUrl?: string | undefined;
|
package/lib/branches/expand.js
CHANGED
|
@@ -10,7 +10,9 @@ export default async (repositoryUrl, { cwd }, branches) => {
|
|
|
10
10
|
...branches,
|
|
11
11
|
...remove(gitBranches, (name) => micromatch(gitBranches, branch.name).includes(name)).map((name) => ({
|
|
12
12
|
name,
|
|
13
|
-
...mapValues(omit(branch, "name"), (value) =>
|
|
13
|
+
...mapValues(omit(branch, "name"), (value) =>
|
|
14
|
+
isString(value) ? template(value, { evaluate: false, escape: false })({ name }) : value
|
|
15
|
+
),
|
|
14
16
|
})),
|
|
15
17
|
],
|
|
16
18
|
[]
|
package/lib/branches/get-tags.js
CHANGED
|
@@ -11,7 +11,10 @@ export default async ({ cwd, env, options: { tagFormat } }, branches) => {
|
|
|
11
11
|
// by replacing the `version` variable in the template by `(.+)`.
|
|
12
12
|
// The `tagFormat` is compiled with space as the `version` as it's an invalid tag character,
|
|
13
13
|
// so it's guaranteed to no be present in the `tagFormat`.
|
|
14
|
-
const tagRegexp = `^${escapeRegExp(template(tagFormat)({ version: " " })).replace(
|
|
14
|
+
const tagRegexp = `^${escapeRegExp(template(tagFormat, { evaluate: false, escape: false })({ version: " " })).replace(
|
|
15
|
+
" ",
|
|
16
|
+
"(.+)"
|
|
17
|
+
)}`;
|
|
15
18
|
|
|
16
19
|
// Get the tags notes for all the tags in the repository
|
|
17
20
|
const tagsNotesMap = await getTagsNotes({ cwd, env });
|
|
@@ -42,6 +42,21 @@ Please make sure to add the \`repositoryUrl\` to the [semantic-release configura
|
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
export function EINVALIDREPOURL({ repositoryUrl }) {
|
|
46
|
+
return {
|
|
47
|
+
message: "The `repositoryUrl` option is not a valid git URL.",
|
|
48
|
+
details: `The [repositoryUrl option](${linkify(
|
|
49
|
+
"usage/configuration#repositoryurl"
|
|
50
|
+
)}) must be a valid git URL and cannot begin with \`-\`, as \`git\` would otherwise interpret it as a command-line option rather than a URL.
|
|
51
|
+
|
|
52
|
+
The invalid \`repositoryUrl\` is \`${repositoryUrl}\`.
|
|
53
|
+
|
|
54
|
+
Please verify the \`repository\` property in your \`package.json\` and the [repositoryUrl option](${linkify(
|
|
55
|
+
"usage/configuration#repositoryurl"
|
|
56
|
+
)}) in your [semantic-release configuration](${linkify("usage/configuration#configuration")}).`,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
45
60
|
export function EGITNOPERMISSION({ options: { repositoryUrl }, branch: { name } }) {
|
|
46
61
|
return {
|
|
47
62
|
message: "Cannot push to the Git repository.",
|
package/lib/git.js
CHANGED
|
@@ -54,7 +54,11 @@ export async function getCommits(from, to, execaOptions) {
|
|
|
54
54
|
{ cwd: execaOptions.cwd, env: { ...process.env, ...execaOptions.env } }
|
|
55
55
|
)
|
|
56
56
|
)
|
|
57
|
-
).map(({ message, gitTags, ...commit }) => ({
|
|
57
|
+
).map(({ message, gitTags, ...commit }) => ({
|
|
58
|
+
...commit,
|
|
59
|
+
message: (message ?? "").trim(),
|
|
60
|
+
gitTags: (gitTags ?? "").trim(),
|
|
61
|
+
}));
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
/**
|
|
@@ -67,7 +71,7 @@ export async function getCommits(from, to, execaOptions) {
|
|
|
67
71
|
* @throws {Error} If the `git` command fails.
|
|
68
72
|
*/
|
|
69
73
|
export async function getBranches(repositoryUrl, execaOptions) {
|
|
70
|
-
return (await execa("git", ["ls-remote", "--heads", repositoryUrl], execaOptions)).stdout
|
|
74
|
+
return (await execa("git", ["ls-remote", "--heads", "--", repositoryUrl], execaOptions)).stdout
|
|
71
75
|
.split("\n")
|
|
72
76
|
.filter(Boolean)
|
|
73
77
|
.map((branch) => branch.match(/^.+refs\/heads\/(?<branch>.+)$/)[1]);
|
|
@@ -115,8 +119,8 @@ export async function fetch(repositoryUrl, branch, ciBranch, execaOptions) {
|
|
|
115
119
|
"--unshallow",
|
|
116
120
|
"--tags",
|
|
117
121
|
...(branch === ciBranch && !isDetachedHead
|
|
118
|
-
? [repositoryUrl]
|
|
119
|
-
: ["--update-head-ok", repositoryUrl, `+refs/heads/${branch}:refs/heads/${branch}`]),
|
|
122
|
+
? ["--", repositoryUrl]
|
|
123
|
+
: ["--update-head-ok", "--", repositoryUrl, `+refs/heads/${branch}:refs/heads/${branch}`]),
|
|
120
124
|
],
|
|
121
125
|
execaOptions
|
|
122
126
|
);
|
|
@@ -127,8 +131,8 @@ export async function fetch(repositoryUrl, branch, ciBranch, execaOptions) {
|
|
|
127
131
|
"fetch",
|
|
128
132
|
"--tags",
|
|
129
133
|
...(branch === ciBranch && !isDetachedHead
|
|
130
|
-
? [repositoryUrl]
|
|
131
|
-
: ["--update-head-ok", repositoryUrl, `+refs/heads/${branch}:refs/heads/${branch}`]),
|
|
134
|
+
? ["--", repositoryUrl]
|
|
135
|
+
: ["--update-head-ok", "--", repositoryUrl, `+refs/heads/${branch}:refs/heads/${branch}`]),
|
|
132
136
|
],
|
|
133
137
|
execaOptions
|
|
134
138
|
);
|
|
@@ -143,9 +147,9 @@ export async function fetch(repositoryUrl, branch, ciBranch, execaOptions) {
|
|
|
143
147
|
*/
|
|
144
148
|
export async function fetchNotes(repositoryUrl, execaOptions) {
|
|
145
149
|
try {
|
|
146
|
-
await execa("git", ["fetch", "--unshallow", repositoryUrl, `+refs/notes/*:refs/notes/*`], execaOptions);
|
|
150
|
+
await execa("git", ["fetch", "--unshallow", "--", repositoryUrl, `+refs/notes/*:refs/notes/*`], execaOptions);
|
|
147
151
|
} catch {
|
|
148
|
-
await execa("git", ["fetch", repositoryUrl, `+refs/notes/*:refs/notes/*`], {
|
|
152
|
+
await execa("git", ["fetch", "--", repositoryUrl, `+refs/notes/*:refs/notes/*`], {
|
|
149
153
|
...execaOptions,
|
|
150
154
|
reject: false,
|
|
151
155
|
});
|
|
@@ -204,7 +208,7 @@ export async function isGitRepo(execaOptions) {
|
|
|
204
208
|
*/
|
|
205
209
|
export async function verifyAuth(repositoryUrl, branch, execaOptions) {
|
|
206
210
|
try {
|
|
207
|
-
await execa("git", ["push", "--dry-run", "--no-verify", repositoryUrl, `HEAD:${branch}`], execaOptions);
|
|
211
|
+
await execa("git", ["push", "--dry-run", "--no-verify", "--", repositoryUrl, `HEAD:${branch}`], execaOptions);
|
|
208
212
|
} catch (error) {
|
|
209
213
|
debug(error);
|
|
210
214
|
throw error;
|
|
@@ -233,7 +237,7 @@ export async function tag(tagName, ref, execaOptions) {
|
|
|
233
237
|
* @throws {Error} if the push failed.
|
|
234
238
|
*/
|
|
235
239
|
export async function push(repositoryUrl, execaOptions) {
|
|
236
|
-
await execa("git", ["push", "--tags", repositoryUrl], execaOptions);
|
|
240
|
+
await execa("git", ["push", "--tags", "--", repositoryUrl], execaOptions);
|
|
237
241
|
}
|
|
238
242
|
|
|
239
243
|
/**
|
|
@@ -245,7 +249,7 @@ export async function push(repositoryUrl, execaOptions) {
|
|
|
245
249
|
* @throws {Error} if the push failed.
|
|
246
250
|
*/
|
|
247
251
|
export async function pushNotes(repositoryUrl, ref, execaOptions) {
|
|
248
|
-
await execa("git", ["push", repositoryUrl, `refs/notes/${GIT_NOTE_REF}-${ref}`], execaOptions);
|
|
252
|
+
await execa("git", ["push", "--", repositoryUrl, `refs/notes/${GIT_NOTE_REF}-${ref}`], execaOptions);
|
|
249
253
|
}
|
|
250
254
|
|
|
251
255
|
/**
|
|
@@ -292,7 +296,9 @@ export async function verifyBranchName(branch, execaOptions) {
|
|
|
292
296
|
export async function isBranchUpToDate(repositoryUrl, branch, execaOptions) {
|
|
293
297
|
return (
|
|
294
298
|
(await getGitHead(execaOptions)) ===
|
|
295
|
-
(await execa("git", ["ls-remote", "--heads", repositoryUrl, branch], execaOptions)).stdout.match(
|
|
299
|
+
(await execa("git", ["ls-remote", "--heads", "--", repositoryUrl, branch], execaOptions)).stdout.match(
|
|
300
|
+
/^(?<ref>\w+)?/
|
|
301
|
+
)[1]
|
|
296
302
|
);
|
|
297
303
|
}
|
|
298
304
|
|
package/lib/hide-sensitive.js
CHANGED
|
@@ -8,7 +8,10 @@ export default (env) => {
|
|
|
8
8
|
return false;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
return
|
|
11
|
+
return (
|
|
12
|
+
/token|password|credential|secret|private|key|auth|webhook/i.test(envVar) &&
|
|
13
|
+
size(env[envVar].trim()) >= SECRET_MIN_SIZE
|
|
14
|
+
);
|
|
12
15
|
});
|
|
13
16
|
|
|
14
17
|
const regexp = new RegExp(
|
package/lib/utils.js
CHANGED
|
@@ -75,7 +75,7 @@ export function getRange(min, max) {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
export function makeTag(tagFormat, version) {
|
|
78
|
-
return template(tagFormat)({ version });
|
|
78
|
+
return template(tagFormat, { evaluate: false, escape: false })({ version });
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
export function isSameChannel(channel, otherChannel) {
|
package/lib/verify.js
CHANGED
|
@@ -15,17 +15,21 @@ export default async (context) => {
|
|
|
15
15
|
errors.push(getError("ENOGITREPO", { cwd }));
|
|
16
16
|
} else if (!repositoryUrl) {
|
|
17
17
|
errors.push(getError("ENOREPOURL"));
|
|
18
|
+
} else if (repositoryUrl.startsWith("-")) {
|
|
19
|
+
// A `repositoryUrl` beginning with `-` would be interpreted by `git` as a
|
|
20
|
+
// command-line option rather than a URL, enabling argument injection.
|
|
21
|
+
errors.push(getError("EINVALIDREPOURL", { repositoryUrl }));
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
// Verify that compiling the `tagFormat` produce a valid Git tag
|
|
21
|
-
if (!(await verifyTagName(template(tagFormat)({ version: "0.0.0" })))) {
|
|
25
|
+
if (!(await verifyTagName(template(tagFormat, { evaluate: false, escape: false })({ version: "0.0.0" })))) {
|
|
22
26
|
errors.push(getError("EINVALIDTAGFORMAT", context));
|
|
23
27
|
}
|
|
24
28
|
|
|
25
29
|
// Verify the `tagFormat` contains the variable `version` by compiling the `tagFormat` template
|
|
26
30
|
// with a space as the `version` value and verify the result contains the space.
|
|
27
31
|
// The space is used as it's an invalid tag character, so it's guaranteed to no be present in the `tagFormat`.
|
|
28
|
-
if ((template(tagFormat)({ version: " " }).match(/ /g) || []).length !== 1) {
|
|
32
|
+
if ((template(tagFormat, { evaluate: false, escape: false })({ version: " " }).match(/ /g) || []).length !== 1) {
|
|
29
33
|
errors.push(getError("ETAGNOVERSION", context));
|
|
30
34
|
}
|
|
31
35
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "semantic-release",
|
|
3
3
|
"description": "Automated semver compliant package publishing",
|
|
4
|
-
"version": "25.0.
|
|
4
|
+
"version": "25.0.8",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Stephan Bönnemann <stephan@boennemann.me> (http://boennemann.me)",
|
|
7
7
|
"ava": {
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"yargs": "^18.0.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@types/node": "24.13.
|
|
60
|
+
"@types/node": "24.13.3",
|
|
61
61
|
"@types/signale": "1.4.7",
|
|
62
62
|
"ava": "8.0.1",
|
|
63
63
|
"c8": "11.0.0",
|
|
@@ -167,5 +167,5 @@
|
|
|
167
167
|
]
|
|
168
168
|
}
|
|
169
169
|
},
|
|
170
|
-
"packageManager": "npm@
|
|
170
|
+
"packageManager": "npm@12.0.1+sha512.2f94fd8bf600416416a934bfc59c4991e8bff7372ef7d842784e2a8b8d48c81555ee645069ddea73625fb8e92dc261feab0188fd5dab6c22fefd46316f5f9140"
|
|
171
171
|
}
|