@@ -2898,11 +2898,13 @@ test-full: coverage test-ui-report
2898
2898
# help: pip-audit - Audit Python dependencies for published CVEs
2899
2899
# help: gitleaks-install - Install gitleaks secret scanner
2900
2900
# 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
2901
2903
2902
2904
# 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
2904
2906
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
2906
2908
2907
2909
# # --------------------------------------------------------------------------- ##
2908
2910
# # Master security target
@@ -3004,6 +3006,63 @@ gitleaks: ## 🔍 Scan for secrets in git history
3004
3006
@gitleaks detect --source . -v || true
3005
3007
@echo " 💡 To scan git history: gitleaks detect --source . --log-opts='--all'"
3006
3008
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
+
3007
3066
# # --------------------------------------------------------------------------- ##
3008
3067
# # Security reporting and advanced targets
3009
3068
# # --------------------------------------------------------------------------- ##
@@ -3021,6 +3080,14 @@ security-report: ## 📊 Generate comprehensive security repo
3021
3080
@/bin/bash -c " source $( VENV_DIR) /bin/activate && \
3022
3081
python3 -m pip install -q dodgy && \
3023
3082
$(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
3024
3091
@echo " ✅ Security report saved to $( DOCS_DIR) /docs/security/report.md"
3025
3092
3026
3093
security-fix : # # 🔧 Auto-fix security issues where possible
@@ -3038,3 +3105,4 @@ security-fix: ## 🔧 Auto-fix security issues where possi
3038
3105
@echo " - Dependency updates (run 'make update')"
3039
3106
@echo " - Secrets in code (review dodgy/gitleaks output)"
3040
3107
@echo " - Security patterns (review semgrep output)"
3108
+ @echo " - DevSkim findings (review devskim-results.sarif)"
0 commit comments