Skip to content

Commit acd1619

Browse files
authored
Add proper HTML escaping for admin UI user data rendering, and eliminate all web lint issues closes #336 #338 (#337)
* Initial validation and XSS protection for UI Signed-off-by: Mihai Criveti <[email protected]> * Race condition UI fix Signed-off-by: Mihai Criveti <[email protected]> * Full lint compliance for web stack Signed-off-by: Mihai Criveti <[email protected]> * Full lint compliance for web stack and fixed metrics tab Signed-off-by: Mihai Criveti <[email protected]> * Full lint compliance for web stack and fixed metrics tab Signed-off-by: Mihai Criveti <[email protected]> * Full lint compliance for web stack and fixed metrics tab Signed-off-by: Mihai Criveti <[email protected]> * Don't show full json Signed-off-by: Mihai Criveti <[email protected]> * Cleanup escape issues Signed-off-by: Mihai Criveti <[email protected]> --------- Signed-off-by: Mihai Criveti <[email protected]>
1 parent efb5cf8 commit acd1619

File tree

14 files changed

+9426
-4674
lines changed

14 files changed

+9426
-4674
lines changed

.bumpversion.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ tag = False
55
sign-tags = True
66
tag_name = v{new_version} # tag format (only used if you flip tag=True later)
77
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)
8-
serialize =
9-
{major}.{minor}.{patch}
8+
serialize =
9+
{major}.{minor}.{patch}
1010

1111
[bumpversion:file:mcpgateway/__init__.py]
1212
search = __version__ = "{current_version}"

.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ AUTH_ENCRYPTION_SECRET=my-test-salt
106106
#####################################
107107

108108
# Enable the visual Admin UI (true/false)
109-
MCPGATEWAY_UI_ENABLED=true
109+
MCPGATEWAY_UI_ENABLED=false
110110

111111
# Enable the Admin API endpoints (true/false)
112-
MCPGATEWAY_ADMIN_API_ENABLED=true
112+
MCPGATEWAY_ADMIN_API_ENABLED=false
113113

114114
#####################################
115115
# Security and CORS

.eslintrc.json

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
11
{
22
"root": true,
3+
34
"env": {
45
"browser": true,
6+
"node": true,
57
"es2021": true
68
},
7-
"extends": ["standard"],
9+
810
"parserOptions": {
9-
"ecmaVersion": 12,
11+
"ecmaVersion": "latest",
1012
"sourceType": "module"
1113
},
14+
15+
"extends": [
16+
"standard",
17+
"plugin:prettier/recommended"
18+
],
19+
1220
"rules": {
13-
"semi": ["error", "always"],
14-
"quotes": ["error", "double"]
21+
"semi": ["error", "always"],
22+
"quotes": ["error", "double", { "avoidEscape": true }],
23+
24+
"curly": ["error", "all"],
25+
"prefer-const": "warn"
1526
}
1627
}

SECURITY.md

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Here's an expanded section for that part:
1313
**Tools are not enough**: While our automated security tooling provides comprehensive coverage, we recognize that true security requires human expertise and collaborative oversight. Our security posture extends beyond automated scanning to include:
1414

1515
- **Manual Security Code Reviews**: Expert security engineers conduct thorough code reviews focusing on logic flaws, business logic vulnerabilities, and complex attack vectors that automated tools might miss
16-
- **Threat Modeling & Risk Assessment**: Regular security assessments evaluate our attack surface, identify potential threat vectors, and validate our defense mechanisms against real-world attack scenarios
16+
- **Threat Modeling & Risk Assessment**: Regular security assessments evaluate our attack surface, identify potential threat vectors, and validate our defense mechanisms against real-world attack scenarios
1717
- **Community-Driven Security**: We actively engage with the security research community, maintain responsible disclosure processes, and leverage collective intelligence to identify and address emerging threats
1818
- **Security Champion Program**: Developers across the project receive security training and act as security advocates within their teams, creating a culture of security awareness
1919
- **Penetration Testing**: Regular security assessments by internal and external security professionals validate our defenses against sophisticated attack techniques
@@ -85,26 +85,26 @@ The following diagram illustrates our comprehensive security scanning pipeline:
8585
```mermaid
8686
flowchart TD
8787
A[Code Changes] --> B{Pre-commit Hooks}
88-
88+
8989
B --> C[Ruff - Python Linter/Formatter]
9090
B --> D[Black - Code Formatter]
9191
B --> E[isort - Import Sorter]
9292
B --> F[mypy - Type Checking]
9393
B --> G[Bandit - Security Scanner]
94-
94+
9595
C --> H[Pre-commit Success?]
9696
D --> H
9797
E --> H
9898
F --> H
9999
G --> H
100-
100+
101101
H -->|No| I[Fix Issues & Retry]
102102
I --> B
103-
103+
104104
H -->|Yes| J[Push to GitHub]
105-
105+
106106
J --> K[GitHub Actions Triggers]
107-
107+
108108
K --> L[Python Package Build]
109109
K --> M[CodeQL Analysis]
110110
K --> N[Bandit Security Scan]
@@ -113,29 +113,29 @@ flowchart TD
113113
K --> Q[Lint & Static Analysis]
114114
K --> R[Docker Image Build]
115115
K --> S[Container Security Scan]
116-
116+
117117
L --> L1[Python Build Test]
118118
L --> L2[Package Installation Test]
119-
119+
120120
M --> M1[Semantic Code Analysis]
121121
M --> M2[Security Vulnerability Detection]
122122
M --> M3[Data Flow Analysis]
123-
123+
124124
N --> N1[Security Issue Detection]
125125
N --> N2[Common Security Patterns]
126126
N --> N3[Hardcoded Secrets Check]
127-
127+
128128
O --> O1[Dependency Vulnerability Check]
129129
O --> O2[License Compliance]
130130
O --> O3[Supply Chain Security]
131-
131+
132132
P --> P1[pytest Unit Tests]
133133
P --> P2[Coverage Analysis]
134134
P --> P3[Integration Tests]
135-
135+
136136
Q --> Q1[Multiple Linters]
137137
Q --> Q2[Static Analysis Tools]
138-
138+
139139
Q1 --> Q1A[flake8 - PEP8 Compliance]
140140
Q1 --> Q1B[pylint - Code Quality]
141141
Q1 --> Q1C[pycodestyle - Style Guide]
@@ -144,7 +144,7 @@ flowchart TD
144144
Q1 --> Q1F[yamllint - YAML Files]
145145
Q1 --> Q1G[jsonlint - JSON Files]
146146
Q1 --> Q1H[tomllint - TOML Files]
147-
147+
148148
Q2 --> Q2A[mypy - Type Checking]
149149
Q2 --> Q2B[pyright - Type Analysis]
150150
Q2 --> Q2C[pytype - Google Type Checker]
@@ -153,77 +153,77 @@ flowchart TD
153153
Q2 --> Q2F[importchecker - Import Analysis]
154154
Q2 --> Q2G[fawltydeps - Dependency Analysis]
155155
Q2 --> Q2H[check-manifest - Package Completeness]
156-
156+
157157
R --> R1[Docker Build]
158158
R --> R2[Multi-stage Build Process]
159159
R --> R3[Security Hardening]
160-
160+
161161
S --> S1[Hadolint - Dockerfile Linting]
162162
S --> S2[Dockle - Container Security]
163163
S --> S3[Trivy - Vulnerability Scanner]
164164
S --> S4[OSV-Scanner - Open Source Vulns]
165-
165+
166166
T[Local Development] --> U[Make Targets]
167-
167+
168168
U --> V[make lint - Full Lint Suite]
169169
U --> W[Individual Security Tools]
170170
U --> X[make sbom - Software Bill of Materials]
171171
U --> Y[make lint-web - Frontend Security]
172-
172+
173173
V --> V1[All Python Linters]
174174
V --> V2[Code Quality Checks]
175175
V --> V3[Style Enforcement]
176-
176+
177177
W --> W1[make bandit - Security Scanner]
178178
W --> W2[make osv-scan - Vulnerability Check]
179179
W --> W3[make trivy - Container Security]
180180
W --> W4[make dockle - Image Analysis]
181181
W --> W5[make hadolint - Dockerfile Linting]
182182
W --> W6[make pip-audit - Dependency Scanning]
183-
183+
184184
X --> X1[CycloneDX SBOM Generation]
185185
X --> X2[Dependency Inventory]
186186
X --> X3[License Compliance Check]
187187
X --> X4[Vulnerability Assessment]
188-
188+
189189
Y --> Y1[htmlhint - HTML Validation]
190190
Y --> Y2[stylelint - CSS Security]
191191
Y --> Y3[eslint - JavaScript Security]
192192
Y --> Y4[retire.js - JS Library Vulnerabilities]
193193
Y --> Y5[npm audit - Package Vulnerabilities]
194-
194+
195195
Z[Additional Security Tools] --> Z1[SonarQube Analysis]
196196
Z --> Z2[WhiteSource Security Scanning]
197197
Z --> Z3[Spellcheck - Documentation]
198198
Z --> Z4[Pre-commit Hook Validation]
199-
199+
200200
AA[Container Security Pipeline] --> AA1[Multi-stage Build]
201201
AA --> AA2[Minimal Base Images]
202202
AA --> AA3[Security Hardening]
203203
AA --> AA4[Runtime Security]
204-
204+
205205
AA1 --> AA1A[Build Dependencies]
206206
AA1 --> AA1B[Runtime Dependencies]
207207
AA1 --> AA1C[Security Scanning]
208-
208+
209209
AA2 --> AA2A[UBI Micro Base]
210210
AA2 --> AA2B[Minimal Attack Surface]
211211
AA2 --> AA2C[No Shell Access]
212-
212+
213213
AA3 --> AA3A[Non-root User]
214214
AA3 --> AA3B[Read-only Filesystem]
215215
AA3 --> AA3C[Capability Dropping]
216-
216+
217217
AA4 --> AA4A[Runtime Monitoring]
218218
AA4 --> AA4B[Security Policies]
219219
AA4 --> AA4C[Vulnerability Patching]
220-
220+
221221
classDef security fill:#ff6b6b,stroke:#d63031,stroke-width:2px
222222
classDef linting fill:#74b9ff,stroke:#0984e3,stroke-width:2px
223223
classDef container fill:#00b894,stroke:#00a085,stroke-width:2px
224224
classDef process fill:#fdcb6e,stroke:#e17055,stroke-width:2px
225225
classDef success fill:#55a3ff,stroke:#2d3436,stroke-width:2px
226-
226+
227227
class G,M,N,O,W,W1,W2,W3,W4,Z1,Z2,AA security
228228
class C,D,E,F,Q,Q1,Q1A,Q1B,Q1C,Q1D,Q1E,Q1F,Q1G,Q1H,V linting
229229
class R,S,S1,S2,S3,S4,AA,AA1,AA2,AA3,AA4 container
@@ -238,8 +238,9 @@ flowchart TD
238238
## 📦 Supported Versions and Security Updates
239239

240240
All Container Images and Python dependencies are updated with every release (major or minor) or on CRITICAL/HIGH security vulnerabilities (triggering a minor release).
241-
242-
We currently support only the latest version of this project. Older versions are not maintained or patched.
241+
We currently support only the latest version of this project, and only through the REST API.
242+
Admin UI / APIs are provided for developer convenience and should be disabled in production using the provided feature flags.
243+
Older versions are not maintained or patched.
243244

244245
### Security Patching Policy
245246

docs/docs/architecture/roadmap.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,4 +393,4 @@
393393
7. **Chrome MCP Plugin Integration** - Browser extension for managing MCP configurations, servers, and connections
394394

395395
### 🔐 Secrets & Sensitive Data
396-
8. **Secure Secrets Management & Masking** - External secrets store integration (Vault)
396+
8. **Secure Secrets Management & Masking** - External secrets store integration (Vault)

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,4 @@ weasyprint>=65.1
8787
webcolors>=24.11.1
8888
webencodings>=0.5.1
8989
zipp>=3.23.0
90-
zopfli>=0.2.3.post1
90+
zopfli>=0.2.3.post1

mcpgateway/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ async def server_get_prompts(
892892
@tool_router.get("", response_model=Union[List[ToolRead], List[Dict], Dict, List])
893893
@tool_router.get("/", response_model=Union[List[ToolRead], List[Dict], Dict, List])
894894
async def list_tools(
895-
cursor: Optional[str] = None, # Add this parameter
895+
cursor: Optional[str] = None,
896896
include_inactive: bool = False,
897897
db: Session = Depends(get_db),
898898
apijsonpath: JsonPathModifier = Body(None),
@@ -1138,7 +1138,7 @@ async def toggle_resource_status(
11381138
@resource_router.get("", response_model=List[ResourceRead])
11391139
@resource_router.get("/", response_model=List[ResourceRead])
11401140
async def list_resources(
1141-
cursor: Optional[str] = None, # Add this parameter
1141+
cursor: Optional[str] = None,
11421142
include_inactive: bool = False,
11431143
db: Session = Depends(get_db),
11441144
user: str = Depends(require_auth),

mcpgateway/static/admin.css

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,36 @@
99
}
1010

1111

12-
/* Add this CSS for the spinner */
12+
/* CSS for the spinner */
1313
.spinner {
1414
border: 4px solid #f3f3f3;
1515
border-top: 4px solid #3498db;
1616
border-radius: 50%;
1717
width: 24px;
1818
height: 24px;
1919
animation: spin 1s linear infinite;
20+
2021
/* margin: 10px auto; */
2122

2223
/* Positioning to the left */
23-
margin: 10px 0 10px 10px; /* top, right, bottom, left */
24-
display: block; /* Ensures it behaves like a block-level element */
24+
margin: 10px 0 10px 10px;
25+
26+
/* top, right, bottom, left */
27+
display: block;
28+
29+
/* Ensures it behaves like a block-level element */
2530
}
2631

2732
@keyframes spin {
28-
0% { transform: rotate(0deg); }
29-
100% { transform: rotate(360deg); }
33+
0% {
34+
transform: rotate(0deg);
35+
}
36+
37+
100% {
38+
transform: rotate(360deg);
39+
}
3040
}
3141

32-
.feedback:blank { display:none; }
42+
.feedback:blank {
43+
display: none;
44+
}

0 commit comments

Comments
 (0)