Skip to content

Commit c163a60

Browse files
authored
590 devskim (#592)
* Implement devskim Signed-off-by: Mihai Criveti <[email protected]> * Implement devskim Signed-off-by: Mihai Criveti <[email protected]> --------- Signed-off-by: Mihai Criveti <[email protected]>
1 parent 48b0ef2 commit c163a60

File tree

6 files changed

+106
-7
lines changed

6 files changed

+106
-7
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: DevSkim
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
schedule:
9+
- cron: '31 6 * * 6'
10+
11+
jobs:
12+
lint:
13+
name: DevSkim
14+
runs-on: ubuntu-latest
15+
permissions:
16+
actions: read
17+
contents: read
18+
security-events: write
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Run DevSkim scanner
24+
uses: microsoft/DevSkim-Action@v1
25+
26+
- name: Upload DevSkim scan results to GitHub Security tab
27+
uses: github/codeql-action/upload-sarif@v3
28+
with:
29+
sarif_file: devskim-results.sarif

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
*.sarif
2+
devskim-results.sarif
13
debug_login_page.png
24
docs/pstats.png
35
mcp.prof

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
1111
### Security Notice
1212

1313
> **This is a security-focused release. Upgrading is highly recommended.**
14-
>
14+
>
1515
> This release continues our security-first approach with the Admin UI and Admin API **disabled by default**. To enable these features for local development, update your `.env` file:
1616
> ```bash
1717
> # Enable the visual Admin UI (true/false)
1818
> MCPGATEWAY_UI_ENABLED=true
19-
>
19+
>
2020
> # Enable the Admin API endpoints (true/false)
2121
> MCPGATEWAY_ADMIN_API_ENABLED=true
2222
> ```
@@ -131,7 +131,7 @@ This release represents a major milestone in code quality, security, and reliabi
131131
132132
#### 🏆 Top Contributors in 0.4.0
133133
- **Mihai Criveti** (@crivetimihai) - Release coordinator, security improvements, and extensive testing infrastructure
134-
- **Madhav Kandukuri** (@madhav165) - Major input validation framework, security fixes, and test coverage improvements
134+
- **Madhav Kandukuri** (@madhav165) - Major input validation framework, security fixes, and test coverage improvements
135135
- **Keval Mahajan** (@kevalmahajan) - HTTPX retry mechanism implementation and UI improvements
136136
- **Manav Gupta** (@manavgup) - Comprehensive doctest coverage and Playwright test suite
137137

Makefile

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2898,11 +2898,13 @@ test-full: coverage test-ui-report
28982898
# help: pip-audit - Audit Python dependencies for published CVEs
28992899
# help: gitleaks-install - Install gitleaks secret scanner
29002900
# help: gitleaks - Scan git history for secrets
2901+
# help: devskim-install-dotnet - Install .NET SDK and DevSkim CLI (security patterns scanner)
2902+
# help: devskim - Run DevSkim static analysis for security anti-patterns
29012903

29022904
# List of security tools to run with security-all
2903-
SECURITY_TOOLS := semgrep dodgy dlint interrogate prospector pip-audit
2905+
SECURITY_TOOLS := semgrep dodgy dlint interrogate prospector pip-audit devskim
29042906

2905-
.PHONY: security-all security-report security-fix $(SECURITY_TOOLS) gitleaks-install gitleaks pyupgrade
2907+
.PHONY: security-all security-report security-fix $(SECURITY_TOOLS) gitleaks-install gitleaks pyupgrade devskim-install-dotnet devskim
29062908

29072909
## --------------------------------------------------------------------------- ##
29082910
## Master security target
@@ -3004,6 +3006,63 @@ gitleaks: ## 🔍 Scan for secrets in git history
30043006
@gitleaks detect --source . -v || true
30053007
@echo "💡 To scan git history: gitleaks detect --source . --log-opts='--all'"
30063008

3009+
## --------------------------------------------------------------------------- ##
3010+
## DevSkim (.NET-based security patterns scanner)
3011+
## --------------------------------------------------------------------------- ##
3012+
devskim-install-dotnet: ## 📦 Install .NET SDK and DevSkim CLI
3013+
@echo "📦 Installing .NET SDK and DevSkim CLI..."
3014+
@if [ "$$(uname)" = "Darwin" ]; then \
3015+
echo "🍏 Installing .NET SDK for macOS..."; \
3016+
brew install --cask dotnet-sdk || brew upgrade --cask dotnet-sdk; \
3017+
elif [ "$$(uname)" = "Linux" ]; then \
3018+
echo "🐧 Installing .NET SDK for Linux..."; \
3019+
if command -v apt-get >/dev/null 2>&1; then \
3020+
wget -q https://packages.microsoft.com/config/ubuntu/$$(lsb_release -rs)/packages-microsoft-prod.deb -O /tmp/packages-microsoft-prod.deb 2>/dev/null || \
3021+
wget -q https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O /tmp/packages-microsoft-prod.deb; \
3022+
sudo dpkg -i /tmp/packages-microsoft-prod.deb; \
3023+
sudo apt-get update; \
3024+
sudo apt-get install -y dotnet-sdk-9.0 || sudo apt-get install -y dotnet-sdk-8.0 || sudo apt-get install -y dotnet-sdk-7.0; \
3025+
rm -f /tmp/packages-microsoft-prod.deb; \
3026+
elif command -v dnf >/dev/null 2>&1; then \
3027+
sudo dnf install -y dotnet-sdk-9.0 || sudo dnf install -y dotnet-sdk-8.0; \
3028+
else \
3029+
echo "❌ Unsupported Linux distribution. Please install .NET SDK manually."; \
3030+
echo " Visit: https://dotnet.microsoft.com/download"; \
3031+
exit 1; \
3032+
fi; \
3033+
else \
3034+
echo "❌ Unsupported OS. Please install .NET SDK manually."; \
3035+
echo " Visit: https://dotnet.microsoft.com/download"; \
3036+
exit 1; \
3037+
fi
3038+
@echo "🔧 Installing DevSkim CLI tool..."
3039+
@export PATH="$$PATH:$$HOME/.dotnet/tools" && \
3040+
dotnet tool install --global Microsoft.CST.DevSkim.CLI || \
3041+
dotnet tool update --global Microsoft.CST.DevSkim.CLI
3042+
@echo "✅ DevSkim installed successfully!"
3043+
@echo "💡 You may need to add ~/.dotnet/tools to your PATH:"
3044+
@echo " export PATH=\"\$$PATH:\$$HOME/.dotnet/tools\""
3045+
3046+
devskim: ## 🛡️ Run DevSkim security patterns analysis
3047+
@echo "🛡️ Running DevSkim static analysis..."
3048+
@if command -v devskim >/dev/null 2>&1 || [ -f "$$HOME/.dotnet/tools/devskim" ]; then \
3049+
export PATH="$$PATH:$$HOME/.dotnet/tools" && \
3050+
echo "📂 Scanning mcpgateway/ for security anti-patterns..." && \
3051+
devskim analyze --source-code mcpgateway --output-file devskim-results.sarif -f sarif && \
3052+
echo "" && \
3053+
echo "📊 Detailed findings:" && \
3054+
devskim analyze --source-code mcpgateway -f text && \
3055+
echo "" && \
3056+
echo "📄 SARIF report saved to: devskim-results.sarif" && \
3057+
echo "💡 To view just the summary: devskim analyze --source-code mcpgateway -f text | grep -E '(Critical|Important|Moderate|Low)' | sort | uniq -c"; \
3058+
else \
3059+
echo "❌ DevSkim not found in PATH or ~/.dotnet/tools/"; \
3060+
echo "💡 Install with:"; \
3061+
echo " • Run 'make devskim-install-dotnet'"; \
3062+
echo " • Or install .NET SDK and run: dotnet tool install --global Microsoft.CST.DevSkim.CLI"; \
3063+
echo " • Then add to PATH: export PATH=\"\$$PATH:\$$HOME/.dotnet/tools\""; \
3064+
fi
3065+
30073066
## --------------------------------------------------------------------------- ##
30083067
## Security reporting and advanced targets
30093068
## --------------------------------------------------------------------------- ##
@@ -3021,6 +3080,14 @@ security-report: ## 📊 Generate comprehensive security repo
30213080
@/bin/bash -c "source $(VENV_DIR)/bin/activate && \
30223081
python3 -m pip install -q dodgy && \
30233082
$(VENV_DIR)/bin/dodgy mcpgateway tests || true" >> $(DOCS_DIR)/docs/security/report.md 2>&1
3083+
@echo "" >> $(DOCS_DIR)/docs/security/report.md
3084+
@echo "## DevSkim Security Anti-patterns" >> $(DOCS_DIR)/docs/security/report.md
3085+
@if command -v devskim >/dev/null 2>&1 || [ -f "$$HOME/.dotnet/tools/devskim" ]; then \
3086+
export PATH="$$PATH:$$HOME/.dotnet/tools" && \
3087+
devskim analyze --source-code mcpgateway --format text >> $(DOCS_DIR)/docs/security/report.md 2>&1 || true; \
3088+
else \
3089+
echo "DevSkim not installed - skipping" >> $(DOCS_DIR)/docs/security/report.md; \
3090+
fi
30243091
@echo "✅ Security report saved to $(DOCS_DIR)/docs/security/report.md"
30253092

30263093
security-fix: ## 🔧 Auto-fix security issues where possible
@@ -3038,3 +3105,4 @@ security-fix: ## 🔧 Auto-fix security issues where possi
30383105
@echo " - Dependency updates (run 'make update')"
30393106
@echo " - Secrets in code (review dodgy/gitleaks output)"
30403107
@echo " - Security patterns (review semgrep output)"
3108+
@echo " - DevSkim findings (review devskim-results.sarif)"

docs/docs/architecture/roadmap.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,4 +519,4 @@ WE ARE HERE
519519
7. **Chrome MCP Plugin Integration** - Browser extension for managing MCP configurations, servers, and connections
520520

521521
### 🔐 Secrets & Sensitive Data
522-
8. **Secure Secrets Management & Masking** - External secrets store integration (Vault)
522+
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

0 commit comments

Comments
 (0)