Skip to content
Snippets Groups Projects
Unverified Commit 99467af0 authored by Sergei Zharinov's avatar Sergei Zharinov Committed by GitHub
Browse files

fix(go): Disable direct digest fetch for GOPROXY containing "off" (#27672)

parent be3b29e4
No related branches found
No related tags found
No related merge requests found
......@@ -193,5 +193,20 @@ describe('modules/datasource/go/index', () => {
expect(res).not.toBeNull();
expect(res).toBeDefined();
});
describe('GOPROXY', () => {
afterEach(() => {
delete process.env.GOPROXY;
});
it('returns null when GOPROXY contains off', async () => {
process.env.GOPROXY = 'https://proxy.golang.org,off';
const res = await datasource.getDigest(
{ packageName: 'golang.org/x/text' },
'v1.2.3',
);
expect(res).toBeNull();
});
});
});
});
import is from '@sindresorhus/is';
import { logger } from '../../../logger';
import { cache } from '../../../util/cache/package/decorator';
import { regEx } from '../../../util/regex';
import { addSecretForSanitizing } from '../../../util/sanitize';
......@@ -11,6 +12,7 @@ import { GithubTagsDatasource } from '../github-tags';
import { GitlabTagsDatasource } from '../gitlab-tags';
import type { DigestConfig, GetReleasesConfig, ReleaseResult } from '../types';
import { BaseGoDatasource } from './base';
import { parseGoproxy } from './goproxy-parser';
import { GoDirectDatasource } from './releases-direct';
import { GoProxyDatasource } from './releases-goproxy';
......@@ -63,6 +65,13 @@ export class GoDatasource extends Datasource {
{ packageName }: DigestConfig,
value?: string | null,
): Promise<string | null> {
if (parseGoproxy().some(({ url }) => url === 'off')) {
logger.debug(
`Skip digest fetch for ${packageName} with GOPROXY containing "off"`,
);
return null;
}
const source = await BaseGoDatasource.getDatasource(packageName);
if (!source) {
return null;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment