@appaflytech/zeyrek-ai-mcp 0.0.60 → 0.0.62
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.
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// `//` önünde `:` (https://), `(` (url(//cdn)), tırnak (src="//cdn"), eğik çizgi ya da harf varsa yorum değildir.
|
|
2
|
+
const commentPattern = /([ \t]*)(\/\*[\s\S]*?\*\/|<!--[\s\S]*?-->|(?<![:/\\(\w'"`])\/\/[^\n]*)(\n?)/g;
|
|
3
|
+
const LEAKS = [
|
|
4
|
+
{ label: 'dal adı', pattern: /\b(?:feature|feat|fix|hotfix|bugfix|chore|refactor|release)\/[\w.-]+/i },
|
|
5
|
+
{ label: 'kaynak dizini', pattern: /\bzeyrek-(?:frontend|backend|mcp|monitoring|qm-extension)\b|\bng-apps-[a-z][\w-]*|\b(?:apps|packages|src|Contexts)\/[\w.*-]+|(?:^|[\s(])\.(?:superpowers|claude)\b/i },
|
|
6
|
+
{ label: 'kaynak dosyası', pattern: /\b[\w*-]+\.(?:svelte|cs|csproj|tsx?|mts|cts|py)\b/i },
|
|
7
|
+
{ label: 'çatı adı', pattern: /\bsvelte\b/i },
|
|
8
|
+
{ label: 'mimari karar kaydı', pattern: /\bADR[\s-]?\d{2,4}\b/i }
|
|
9
|
+
];
|
|
10
|
+
const EXCERPT_RADIUS = 40;
|
|
11
|
+
function mayHoldComment(text) {
|
|
12
|
+
return text.includes('/*') || text.includes('//') || text.includes('<!--');
|
|
13
|
+
}
|
|
14
|
+
export function commentsIn(text) {
|
|
15
|
+
if (!mayHoldComment(text))
|
|
16
|
+
return [];
|
|
17
|
+
return [...text.matchAll(commentPattern)].map(match => match[2]);
|
|
18
|
+
}
|
|
19
|
+
function leaksInComment(comment, path) {
|
|
20
|
+
return LEAKS.flatMap(({ label, pattern }) => {
|
|
21
|
+
const match = pattern.exec(comment);
|
|
22
|
+
if (!match)
|
|
23
|
+
return [];
|
|
24
|
+
const start = Math.max(0, match.index - EXCERPT_RADIUS);
|
|
25
|
+
const end = Math.min(comment.length, match.index + match[0].length + EXCERPT_RADIUS);
|
|
26
|
+
return [{ path, label, excerpt: comment.slice(start, end).replace(/\s+/g, ' ').trim() }];
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function walk(value, path, leaks) {
|
|
30
|
+
if (typeof value === 'string') {
|
|
31
|
+
for (const comment of commentsIn(value))
|
|
32
|
+
leaks.push(...leaksInComment(comment, path));
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (Array.isArray(value)) {
|
|
36
|
+
value.forEach((item, index) => walk(item, `${path}[${index}]`, leaks));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (value && typeof value === 'object') {
|
|
40
|
+
for (const [key, item] of Object.entries(value))
|
|
41
|
+
walk(item, path === '' ? key : `${path}.${key}`, leaks);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export function sourceLeaksIn(value) {
|
|
45
|
+
const leaks = [];
|
|
46
|
+
walk(value, '', leaks);
|
|
47
|
+
return leaks;
|
|
48
|
+
}
|
|
49
|
+
const LISTED = 5;
|
|
50
|
+
export function sourceLeakFindings(leaks) {
|
|
51
|
+
const findings = leaks.slice(0, LISTED).map(leak => ({
|
|
52
|
+
ruleId: 'SRC-001',
|
|
53
|
+
severity: 'block',
|
|
54
|
+
message: `${leak.path || 'gövde'}: yorumda platform ${leak.label} geçiyor — \`${leak.excerpt}\`. Uygulama şemasına yorum dahil platform kaynak kodu bilgisi (dizin, dosya, dal, çatı adı, ADR) yazılmaz: yorumu kaldırın ya da atfı çıkarın; gerekçe repodaki docs/apps/<uygulama>/ dokümanına yazılır`
|
|
55
|
+
}));
|
|
56
|
+
if (leaks.length > LISTED)
|
|
57
|
+
findings.push({ ruleId: 'SRC-001', severity: 'block', message: `… ve ${leaks.length - LISTED} yerde daha` });
|
|
58
|
+
return findings;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Temizlikte yorumun yalnız sızan parçası değil tamamı silinir (kullanıcı, 2026-11-03): parça silmek yarım cümle
|
|
62
|
+
* bırakır. Satırın tek içeriği olan yorum satırıyla birlikte gider; kodun yanındaki yorum önündeki boşlukla gider.
|
|
63
|
+
*/
|
|
64
|
+
export function stripSourceLeakComments(text) {
|
|
65
|
+
if (!mayHoldComment(text))
|
|
66
|
+
return text;
|
|
67
|
+
return text.replace(commentPattern, (match, _lead, comment, newline, offset, whole) => {
|
|
68
|
+
if (leaksInComment(comment, '').length === 0)
|
|
69
|
+
return match;
|
|
70
|
+
return offset === 0 || whole[offset - 1] === '\n' ? '' : newline;
|
|
71
|
+
});
|
|
72
|
+
}
|
package/dist/platform/http.js
CHANGED
|
@@ -4,6 +4,8 @@ import { AsyncLocalStorage } from 'node:async_hooks';
|
|
|
4
4
|
import { TokenProvider } from './token.js';
|
|
5
5
|
import { randomUUID } from 'node:crypto';
|
|
6
6
|
import { request } from 'undici';
|
|
7
|
+
import { PolicyBlockError } from '../knowledge/policy.js';
|
|
8
|
+
import { sourceLeakFindings, sourceLeaksIn } from '../knowledge/sourceLeak.js';
|
|
7
9
|
export const requestAuthStorage = new AsyncLocalStorage();
|
|
8
10
|
const hiddenResponseHeaders = new Set(['set-cookie', 'authorization', 'proxy-authorization']);
|
|
9
11
|
/**
|
|
@@ -140,6 +142,12 @@ export class Platform {
|
|
|
140
142
|
return `Bearer ${await this.tokens.getToken()}`;
|
|
141
143
|
}
|
|
142
144
|
async send(api, method, path, options, raw = false, isRetry = false, networkAttempt = 1) {
|
|
145
|
+
// SRC-001 (2026-11-03): her yazma yolu buradan geçer; araç başına kapı bir yolu atlardı. Mutlak kapıdır.
|
|
146
|
+
if (options.body !== undefined && method !== 'GET' && method !== 'HEAD' && !isRetry && networkAttempt === 1) {
|
|
147
|
+
const leaks = sourceLeaksIn(options.body);
|
|
148
|
+
if (leaks.length > 0)
|
|
149
|
+
throw new PolicyBlockError(sourceLeakFindings(leaks), false);
|
|
150
|
+
}
|
|
143
151
|
const baseUrl = api === 'org' ? this.config.orgApiBaseUrl : this.config.tenantApiBaseUrl;
|
|
144
152
|
const context = { api, method, path, baseUrl, environment: options.environment, authMode: this.config.authMode };
|
|
145
153
|
const url = new URL(`${baseUrl}${path}`);
|
|
@@ -101,6 +101,10 @@ yeniden girilebilir yaz ya da `onCleanup` kullan.
|
|
|
101
101
|
- ✘ `set_event` ile `kaydet` olayına bağ kurmaya çalışmak (PAGE-008 reddeder). ✔ `actions`
|
|
102
102
|
satırının `flow` prop'u.
|
|
103
103
|
- ✘ `setInterval`'i temizliksiz kurmak (içerik değişince ikinci kopya başlar). ✔ `onCleanup`.
|
|
104
|
+
- ✘ CSS/JS/HTML yorumunda platformun kaynak kodunu anmak: dizin (`ng-apps-ui`, `packages/…`), dosya
|
|
105
|
+
(`Table.svelte`, `HttpStep.cs`), dal (`feature/…`), çatı adı (Svelte), ADR. ✔ Yorum yalnız uygulamanın
|
|
106
|
+
kendi diliyle ne yapıldığını söyler; gerekçe ve kaynak uygulamanın repodaki dokümanına yazılır.
|
|
107
|
+
Gateway böyle bir yorum taşıyan **her** yazmayı durdurur (SRC-001, `policyOverride` geçmez).
|
|
104
108
|
|
|
105
109
|
Kaynak: `zeyrek-frontend/packages/ng-apps-ui/src/components/html/*` (Html.svelte, html.functions.ts,
|
|
106
110
|
schema.ts) ve `zeyrek-frontend/docs/features/html-component.md`.
|
package/package.json
CHANGED