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 #2,3,4,5,6,7,8,9,10,11 #3805

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e9810d8
Fix code scanning alert no. 3: Disabling certificate validation
guruh46 Nov 27, 2024
e19cea4
Fix code scanning alert no. 10: Incomplete string escaping or encoding
guruh46 Nov 27, 2024
2da3d67
Fix code scanning alert no. 9: Incomplete string escaping or encoding
guruh46 Nov 27, 2024
56c58c2
Fix code scanning alert no. 8: Incomplete string escaping or encoding
guruh46 Nov 27, 2024
bf1cf07
Fix code scanning alert no. 7: Incomplete string escaping or encoding
guruh46 Nov 27, 2024
c92af19
Fix code scanning alert no. 6: Incomplete string escaping or encoding
guruh46 Nov 27, 2024
646f5a0
Fix code scanning alert no. 5: Incomplete string escaping or encoding
guruh46 Nov 27, 2024
e8dca0c
Fix code scanning alert no. 4: Incomplete string escaping or encoding
guruh46 Nov 27, 2024
86caf2e
Fix code scanning alert no. 2: Incomplete URL substring sanitization
guruh46 Nov 27, 2024
22479a8
Merge pull request #9 from guruh46/alert-autofix-2
guruh46 Nov 27, 2024
23580e5
Merge pull request #8 from guruh46/alert-autofix-4
guruh46 Nov 27, 2024
d86815b
Merge pull request #7 from guruh46/alert-autofix-5
guruh46 Nov 27, 2024
920225f
Merge pull request #6 from guruh46/alert-autofix-6
guruh46 Nov 27, 2024
0ae4047
Merge pull request #5 from guruh46/alert-autofix-7
guruh46 Nov 27, 2024
1ebfa1a
Merge pull request #4 from guruh46/alert-autofix-8
guruh46 Nov 27, 2024
9a7f6b3
Merge pull request #3 from guruh46/alert-autofix-9
guruh46 Nov 27, 2024
60a3be6
Merge pull request #2 from guruh46/alert-autofix-10
guruh46 Nov 27, 2024
4e65793
Merge pull request #1 from guruh46/alert-autofix-3
guruh46 Nov 27, 2024
179fd88
Fix code scanning alert no. 11: Disabling certificate validation
guruh46 Nov 27, 2024
bc73a36
Merge pull request #10 from guruh46/alert-autofix-11
guruh46 Nov 27, 2024
4bcd494
Merge branch 'gitkraken:main' into main
guruh46 Nov 28, 2024
894960a
Merge branch 'gitkraken:main' into main
guruh46 Dec 8, 2024
7fad88e
Merge branch 'gitkraken:main' into main
guruh46 Dec 10, 2024
b53fcfb
Merge branch 'gitkraken:main' into main
guruh46 Dec 11, 2024
bd8fab6
Merge branch 'gitkraken:main' into main
guruh46 Dec 13, 2024
28651b8
Merge branch 'gitkraken:main' into main
guruh46 Dec 20, 2024
1e44924
Merge branch 'gitkraken:main' into main
guruh46 Jan 1, 2025
417a385
Merge branch 'gitkraken:main' into main
guruh46 Jan 7, 2025
6d42213
Merge branch 'gitkraken:main' into main
guruh46 Jan 9, 2025
c5840d1
Merge branch 'gitkraken:main' into main
guruh46 Jan 18, 2025
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
16 changes: 15 additions & 1 deletion src/ai/openaiProvider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { configuration } from '../system/vscode/configuration';
import type { AIModel } from './aiProviderService';
import { OpenAICompatibleProvider } from './openAICompatibleProvider';
import * as urlLib from 'url';

const provider = { id: 'openai', name: 'OpenAI' } as const;

Expand Down Expand Up @@ -183,7 +184,8 @@ export class OpenAIProvider extends OpenAICompatibleProvider<typeof provider.id>
url: string,
apiKey: string,
): Record<string, string> {
if (url.includes('.azure.com')) {
const parsedUrl = urlLib.parse(url);
if (this.isAllowedHost(parsedUrl.host)) {
return {
Accept: 'application/json',
'Content-Type': 'application/json',
Expand All @@ -193,4 +195,16 @@ export class OpenAIProvider extends OpenAICompatibleProvider<typeof provider.id>

return super.getHeaders(model, url, apiKey);
}

private isAllowedHost(host: string | null): boolean {
if (!host) return false;
const allowedHosts = [
'azure.com',
'*.azure.com'
];
return allowedHosts.some(allowedHost => {
const regex = new RegExp(`^${allowedHost.replace('*.', '.*\\.')}$`);
return regex.test(host);
});
}
}
2 changes: 1 addition & 1 deletion src/autolinks/autolinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ export class Autolinks implements Disposable {
} else {
const issue = issueResult.value;
const issueTitle = escapeMarkdown(issue.title.trim());
const issueTitleQuoteEscaped = issueTitle.replace(/"/g, '\\"');
const issueTitleQuoteEscaped = issueTitle.replace(/(["\\])/g, '\\$1');

if (footnotes != null && !prs?.has(num)) {
footnoteIndex = footnotes.size + 1;
Expand Down
8 changes: 4 additions & 4 deletions src/env/node/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ export async function wrapForForcedInsecureSSL<T>(
): Promise<T> {
if (ignoreSSLErrors !== 'force') return fetchFn();

const previousRejectUnauthorized = process.env.NODE_TLS_REJECT_UNAUTHORIZED;
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
const https = require('https');
const agent = new https.Agent();

try {
return await fetchFn();
return await fetchFn({ agent });
} finally {
process.env.NODE_TLS_REJECT_UNAUTHORIZED = previousRejectUnauthorized;
// No need to restore global state
}
}
6 changes: 3 additions & 3 deletions src/git/formatters/commitFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ export class CommitFormatter extends Formatter<GitCommit, CommitFormatOptions> {
pullRequest: { id: pr.id, url: pr.url },
})} "Open Pull Request \\#${pr.id}${
Container.instance.actionRunners.count('openPullRequest') === 1 ? ` on ${pr.provider.name}` : '...'
}\n${GlyphChars.Dash.repeat(2)}\n${escapeMarkdown(pr.title).replace(/"/g, '\\"')}\n${
}\n${GlyphChars.Dash.repeat(2)}\n${escapeMarkdown(pr.title).replace(/\\/g, '\\\\').replace(/"/g, '\\"')}\n${
pr.state
}, ${pr.formatDateFromNow()}")`;
} else if (isPromise(pr)) {
Expand Down Expand Up @@ -783,12 +783,12 @@ export class CommitFormatter extends Formatter<GitCommit, CommitFormatOptions> {
pullRequest: { id: pr.id, url: pr.url },
})} "Open Pull Request \\#${pr.id}${
Container.instance.actionRunners.count('openPullRequest') === 1 ? ` on ${pr.provider.name}` : '...'
}\n${GlyphChars.Dash.repeat(2)}\n${escapeMarkdown(pr.title).replace(/"/g, '\\"')}\n${
}\n${GlyphChars.Dash.repeat(2)}\n${escapeMarkdown(pr.title).replace(/\\/g, '\\\\').replace(/"/g, '\\"')}\n${
pr.state
}, ${pr.formatDateFromNow()}")`;

if (this._options.footnotes != null) {
const prTitle = escapeMarkdown(pr.title).replace(/"/g, '\\"').trim();
const prTitle = escapeMarkdown(pr.title).replace(/\\/g, '\\\\').replace(/"/g, '\\"').trim();

const index = this._options.footnotes.size + 1;
this._options.footnotes.set(
Expand Down
2 changes: 1 addition & 1 deletion src/git/remotes/bitbucket-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export class BitbucketServerRemote extends RemoteProvider {
}

protected override getUrlForComparison(base: string, compare: string, _notation: '..' | '...'): string {
return this.encodeUrl(`${this.baseUrl}/branches/compare/${base}%0D${compare}`).replace('%250D', '%0D');
return this.encodeUrl(`${this.baseUrl}/branches/compare/${base}%0D${compare}`).replace(/%250D/g, '%0D');
}

protected getUrlForFile(fileName: string, branch?: string, sha?: string, range?: Range): string {
Expand Down
2 changes: 1 addition & 1 deletion src/git/remotes/bitbucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export class BitbucketRemote extends RemoteProvider {
}

protected override getUrlForComparison(base: string, compare: string, _notation: '..' | '...'): string {
return this.encodeUrl(`${this.baseUrl}/branches/compare/${base}%0D${compare}`).replace('%250D', '%0D');
return this.encodeUrl(`${this.baseUrl}/branches/compare/${base}%0D${compare}`).replace(/%250D/g, '%0D');
}

protected getUrlForFile(fileName: string, branch?: string, sha?: string, range?: Range): string {
Expand Down
7 changes: 3 additions & 4 deletions src/system/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ export function createMarkdownCommandLink<T>(command: Commands, args: T): string
if (args == null) return `command:${command}`;

// Since we are using the command in a markdown link, we need to escape ()'s so they don't get interpreted as markdown
return `command:${command}?${encodeURIComponent(typeof args === 'string' ? args : JSON.stringify(args)).replace(
/([()])/g,
'\\$1',
)}`;
return `command:${command}?${encodeURIComponent(typeof args === 'string' ? args : JSON.stringify(args))
.replace(/\\/g, '\\\\')
.replace(/([()])/g, '\\$1')}`;
}