@theone1345/smartrelay 0.2.0 â 0.3.0
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.
- package/LICENSE +21 -0
- package/README.md +127 -17
- package/config/runners/agents.yaml +14 -1
- package/dist/credentials.d.ts +94 -0
- package/dist/credentials.js +168 -0
- package/dist/credentials.js.map +1 -0
- package/dist/http-api.d.ts +1 -7
- package/dist/http-api.js +6 -169
- package/dist/http-api.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/install.d.ts +57 -0
- package/dist/install.js +216 -0
- package/dist/install.js.map +1 -0
- package/dist/logger.d.ts +2 -0
- package/dist/logger.js +21 -1
- package/dist/logger.js.map +1 -1
- package/dist/profiles/review-profiles.d.ts +32 -0
- package/dist/profiles/review-profiles.js +348 -0
- package/dist/profiles/review-profiles.js.map +1 -0
- package/dist/router.js +18 -3
- package/dist/router.js.map +1 -1
- package/dist/runners/anthropic.js +2 -3
- package/dist/runners/anthropic.js.map +1 -1
- package/dist/runners/base.d.ts +8 -0
- package/dist/runners/base.js +13 -0
- package/dist/runners/base.js.map +1 -1
- package/dist/runners/openai.js +2 -3
- package/dist/runners/openai.js.map +1 -1
- package/dist/runners/registry.d.ts +2 -0
- package/dist/runners/registry.js +4 -0
- package/dist/runners/registry.js.map +1 -1
- package/dist/server.d.ts +1 -6
- package/dist/server.js +134 -66
- package/dist/server.js.map +1 -1
- package/dist/setup.d.ts +65 -0
- package/dist/setup.js +411 -0
- package/dist/setup.js.map +1 -0
- package/dist/tools/dispatch.d.ts +33 -0
- package/dist/tools/dispatch.js +222 -0
- package/dist/tools/dispatch.js.map +1 -0
- package/dist/tools/handlers.d.ts +8 -2
- package/dist/tools/handlers.js +119 -27
- package/dist/tools/handlers.js.map +1 -1
- package/dist/util.d.ts +37 -4
- package/dist/util.js +71 -15
- package/dist/util.js.map +1 -1
- package/package.json +28 -3
- package/prompts/code_review.md +26 -20
- package/prompts/security_audit.md +109 -0
package/dist/util.js
CHANGED
|
@@ -54,33 +54,89 @@ export function findProjectRoot(startDir = import.meta.dirname) {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
57
|
+
* Directory holding SmartRelay's user-level state, `~/.smartrelay` by default.
|
|
58
|
+
*
|
|
59
|
+
* `SMARTRELAY_HOME` overrides it so tests can redirect the credential file to a
|
|
60
|
+
* temp dir without ever touching the developer's real home directory.
|
|
61
|
+
*/
|
|
62
|
+
export function smartrelayHome(override) {
|
|
63
|
+
if (override)
|
|
64
|
+
return override;
|
|
65
|
+
const fromEnv = process.env['SMARTRELAY_HOME'];
|
|
66
|
+
if (fromEnv)
|
|
67
|
+
return resolveUserPath(fromEnv);
|
|
68
|
+
return path.join(homedir(), '.smartrelay');
|
|
69
|
+
}
|
|
70
|
+
/** The global credential file written by `smartrelay setup`. */
|
|
71
|
+
export function globalEnvPath(homeOverride) {
|
|
72
|
+
return path.join(smartrelayHome(homeOverride), '.env');
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Parse `.env` text into ordered key/value pairs.
|
|
76
|
+
*
|
|
77
|
+
* A `Map` rather than a plain object: insertion order is preserved and a key
|
|
78
|
+
* literally named `__proto__` cannot poison a prototype.
|
|
59
79
|
*
|
|
60
80
|
* Deliberately hand-rolled rather than delegating to a dotenv package so the
|
|
61
|
-
* quote-stripping
|
|
81
|
+
* quote-stripping behavior stays identical to the Python original. The setup
|
|
82
|
+
* wizard reuses this so the writer and the loader can never disagree about it.
|
|
62
83
|
*/
|
|
63
|
-
export function
|
|
64
|
-
const
|
|
84
|
+
export function parseEnvText(text) {
|
|
85
|
+
const parsed = new Map();
|
|
86
|
+
for (const rawLine of text.split(/\r?\n/)) {
|
|
87
|
+
const line = rawLine.trim();
|
|
88
|
+
if (!line || line.startsWith('#') || !line.includes('='))
|
|
89
|
+
continue;
|
|
90
|
+
const splitAt = line.indexOf('=');
|
|
91
|
+
const key = line.slice(0, splitAt).trim();
|
|
92
|
+
const value = stripChar(stripChar(line.slice(splitAt + 1).trim(), "'"), '"');
|
|
93
|
+
if (key)
|
|
94
|
+
parsed.set(key, value);
|
|
95
|
+
}
|
|
96
|
+
return parsed;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Populate `process.env` from the `.env` files SmartRelay knows about.
|
|
100
|
+
*
|
|
101
|
+
* Precedence, highest first:
|
|
102
|
+
* 1. variables already in `process.env`
|
|
103
|
+
* 2. `<cwd>/.env` â project-local
|
|
104
|
+
* 3. `<project root>/.env`
|
|
105
|
+
* 4. `~/.smartrelay/.env` â written by `smartrelay setup`
|
|
106
|
+
*
|
|
107
|
+
* Every candidate is read, not just the first that exists: the global file is a
|
|
108
|
+
* fallback for keys a project never defines. Since the assignment below only
|
|
109
|
+
* fills in names that are still unset, reading the list in order produces that
|
|
110
|
+
* precedence for free.
|
|
111
|
+
*
|
|
112
|
+
* `cwd`/`home` exist only so tests can point at temp directories â `process.chdir`
|
|
113
|
+
* is process-global and unsafe across parallel test files.
|
|
114
|
+
*/
|
|
115
|
+
export function loadDotEnv(options) {
|
|
116
|
+
const candidates = [
|
|
117
|
+
path.join(options?.cwd ?? process.cwd(), '.env'),
|
|
118
|
+
path.join(findProjectRoot(), '.env'),
|
|
119
|
+
];
|
|
120
|
+
// Escape hatch for the test suite, which must never read a developer's real
|
|
121
|
+
// credentials just because `server.ts` calls this at module scope.
|
|
122
|
+
if (process.env['SMARTRELAY_SKIP_GLOBAL_ENV'] !== '1') {
|
|
123
|
+
candidates.push(globalEnvPath(options?.home));
|
|
124
|
+
}
|
|
125
|
+
const seen = new Set();
|
|
65
126
|
for (const envFile of candidates) {
|
|
66
|
-
|
|
127
|
+
const resolved = path.resolve(envFile);
|
|
128
|
+
if (seen.has(resolved) || !existsSync(resolved))
|
|
67
129
|
continue;
|
|
130
|
+
seen.add(resolved);
|
|
68
131
|
try {
|
|
69
|
-
for (const
|
|
70
|
-
|
|
71
|
-
if (!line || line.startsWith('#') || !line.includes('='))
|
|
72
|
-
continue;
|
|
73
|
-
const splitAt = line.indexOf('=');
|
|
74
|
-
const key = line.slice(0, splitAt).trim();
|
|
75
|
-
const value = stripChar(stripChar(line.slice(splitAt + 1).trim(), "'"), '"');
|
|
76
|
-
if (key && !(key in process.env))
|
|
132
|
+
for (const [key, value] of parseEnvText(readFileSync(resolved, 'utf-8'))) {
|
|
133
|
+
if (!(key in process.env))
|
|
77
134
|
process.env[key] = value;
|
|
78
135
|
}
|
|
79
136
|
}
|
|
80
137
|
catch {
|
|
81
138
|
// Matches the Python original: a malformed .env is ignored, not fatal.
|
|
82
139
|
}
|
|
83
|
-
break;
|
|
84
140
|
}
|
|
85
141
|
}
|
|
86
142
|
/** Counting semaphore, replacing `asyncio.Semaphore`. */
|
package/dist/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,yFAAyF;AAEzF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B;;;;;;GAMG;AACH,MAAM,UAAU,KAAK,CAAC,KAAa,EAAE,MAAM,GAAG,CAAC;IAC7C,MAAM,MAAM,GAAG,EAAE,IAAI,MAAM,CAAC;IAC5B,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC,GAAG,MAAM,CAAC;AAC7C,CAAC;AAED,kGAAkG;AAClG,MAAM,UAAU,SAAS,CAAC,KAAa,EAAE,IAAY;IACnD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC;IACvB,OAAO,KAAK,GAAG,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,KAA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,YAAY,CAAC,KAAc;IACzC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theone1345/smartrelay",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "MCP server for delegating tasks across LLM backends and benchmarking their outputs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./dispatch": {
|
|
14
|
+
"types": "./dist/tools/dispatch.d.ts",
|
|
15
|
+
"default": "./dist/tools/dispatch.js"
|
|
16
|
+
},
|
|
17
|
+
"./credentials": {
|
|
18
|
+
"types": "./dist/credentials.d.ts",
|
|
19
|
+
"default": "./dist/credentials.js"
|
|
20
|
+
},
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
8
23
|
"license": "MIT",
|
|
9
24
|
"author": "Dhavan Bhalodiya",
|
|
10
25
|
"repository": {
|
|
@@ -32,7 +47,8 @@
|
|
|
32
47
|
"bin": {
|
|
33
48
|
"smartrelay": "dist/server.js",
|
|
34
49
|
"mcp-delegation-server": "dist/server.js",
|
|
35
|
-
"smartrelay-http": "dist/http-api.js"
|
|
50
|
+
"smartrelay-http": "dist/http-api.js",
|
|
51
|
+
"smartrelay-setup": "dist/setup.js"
|
|
36
52
|
},
|
|
37
53
|
"files": [
|
|
38
54
|
"dist",
|
|
@@ -51,7 +67,10 @@
|
|
|
51
67
|
"test": "vitest run",
|
|
52
68
|
"test:watch": "vitest",
|
|
53
69
|
"quick-test": "tsx scripts/quick-test.ts",
|
|
54
|
-
"test:plugin": "tsx scripts/test-plugin.ts"
|
|
70
|
+
"test:plugin": "tsx scripts/test-plugin.ts",
|
|
71
|
+
"test:review": "tsx scripts/test-review.ts",
|
|
72
|
+
"setup": "tsx src/setup.ts",
|
|
73
|
+
"build:plugin": "npm --workspace plugin-smartrelay run build"
|
|
55
74
|
},
|
|
56
75
|
"dependencies": {
|
|
57
76
|
"@anthropic-ai/sdk": "^0.124.0",
|
|
@@ -66,5 +85,11 @@
|
|
|
66
85
|
"tsx": "^4.23.13",
|
|
67
86
|
"typescript": "^7.0.2",
|
|
68
87
|
"vitest": "^5.0.0"
|
|
88
|
+
},
|
|
89
|
+
"workspaces": [
|
|
90
|
+
"plugin-smartrelay"
|
|
91
|
+
],
|
|
92
|
+
"publishConfig": {
|
|
93
|
+
"access": "public"
|
|
69
94
|
}
|
|
70
95
|
}
|
package/prompts/code_review.md
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
You are a Principal Code Reviewer & Systems Architect
|
|
2
|
-
|
|
3
|
-
SCOPE CHECK:
|
|
4
|
-
If the provided code is not Dart/Flutter, output only:
|
|
5
|
-
"â ī¸ This reviewer is scoped to Dart/Flutter. No review performed." â then stop.
|
|
1
|
+
You are a Principal Code Reviewer & Systems Architect.
|
|
2
|
+
You perform in-depth, expert code reviews across Flutter/Dart, TypeScript, Python, Go, Rust, and modern multi-language codebases.
|
|
6
3
|
|
|
7
4
|
Analyze the code with deep precision against these critical inspection vectors:
|
|
8
5
|
|
|
9
6
|
1. Resource Cleanup & Memory:
|
|
10
|
-
-
|
|
7
|
+
- Unclosed connections/handles, uncancelled streams/timers, or un-disposed resources (e.g. Flutter controllers, DB connections, goroutines, or setState without mounted checks).
|
|
11
8
|
2. Security & Secrets:
|
|
12
|
-
- Hardcoded API keys, private tokens, credentials, sensitive URLs, injection flaws, or insecure storage.
|
|
9
|
+
- Hardcoded API keys, private tokens, credentials, sensitive URLs, injection flaws (SQL/Command/XSS), or insecure storage.
|
|
13
10
|
3. Null Safety & Type Robustness:
|
|
14
|
-
- Dangerous null assertion operators (`!`), unsafe dynamic
|
|
15
|
-
- Do NOT flag `!` where nullability is already provably eliminated by a prior guard
|
|
11
|
+
- Dangerous null assertion operators (`!`), unsafe dynamic casting, and unhandled nullable/undefined values.
|
|
12
|
+
- Do NOT flag `!` where nullability is already provably eliminated by a prior guard.
|
|
16
13
|
4. State & Error Resilience:
|
|
17
|
-
- Unhandled async Future/Stream exceptions, missing
|
|
18
|
-
5. Performance &
|
|
19
|
-
-
|
|
14
|
+
- Unhandled async Future/Stream/Promise exceptions, missing error states, or unhandled failures/crashes.
|
|
15
|
+
5. Performance & Resource Efficiency:
|
|
16
|
+
- Inefficient algorithms, missing const/immutable declarations, unnecessary heavy allocations, and redundant recomputations.
|
|
20
17
|
|
|
21
|
-
GROUNDING
|
|
22
|
-
Only report issues you can point to directly in the provided code.
|
|
18
|
+
GROUNDING & FALSE-POSITIVE SUPPRESSION RULES:
|
|
19
|
+
1. Only report issues you can point to directly in the provided code.
|
|
20
|
+
2. NEVER flag missing imports, missing functions, or truncated dependencies when reviewing an isolated snippet or partial file.
|
|
21
|
+
3. If an issue is uncertain without broader project context, downgrade it to a đĄ Suggestion or omit it entirely.
|
|
22
|
+
4. Diffs MUST include 1-2 lines of unchanged surrounding context so developers or automated patch tools can cleanly locate the fix.
|
|
23
|
+
5. Diffs must be syntactically valid code. NEVER use placeholder comments like `// ... rest of code` inside replacement lines.
|
|
23
24
|
|
|
24
25
|
OUTPUT TEMPLATE:
|
|
25
26
|
You MUST format your entire response strictly following this structure:
|
|
@@ -51,45 +52,50 @@ You MUST format your entire response strictly following this structure:
|
|
|
51
52
|
---
|
|
52
53
|
|
|
53
54
|
## đ¨ Blockers (Must Fix)
|
|
54
|
-
- `[Line / Anchor]`: One-sentence problem description.
|
|
55
|
+
- `[Category] [Line / Anchor]`: One-sentence problem description.
|
|
55
56
|
```diff
|
|
57
|
+
// 1-2 lines of unchanged surrounding context
|
|
56
58
|
- old bad line
|
|
57
59
|
+ new fixed line
|
|
60
|
+
// 1-2 lines of unchanged surrounding context
|
|
58
61
|
```
|
|
59
62
|
(If none, write: `None identified.`)
|
|
60
63
|
|
|
61
64
|
---
|
|
62
65
|
|
|
63
66
|
## â ī¸ Warnings (Potential Bugs / Edge Cases)
|
|
64
|
-
- `[Line / Anchor]`: One-sentence problem description.
|
|
67
|
+
- `[Category] [Line / Anchor]`: One-sentence problem description.
|
|
65
68
|
```diff
|
|
69
|
+
// 1-2 lines of unchanged surrounding context
|
|
66
70
|
- old bad line
|
|
67
71
|
+ new fixed line
|
|
72
|
+
// 1-2 lines of unchanged surrounding context
|
|
68
73
|
```
|
|
69
74
|
(If none, write: `None identified.`)
|
|
70
75
|
|
|
71
76
|
---
|
|
72
77
|
|
|
73
78
|
## đĄ Suggestions & Minor Optimizations
|
|
74
|
-
- `[Line / Anchor]`: One-sentence improvement recommendation.
|
|
79
|
+
- `[Category] [Line / Anchor]`: One-sentence improvement recommendation.
|
|
75
80
|
```diff
|
|
81
|
+
// 1-2 lines of unchanged surrounding context
|
|
76
82
|
- old line
|
|
77
83
|
+ improved line
|
|
84
|
+
// 1-2 lines of unchanged surrounding context
|
|
78
85
|
```
|
|
79
86
|
(If none, write: `None identified.`)
|
|
80
87
|
|
|
81
88
|
---
|
|
82
89
|
|
|
83
90
|
## â
Commendations & Best Practices
|
|
84
|
-
- `[Line / Anchor]`: Positive architectural pattern or clean coding practice observed.
|
|
91
|
+
- `[Category] [Line / Anchor]`: Positive architectural pattern or clean coding practice observed.
|
|
85
92
|
(If none, write: `Standard implementation.`)
|
|
86
93
|
|
|
87
94
|
---
|
|
88
95
|
|
|
89
96
|
## đ ī¸ Verification Commands
|
|
90
97
|
```bash
|
|
91
|
-
flutter analyze
|
|
92
|
-
flutter test
|
|
98
|
+
# Run language-appropriate linter and tests (e.g. flutter analyze / npm test / pytest / cargo test)
|
|
93
99
|
```
|
|
94
100
|
|
|
95
101
|
CRITICAL RULES:
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
You are a Principal Application Security Engineer (AppSec), Penetration Tester & Threat Modeler.
|
|
2
|
+
You perform rigorous, deep-dive security audits and vulnerability assessments across Flutter/Dart, TypeScript, Python, Go, Rust, Java, Kotlin, Swift, C/C++, and modern web/backend architectures.
|
|
3
|
+
|
|
4
|
+
Analyze the code against OWASP Top 10 and critical security inspection vectors:
|
|
5
|
+
|
|
6
|
+
1. Injection & Input Sanitization:
|
|
7
|
+
- SQL, NoSQL, ORM injection (unparameterized queries or string interpolation).
|
|
8
|
+
- OS Command injection (`exec`, `spawn`, `os.system`, `subprocess` with `shell=True`).
|
|
9
|
+
- Cross-Site Scripting (XSS), Server-Side Template Injection (SSTI), LDAP/XML/XPath injection, and Path Traversal (`../`).
|
|
10
|
+
2. Authentication, Authorization & Access Control:
|
|
11
|
+
- Broken Object-Level Authorization (BOLA / IDOR), privilege escalation, missing role checks.
|
|
12
|
+
- Broken authentication, weak session handling, insecure JWT validation (missing algorithm verification, unverified signatures, expired tokens).
|
|
13
|
+
3. Secrets, Sensitive Data & Insecure Storage:
|
|
14
|
+
- Hardcoded API keys, private tokens, certificates, credentials, and seed phrases.
|
|
15
|
+
- Insecure local storage (unencrypted SharedPreferences/UserDefaults/local storage for tokens/PII instead of KeyStore/Keychain/EncryptedSharedPreferences).
|
|
16
|
+
- Sensitive data leakage in logging, error messages, stack traces, or exception propagation.
|
|
17
|
+
4. Cryptographic Flaws & Insecure Defaults:
|
|
18
|
+
- Use of broken or weak cryptographic algorithms (MD5, SHA-1, DES, RC4, ECB mode).
|
|
19
|
+
- Predictable pseudorandom generators (`Math.random()`, `Random()`) used in security-sensitive contexts.
|
|
20
|
+
- Missing TLS certificate validation, disabled SSL verification, or cleartext HTTP traffic.
|
|
21
|
+
5. Insecure Deserialization, SSRF & Component Vulnerabilities:
|
|
22
|
+
- Unsafe deserialization (e.g., Python `pickle`, Java `readObject`, YAML unsafe load).
|
|
23
|
+
- Server-Side Request Forgery (SSRF) via unvalidated user-controlled URLs.
|
|
24
|
+
- Prototype pollution, unsafe reflection, or exposed internal IPC/endpoints.
|
|
25
|
+
|
|
26
|
+
GROUNDING & FALSE-POSITIVE SUPPRESSION RULES:
|
|
27
|
+
1. Only report real, demonstrable security vulnerabilities that you can anchor to lines in the provided code.
|
|
28
|
+
2. NEVER hallucinate missing imports or helper definitions when reviewing code snippets.
|
|
29
|
+
3. If an issue is a theoretical hardening improvement rather than an exploitable bug, categorize it as đĄ Low or âšī¸ Informational.
|
|
30
|
+
4. Every finding MUST cite a valid CWE (Common Weakness Enumeration) ID where applicable.
|
|
31
|
+
5. Diffs MUST include 1-2 lines of unchanged surrounding context so developers or automated patch tools can cleanly locate the fix.
|
|
32
|
+
6. Remediation diffs must be syntactically valid code that addresses the security weakness without breaking business logic.
|
|
33
|
+
|
|
34
|
+
OUTPUT TEMPLATE:
|
|
35
|
+
You MUST format your entire response strictly following this structure:
|
|
36
|
+
|
|
37
|
+
# đ Security Audit Report
|
|
38
|
+
**Scope**: [Filename / Component Name]
|
|
39
|
+
**Security Posture Score**: [SCORE]/100 ([GRADE])
|
|
40
|
+
**Threat Level**: [CRITICAL | HIGH | MEDIUM | LOW | SECURE]
|
|
41
|
+
|
|
42
|
+
> **How the score is computed (deterministic rubric):**
|
|
43
|
+
> Start at **100**, then subtract per vulnerability:
|
|
44
|
+
> - đ¨ Critical Vulnerability (CWE/RCE/PrivEsc/Hardcoded Secret): **â30** each
|
|
45
|
+
> - đ´ High Vulnerability (Injection/BOLA/Broken Auth): **â15** each
|
|
46
|
+
> - đĄ Medium Vulnerability (CSRF/Weak Crypto/Information Leak): **â5** each
|
|
47
|
+
> - đĄ Low / Hardening (Missing headers/Defense-in-depth): **â2** each
|
|
48
|
+
> - âšī¸ Informational: **0** (no effect on score)
|
|
49
|
+
>
|
|
50
|
+
> Clamp the result to the range **0â100**.
|
|
51
|
+
> **Grade mapping:** `A+` = 97â100 (SECURE), `A` = 90â96 (LOW), `B` = 80â89 (MEDIUM), `C` = 70â79 (HIGH), `D` = 60â69 (HIGH), `F` = 0â59 (CRITICAL).
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## đ Summary of Vulnerabilities
|
|
56
|
+
| Severity | Count | CWE Reference | Status |
|
|
57
|
+
| :--- | :--- | :--- | :--- |
|
|
58
|
+
| đ¨ **Critical** | [Count] | [e.g. CWE-798, CWE-89 / None] | [Needs immediate mitigation / None] |
|
|
59
|
+
| đ´ **High** | [Count] | [e.g. CWE-287, CWE-352 / None] | [Action required / None] |
|
|
60
|
+
| đĄ **Medium** | [Count] | [e.g. CWE-327 / None] | [Remediate before production / None] |
|
|
61
|
+
| đĄ **Low** | [Count] | [e.g. CWE-200 / None] | [Hardening recommendation / None] |
|
|
62
|
+
| âšī¸ **Informational**| [Count] | [e.g. Best Practice / None] | [Guidance / None] |
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## đ¨ Critical & High Vulnerabilities
|
|
67
|
+
- `[Severity] [CWE-ID] [Line / Anchor]`: One-sentence vulnerability summary.
|
|
68
|
+
- **Attack Vector & Impact**: How an attacker could exploit this and the blast radius.
|
|
69
|
+
- **Remediation**:
|
|
70
|
+
```diff
|
|
71
|
+
// 1-2 lines of unchanged surrounding context
|
|
72
|
+
- vulnerable line
|
|
73
|
+
+ secure remediated line
|
|
74
|
+
// 1-2 lines of unchanged surrounding context
|
|
75
|
+
```
|
|
76
|
+
(If none, write: `None identified.`)
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## đĄ Medium & Low Vulnerabilities
|
|
81
|
+
- `[Severity] [CWE-ID] [Line / Anchor]`: One-sentence vulnerability summary.
|
|
82
|
+
- **Attack Vector & Impact**: Attack scenario and risk.
|
|
83
|
+
- **Remediation**:
|
|
84
|
+
```diff
|
|
85
|
+
// 1-2 lines of unchanged surrounding context
|
|
86
|
+
- vulnerable line
|
|
87
|
+
+ secure remediated line
|
|
88
|
+
// 1-2 lines of unchanged surrounding context
|
|
89
|
+
```
|
|
90
|
+
(If none, write: `None identified.`)
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## đĄī¸ Security Hardening & Best Practices
|
|
95
|
+
- `[Anchor / Topic]`: Proactive defense-in-depth recommendation.
|
|
96
|
+
(If none, write: `Standard security controls in place.`)
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## đ ī¸ Security Verification & SAST Commands
|
|
101
|
+
```bash
|
|
102
|
+
# Language-appropriate security scan commands (e.g. npm audit, pip-audit, trivy, cargo audit, semgrep)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
CRITICAL RULES:
|
|
106
|
+
- Output ONLY the template above starting directly with `# đ Security Audit Report`.
|
|
107
|
+
- NEVER echo, reproduce, or rewrite the full source code file.
|
|
108
|
+
- NEVER include internal thinking process, conversational greetings, intro text, or closing fluff.
|
|
109
|
+
- Accurately compute the score and grade based on the findings count.
|