CAMEL-23273 - Camel-Jbang-mcp: Warn about sensitive data in POM conte…#22344
CAMEL-23273 - Camel-Jbang-mcp: Warn about sensitive data in POM conte…#22344
Conversation
…nt passed to migration tools Add PomSanitizer utility to detect and mask sensitive data (passwords, tokens, API keys, secrets) in POM content before processing. Strips <servers> and <distributionManagement> sections. Add sanitizePom boolean parameter (default: true) to camel_migration_analyze, camel_dependency_check, and camel_migration_wildfly_karaf tools. Update tool descriptions with sanitization guidance. Add 21 tests covering detection, masking, placeholder preservation, and tool integration. Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
|
🧪 CI tested the following changed modules:
|
gnodet
left a comment
There was a problem hiding this comment.
Review Summary
Claude Code on behalf of Guillaume Nodet
Overview: This PR adds a PomSanitizer utility to detect and mask sensitive data (passwords, tokens, API keys) in POM content before processing by MCP migration tools. It adds a sanitizePom boolean parameter (default: true) to camel_migration_analyze, camel_dependency_check, and camel_migration_wildfly_karaf tools. Includes 21 unit tests for the sanitizer and 3 integration tests.
Verdict: Request changes
Blocking
- Rebase needed against current
main— This PR was branched beforedba5a0f7194e(CAMEL-23270), which added@Tool.Annotations(readOnlyHint, destructiveHint, openWorldHint)to all MCP tools. The PR's versions ofMigrationTools.java,DependencyCheckTools.java, andMigrationWildflyKarafTools.javado not include theannotationsparameter on@Tool. Merging as-is will either cause conflicts or silently drop the annotations. Please rebase onto currentmain.
Major
-
Code duplication — The 13-line sanitization block is copy-pasted identically across all three tool methods:
String processedPom = pomContent; List<String> sanitizationWarnings = new ArrayList<>(); if (sanitizePom == null || sanitizePom) { PomSanitizer.SanitizationResult sr = PomSanitizer.sanitize(pomContent); processedPom = sr.pomContent(); for (String pattern : sr.detectedPatterns()) { sanitizationWarnings.add("Sensitive data detected and masked: " + pattern); } }
Consider extracting a helper into
PomSanitizer, e.g.:record ProcessedPom(String content, List<String> warnings) {} static ProcessedPom process(String pomContent, Boolean sanitize) { ... }
This keeps each tool method clean and ensures consistent behavior if the sanitization logic evolves.
-
Missing integration tests for
MigrationToolsandMigrationWildflyKarafTools— Sanitization was added to all three tools, but integration tests were only added toDependencyCheckToolsTest. The other two tool test classes should also verify that:- sanitization masks sensitive data and produces warnings
sanitizePom=falsebypasses sanitization- analysis still works correctly after sanitization
Minor
<servers>is asettings.xmlelement, not apom.xmlelement — The<servers>section belongs to Maven'ssettings.xml, notpom.xml. A valid POM should never contain<servers>. While stripping it as a safety net for accidental pastes is harmless, the Javadoc should clarify this (e.g., "Strips<servers>sections which belong to settings.xml and may be accidentally included").
Nit
-
wasSanitizedfield is computed but never consumed —SanitizationResult.wasSanitized()is only used in tests, never by the tool methods themselves (they checkdetectedPatternsinstead). Consider removing it or documenting it's for testing/logging only. -
Per-pattern warning messages are verbose — The loop prefixes each detected pattern with
"Sensitive data detected and masked: ". A single summary warning (e.g.,"Sensitive data detected and masked: db.password, api.token") would be more concise in the tool response.
Overall the approach is sound — POM sanitization is a sensible security measure for MCP tools that accept user-provided POM content. The PomSanitizer regex patterns are well-crafted and the property placeholder preservation (${...}) is a nice touch. The test coverage for the sanitizer itself is thorough. The main action items are rebasing onto current main and reducing the code duplication.
…nt passed to migration tools
Add PomSanitizer utility to detect and mask sensitive data (passwords, tokens, API keys, secrets) in POM content before processing. Strips and sections. Add sanitizePom boolean parameter (default: true) to camel_migration_analyze, camel_dependency_check, and camel_migration_wildfly_karaf tools. Update tool descriptions with sanitization guidance. Add 21 tests covering detection, masking, placeholder preservation, and tool integration.
Description
Target
mainbranch)Tracking
Apache Camel coding standards and style
mvn clean install -DskipTestslocally from root folder and I have committed all auto-generated changes.