Repository navigation
Expand file tree
/
Copy pathsecure-code-assistant.ts
More file actions
44 lines (36 loc) · 2.06 KB
/
Copy pathsecure-code-assistant.ts
File metadata and controls
44 lines (36 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import * as vscode from 'vscode';
export function activate(context: vscode.ExtensionContext) {
console.log('Tebrikler dostum, "secure-code-assistant" aktif ve siber kalkan hazır!');
// 1. Ana Komut Kaydı
const startCommand = vscode.commands.registerCommand('secure-code-assistant.start', () => {
vscode.window.showInformationMessage('Güvenli Kod Asistanı Aktif Edildi! Siber kalkanlar devrede.');
});
context.subscriptions.push(startCommand);
// 2. XSS Kalkanı (CompletionItemProvider)
const xssShieldProvider = vscode.languages.registerCompletionItemProvider(
{ scheme: 'file', language: 'typescript' }, // Sadece TS dosyalarında çalışsın
{
provideCompletionItems(document: vscode.TextDocument, position: vscode.Position) {
const completionItem = new vscode.CompletionItem("!sec-xss", vscode.CompletionItemKind.Snippet);
completionItem.insertText = new vscode.SnippetString(
'function secureXssClean(input: string): string {\n' +
' if (!input) return "";\n' +
' return input\n' +
' .replace(/&/g, "&")\n' +
' .replace(/</g, "<")\n' +
' .replace(/>/g, ">")\n' +
' .replace(/"/g, """)\n' +
' .replace(/\'/g, "'")\n' +
' .replace(/\\//g, "/");\n' +
'}\n' +
'// Örnek Kullanım: const temizVeri = secureXssClean(kullaniciGirdisi);'
);
completionItem.documentation = new vscode.MarkdownString("Yazılımcıyı XSS (Cross-Site Scripting) açıklarına karşı koruyan siber güvenlik kalkanı.");
return [completionItem];
}
},
'!' // Tetikleyici karakterimiz
);
context.subscriptions.push(xssShieldProvider);
}
export function deactivate() {}