Skip to content

Commit bad0211

Browse files
authored
chore(github): warn when using default Git author on GitHub.com (renovatebot#41055)
As part of renovatebot#39309 we enabled "Vigilant Mode" for the `@renovate-bot` author. To give an indication to folks who are self-hosting (on GitHub.com) and using this Git commit author, we can provide a log message to let them know. This does not at all stop usage of this default committer email address, but does provide a "nudge" to folks that they may see `Unverified` commits pop up.
1 parent b2c4124 commit bad0211

File tree

3 files changed

+205
-0
lines changed

3 files changed

+205
-0
lines changed

lib/modules/platform/github/index.spec.ts

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,184 @@ describe('modules/platform/github/index', () => {
155155
).toMatchSnapshot();
156156
});
157157

158+
describe('when using the default gitAuthor', () => {
159+
describe('when gitAuthor is not set', () => {
160+
describe('when no email access', () => {
161+
it('if on GitHub.com, a warning is shown', async () => {
162+
httpMock
163+
.scope(githubApiHost)
164+
.get('/user')
165+
.reply(200, {
166+
login: 'some-other-user',
167+
})
168+
.get('/user/emails')
169+
.reply(400);
170+
171+
await github.initPlatform({
172+
token: 'anything',
173+
174+
gitAuthor: undefined,
175+
});
176+
177+
expect(logger.logger.once.warn).toHaveBeenCalledWith(
178+
{
179+
documentationUrl:
180+
'https://github.com/renovatebot/renovate/discussions/39309',
181+
},
182+
'Using the default gitAuthor email address, renovate@whitesourcesoftware.com, is not recommended on GitHub.com, as this corresponds to a user owned by Mend and used by users of the forking-renovate[bot] GitHub App. For security and authenticity reasons, Mend enables "Vigilant Mode" on this account to visibly flag unsigned commits. As an account you do not control, you will not be able to sign commits. If you are comfortable with the `Unverified` signatures on each commit, no work is needed. Otherwise, it is recommended to migrate to a user account you own',
183+
);
184+
});
185+
186+
it('if on GitHub Enterprise, a warning is not shown', async () => {
187+
httpMock
188+
.scope('https://ghe.renovatebot.com')
189+
.head('/')
190+
.reply(200, '', { 'x-github-enterprise-version': '3.10.0' })
191+
.get('/user')
192+
.reply(200, { login: 'renovate-bot' })
193+
.get('/user/emails')
194+
.reply(400);
195+
196+
await github.initPlatform({
197+
token: 'anything',
198+
199+
endpoint: 'https://ghe.renovatebot.com',
200+
gitAuthor: undefined,
201+
});
202+
203+
expect(logger.logger.once.warn).not.toHaveBeenCalled();
204+
});
205+
});
206+
207+
describe('when email access', () => {
208+
it('no warning is shown', async () => {
209+
httpMock
210+
.scope(githubApiHost)
211+
.get('/user')
212+
.reply(200, {
213+
login: 'some-other-user',
214+
})
215+
.get('/user/emails')
216+
.reply(200, [
217+
{
218+
email: 'user@domain.com',
219+
},
220+
]);
221+
222+
await github.initPlatform({
223+
token: 'anything',
224+
225+
gitAuthor: undefined,
226+
});
227+
228+
expect(logger.logger.once.warn).not.toHaveBeenCalled();
229+
});
230+
231+
it('if on GitHub Enterprise, a warning is not shown', async () => {
232+
httpMock
233+
.scope('https://ghe.renovatebot.com')
234+
.head('/')
235+
.reply(200, '', { 'x-github-enterprise-version': '3.10.0' })
236+
.get('/user')
237+
.reply(200, { login: 'renovate-bot' })
238+
.get('/user/emails')
239+
.reply(200, [
240+
{
241+
email: 'user@domain.com',
242+
},
243+
]);
244+
245+
await github.initPlatform({
246+
token: 'anything',
247+
248+
endpoint: 'https://ghe.renovatebot.com',
249+
gitAuthor: undefined,
250+
});
251+
252+
expect(logger.logger.once.warn).not.toHaveBeenCalled();
253+
});
254+
});
255+
});
256+
257+
describe('when explicitly set to only email address', () => {
258+
it('if on GitHub.com, a warning is shown', async () => {
259+
httpMock.scope(githubApiHost).get('/user').reply(200, {
260+
login: 'renovate-bot',
261+
});
262+
263+
await github.initPlatform({
264+
token: 'anything',
265+
266+
gitAuthor: 'renovate@whitesourcesoftware.com',
267+
});
268+
269+
expect(logger.logger.once.warn).toHaveBeenCalledWith(
270+
{
271+
documentationUrl:
272+
'https://github.com/renovatebot/renovate/discussions/39309',
273+
},
274+
'Using the default gitAuthor email address, renovate@whitesourcesoftware.com, is not recommended on GitHub.com, as this corresponds to a user owned by Mend and used by users of the forking-renovate[bot] GitHub App. For security and authenticity reasons, Mend enables "Vigilant Mode" on this account to visibly flag unsigned commits. As an account you do not control, you will not be able to sign commits. If you are comfortable with the `Unverified` signatures on each commit, no work is needed. Otherwise, it is recommended to migrate to a user account you own',
275+
);
276+
});
277+
278+
it('if on GitHub Enterprise, a warning is not shown', async () => {
279+
httpMock
280+
.scope('https://ghe.renovatebot.com')
281+
.head('/')
282+
.reply(200, '', { 'x-github-enterprise-version': '3.10.0' })
283+
.get('/user')
284+
.reply(200, { login: 'renovate-bot' });
285+
await github.initPlatform({
286+
token: 'anything',
287+
288+
endpoint: 'https://ghe.renovatebot.com',
289+
gitAuthor: 'Mend Renovate <renovate@whitesourcesoftware.com>',
290+
});
291+
292+
expect(logger.logger.once.warn).not.toHaveBeenCalled();
293+
});
294+
});
295+
296+
describe('when explicitly set to RFC-RFC5322 format', () => {
297+
it('if on GitHub.com, a warning is shown', async () => {
298+
httpMock.scope(githubApiHost).get('/user').reply(200, {
299+
login: 'renovate-bot',
300+
});
301+
302+
await github.initPlatform({
303+
token: 'anything',
304+
305+
gitAuthor: 'Mend Renovate <renovate@whitesourcesoftware.com>',
306+
});
307+
308+
expect(logger.logger.once.warn).toHaveBeenCalledWith(
309+
{
310+
documentationUrl:
311+
'https://github.com/renovatebot/renovate/discussions/39309',
312+
},
313+
'Using the default gitAuthor email address, renovate@whitesourcesoftware.com, is not recommended on GitHub.com, as this corresponds to a user owned by Mend and used by users of the forking-renovate[bot] GitHub App. For security and authenticity reasons, Mend enables "Vigilant Mode" on this account to visibly flag unsigned commits. As an account you do not control, you will not be able to sign commits. If you are comfortable with the `Unverified` signatures on each commit, no work is needed. Otherwise, it is recommended to migrate to a user account you own',
314+
);
315+
});
316+
317+
it('if on GitHub Enterprise, a warning is not shown', async () => {
318+
httpMock
319+
.scope('https://ghe.renovatebot.com')
320+
.head('/')
321+
.reply(200, '', { 'x-github-enterprise-version': '3.10.0' })
322+
.get('/user')
323+
.reply(200, { login: 'renovate-bot' });
324+
await github.initPlatform({
325+
token: 'anything',
326+
327+
endpoint: 'https://ghe.renovatebot.com',
328+
gitAuthor: 'Mend Renovate <renovate@whitesourcesoftware.com>',
329+
});
330+
331+
expect(logger.logger.once.warn).not.toHaveBeenCalled();
332+
});
333+
});
334+
});
335+
158336
it('should support default endpoint with email', async () => {
159337
httpMock
160338
.scope(githubApiHost)

lib/modules/platform/github/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ import type {
9999
PlatformConfig,
100100
} from './types.ts';
101101
import { getAppDetails, getUserDetails, getUserEmail } from './user.ts';
102+
import { warnIfDefaultGitAuthorEmail } from './utils.ts';
102103

103104
export const id = 'github';
104105

@@ -222,6 +223,9 @@ export async function initPlatform({
222223
renovateUsername,
223224
token,
224225
};
226+
227+
warnIfDefaultGitAuthorEmail(platformResult.gitAuthor, platformConfig.isGhe);
228+
225229
if (
226230
getEnv().RENOVATE_X_GITHUB_HOST_RULES &&
227231
platformResult.endpoint === 'https://api.github.com/'
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { logger } from '../../../logger/index.ts';
2+
import { parseGitAuthor } from '../../../util/git/author.ts';
3+
4+
export function warnIfDefaultGitAuthorEmail(
5+
gitAuthor: string | undefined,
6+
isGHE: boolean | undefined,
7+
): void {
8+
if (isGHE === true) {
9+
return;
10+
}
11+
const parsed = parseGitAuthor(
12+
gitAuthor ?? 'renovate@whitesourcesoftware.com',
13+
);
14+
if (parsed?.address === 'renovate@whitesourcesoftware.com') {
15+
logger.once.warn(
16+
{
17+
documentationUrl:
18+
'https://github.com/renovatebot/renovate/discussions/39309',
19+
},
20+
'Using the default gitAuthor email address, renovate@whitesourcesoftware.com, is not recommended on GitHub.com, as this corresponds to a user owned by Mend and used by users of the forking-renovate[bot] GitHub App. For security and authenticity reasons, Mend enables "Vigilant Mode" on this account to visibly flag unsigned commits. As an account you do not control, you will not be able to sign commits. If you are comfortable with the `Unverified` signatures on each commit, no work is needed. Otherwise, it is recommended to migrate to a user account you own',
21+
);
22+
}
23+
}

0 commit comments

Comments
 (0)