Skip to content

Conversation

@mariocandela
Copy link
Owner

@mariocandela mariocandela commented Jul 1, 2025

Description

  • New MCP Honeypot strategy
  • Extended API YAML schema (protocol: "mcp", tools section)
  • Sample configuration in: configurations/services/mcp-8000.yaml

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. Does your submission pass tests?
  2. Have you lint your code locally before submission?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?

Summary by CodeRabbit

  • New Features

    • Added support for the MCP protocol, including a new MCP honeypot service with user account management and system log tools.
    • Introduced configuration options for defining tools within services.
    • MCP protocol events are now tracked with dedicated Prometheus metrics.
  • Bug Fixes

    • Improved HTTP event tracing by providing both string and map representations of headers.
  • Tests

    • Expanded tests to cover MCP protocol handling and Prometheus counter updates.
  • Chores

    • Updated dependencies and CI workflow to support MCP protocol and related coverage reporting.
  • Documentation

    • Expanded and reorganized README with detailed features, example configurations, testing instructions, and quality assurance practices.

@mariocandela mariocandela self-assigned this Jul 1, 2025
@mariocandela mariocandela added the enhancement New feature or request label Jul 1, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jul 1, 2025

Walkthrough

The changes introduce support for the MCP protocol across the codebase. This includes adding an MCP protocol strategy, updating the service configuration model and parser to support MCP tools, adding a sample MCP honeypot configuration, modifying tracing and metrics to handle MCP events, and updating the CI workflow to exclude MCP code from coverage. Tests and dependencies are also updated accordingly.

Changes

Files / Groups Change Summary
.github/workflows/ci.yml Excludes mcp.go from unit test coverage calculations.
builder/builder.go Integrates MCP protocol strategy into protocol selection and initialization.
configurations/services/mcp-8000.yaml Adds a new MCP honeypot configuration with two tools and static handler responses.
go.mod Adds indirect dependencies: mcp-go, cast, and uritemplate/v3.
parser/configurations_parser.go Adds support for "tools" in service configuration, with new Tool and Param structs.
parser/configurations_parser_test.go Updates tests to verify parsing of "tools" in service configuration.
protocols/strategies/HTTP/http.go Adds helper for stringifying HTTP headers; updates event tracing to include string and map representations of headers.
protocols/strategies/MCP/mcp.go Introduces MCPStrategy struct and its Init method to handle MCP protocol and tool registration.
tracer/tracer.go Adds MCP protocol support, updates event struct for headers, and introduces MCP Prometheus metrics.
tracer/tracer_test.go Extends Prometheus counter tests to include MCP protocol events.
README.md Expands and reorganizes documentation with new key features, code quality, testing, example configurations, and quick start.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant HTTP_Server
    participant MCP_Server
    participant MCPStrategy
    participant Tracer

    Client->>HTTP_Server: Sends MCP protocol request
    HTTP_Server->>MCP_Server: Passes request with remote address in context
    MCP_Server->>MCPStrategy: Invokes tool handler
    MCPStrategy->>Tracer: Emits trace event (protocol: MCP, details)
    MCPStrategy-->>MCP_Server: Returns static handler response
    MCP_Server-->>HTTP_Server: Sends response
    HTTP_Server-->>Client: Returns handler result
Loading

Poem

In burrows deep, a new path found,
MCP now hops around!
With tools and logs, and headers neat,
The tracer counts each bunny feat.
New configs bloom, the garden grows—
With every change, the rabbit knows:
More protocols, more fun to meet!

((\
( -.-)
o_(")(")


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov
Copy link

codecov bot commented Jul 1, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.94%. Comparing base (e1e8012) to head (05e0edd).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #199      +/-   ##
==========================================
+ Coverage   82.66%   82.94%   +0.28%     
==========================================
  Files           7        7              
  Lines         421      428       +7     
==========================================
+ Hits          348      355       +7     
  Misses         63       63              
  Partials       10       10              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Nitpick comments (6)
protocols/strategies/HTTP/http.go (1)

159-169: Improve the header string formatting.

The function works correctly but has minor formatting issues that could be improved.

 func mapHeaderToString(headers http.Header) string {
-	headersString := ""
+	var headersString strings.Builder

 	for key := range headers {
-		for _, values := range headers[key] {
-			headersString += fmt.Sprintf("[Key: %s, values: %s],", key, values)
+		for _, value := range headers[key] {
+			headersString.WriteString(fmt.Sprintf("[Key: %s, Value: %s]", key, value))
 		}
 	}

-	return headersString
+	return headersString.String()
 }

This change:

  • Uses strings.Builder for better performance
  • Fixes variable naming (valuesvalue)
  • Removes trailing comma
  • Uses consistent capitalization ("Value" vs "values")
parser/configurations_parser_test.go (1)

166-166: Remove duplicate assertion.

This line duplicates the assertion from line 165.

-	assert.Equal(t, firstBeelzebubServiceConfiguration.TLSKeyPath, "/tmp/cert.key")
configurations/services/mcp-8000.yaml (2)

41-41: Add newline at end of file.

         }
       }
+

21-21: Use ISO 8601 date format for clarity.

The date format "02/07/2025" is ambiguous (could be DD/MM/YYYY or MM/DD/YYYY). Consider using ISO 8601 format (YYYY-MM-DD) for consistency and clarity.

Also applies to: 38-38

protocols/strategies/MCP/mcp.go (2)

29-29: Remove redundant nil check.

The len() function returns 0 for nil slices, so the nil check is unnecessary.

-		if toolConfig.Params == nil || len(toolConfig.Params) == 0 {
+		if len(toolConfig.Params) == 0 {

62-62: Consider using a more robust command format.

Using "|" as a delimiter could cause issues if the tool name or arguments contain this character. Consider using a structured format or escaping the delimiter.

-				Command:       fmt.Sprintf("%s|%s", request.Params.Name, request.Params.Arguments),
+				Command:       fmt.Sprintf("%s: %v", request.Params.Name, request.Params.Arguments),
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e1e8012 and b506aac.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (9)
  • .github/workflows/ci.yml (1 hunks)
  • builder/builder.go (3 hunks)
  • configurations/services/mcp-8000.yaml (1 hunks)
  • go.mod (1 hunks)
  • parser/configurations_parser.go (2 hunks)
  • parser/configurations_parser_test.go (2 hunks)
  • protocols/strategies/HTTP/http.go (2 hunks)
  • protocols/strategies/MCP/mcp.go (1 hunks)
  • tracer/tracer.go (5 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
builder/builder.go (1)
protocols/strategies/MCP/mcp.go (1)
  • MCPStrategy (18-19)
🪛 YAMLlint (1.37.1)
configurations/services/mcp-8000.yaml

[error] 41-41: no new line character at the end of file

(new-line-at-end-of-file)

🪛 golangci-lint (1.64.8)
protocols/strategies/MCP/mcp.go

29-29: S1009: should omit nil check; len() for nil slices is defined as zero

(gosimple)

🪛 GitHub Check: codecov/patch
tracer/tracer.go

[warning] 159-160: tracer/tracer.go#L159-L160
Added lines #L159 - L160 were not covered by tests

🔇 Additional comments (11)
.github/workflows/ci.yml (1)

48-48: LGTM! Consistent exclusion pattern.

The addition of mcp.go to the coverage exclusion list follows the established pattern for other protocol strategies and aligns with the comment explaining that concrete strategies are covered by integration tests.

go.mod (1)

29-29: MCP library version and security status verified

  • go.mod (line 29): github.com/mark3labs/mcp-go v0.32.0 is the latest stable release (June 11, 2025).
  • No known CVEs or security advisories against v0.32.0.
  • Review the project’s SECURITY.md and issue tracker for any emerging reports.
  • Consider scheduling a periodic security audit and monitoring upstream releases.
builder/builder.go (3)

6-6: LGTM! Proper import integration.

The MCP strategy import follows the established pattern alongside other protocol strategies.


116-116: LGTM! Consistent strategy instantiation.

The MCP strategy instantiation follows the same pattern as other protocol strategies with descriptive variable naming.


144-145: LGTM! Proper protocol switch integration.

The MCP protocol case is correctly added to the switch statement, maintaining consistency with existing protocol handling.

protocols/strategies/HTTP/http.go (1)

141-142: LGTM! Dual header representation support.

The changes correctly support both string and map representations of headers, which appears to align with tracer event structure modifications for MCP protocol compatibility.

parser/configurations_parser_test.go (2)

55-63: LGTM! Comprehensive tools test data.

The mock YAML properly represents the tools configuration structure with name, description, parameters, and handler - providing good test coverage for the new functionality.


167-173: LGTM! Thorough tools configuration testing.

The test assertions comprehensively verify the tools parsing including count, names, descriptions, parameters, and handler - ensuring the new configuration structure is properly validated.

parser/configurations_parser.go (1)

66-66: LGTM! Clean extension of the configuration model.

The addition of the Tools field and the new Tool and Param structs properly extends the service configuration to support MCP honeypot tools. The structure follows the existing patterns in the codebase.

Also applies to: 90-102

tracer/tracer.go (2)

52-52: Well-structured MCP protocol integration.

The addition of MCP support to the tracer follows the existing pattern perfectly. The new protocol constant, Prometheus counter, and switch case are implemented consistently with the other protocols.

Also applies to: 56-56, 83-83, 118-122, 159-160


28-29: No usages of tracer.Event.Headers detected; change is safe.

A search for any direct access or iteration over Headers on the Event type returned no matches. The only .Headers[0] hit was in parser/configurations_parser_test.go, which refers to a different Headers field in the parser package. As a result, switching Event.Headers from map[string][]string to string does not introduce a breaking change in the current codebase.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
tracer/tracer_test.go (1)

89-89: Consider test isolation to avoid shared state dependencies.

The global counter variable creates dependencies between test cases. While this doesn't affect the correctness of the current changes, consider resetting the counter between test cases or using test-specific counters for better test isolation.

 func TestUpdatePrometheusCounters(t *testing.T) {
+	counter = 0  // Reset counter at the start of the test
 	mockStrategy := func(event Event) {}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b506aac and 59415ee.

📒 Files selected for processing (1)
  • tracer/tracer_test.go (2 hunks)
🔇 Additional comments (2)
tracer/tracer_test.go (2)

109-109: LGTM! Consistent with existing pattern.

The addition of eventsMCPTotal field to the mock tracer struct is consistent with the existing pattern for other protocols (SSH, HTTP, TCP).


121-122: LGTM! MCP protocol test follows established pattern.

The MCP protocol test case correctly follows the same pattern as the existing protocol tests, incrementing the global counter by 2 (once for total events, once for protocol-specific events).

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (5)
README.md (5)

21-21: Insert a space after “MCP” to fix the broken parenthesis.
Current text renders as MCP(Detect …) which is hard to read and triggers the spell checker.

- - Multi-protocol support: SSH, HTTP, TCP, MCP(Detect prompt injection against LLM agents)
+ - Multi-protocol support: SSH, HTTP, TCP, MCP (detect prompt-injection against LLM agents)

36-50: Unify list-marker style for markdown-lint compliance.
Above lists use dashes (-) while this block uses asterisks (*), producing MD004 warnings. Pick one style; the rest of the file already prefers dashes.

-* **Automated Testing:**
-* **Static Analysis:**
-* **Code Coverage:**
-* **Continuous Integration:**
-* **Code Reviews:**
+- **Automated Testing:**
+- **Static Analysis:**
+- **Code Coverage:**
+- **Continuous Integration:**
+- **Code Reviews:**

53-53: Add a space before the parenthesis and hyphenate “cross-device”.

-You can run Beelzebub via Docker, Go compiler(cross device), or Helm (Kubernetes).
+You can run Beelzebub via Docker, Go compiler (cross-device), or Helm (Kubernetes).

182-182: Remove trailing punctuation in the heading (MD026).

-#### Invoke remotely: beelzebub:port/mcp (Streamable HTTPServer).
+#### Invoke remotely: beelzebub:port/mcp (streamable HTTP server)

249-249: Duplicate heading – differentiate or remove.
### HTTP Honeypot appears twice (lines 185 and 249). Consider renaming the second one, e.g.:

-### HTTP Honeypot
+### HTTP Honeypot (Port 8080 example)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 59415ee and 967a852.

📒 Files selected for processing (1)
  • README.md (7 hunks)
🧰 Additional context used
🪛 LanguageTool
README.md

[misspelling] ~21-~21: This word is normally spelled as one.
Context: ...nhanced security and easy management. - Multi-protocol support: SSH, HTTP, TCP, MCP(Detect pro...

(EN_COMPOUNDS_MULTI_PROTOCOL)

🪛 markdownlint-cli2 (0.17.2)
README.md

36-36: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


39-39: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


42-42: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


45-45: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


48-48: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


113-113: Dollar signs used before commands without showing output

(MD014, commands-show-output)


124-124: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


127-127: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


130-130: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)


182-182: Trailing punctuation in heading
Punctuation: '.'

(MD026, no-trailing-punctuation)


249-249: Multiple headings with the same content

(MD024, no-duplicate-heading)


374-374: Dollar signs used before commands without showing output

(MD014, commands-show-output)


382-382: Dollar signs used before commands without showing output

(MD014, commands-show-output)


383-383: Dollar signs used before commands without showing output

(MD014, commands-show-output)


384-384: Dollar signs used before commands without showing output

(MD014, commands-show-output)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
configurations/services/mcp-8000.yaml (1)

20-22: Remove real-looking email to avoid PII exposure

The static JSON responses embed what looks like a real e-mail address ([email protected]). Publishing even fictitious personal data in public repos can raise compliance / GDPR questions and was flagged in the previous review round.

-            "details": "email: [email protected], role: admin, last-login: 02/07/2025"
+            "details": "email: [email protected], role: admin, last-login: 2025-07-02"-            "details": "Info: email: [email protected], last-login: 02/07/2025"
+            "details": "Info: email: [email protected], last-login: 2025-07-02"

Also applies to: 36-39

🧹 Nitpick comments (1)
configurations/services/mcp-8000.yaml (1)

41-41: Add trailing newline

yamllint flags the missing newline at EOF.
Helps maintain POSIX-friendly files and keeps linters quiet.

       }
+
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 967a852 and 05e0edd.

📒 Files selected for processing (1)
  • configurations/services/mcp-8000.yaml (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
configurations/services/mcp-8000.yaml

[error] 41-41: no new line character at the end of file

(new-line-at-end-of-file)

@mariocandela mariocandela changed the title Feat: add MCP honeypot support to Beelzebub Feat: add MCP honeypot support Jul 1, 2025
@mariocandela mariocandela merged commit c032489 into main Jul 1, 2025
6 checks passed
@mariocandela mariocandela deleted the mcp-honeypot branch July 1, 2025 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants