Add jws-diag diff command: compare effective config between two CATALINA_BASE directories - #20
Conversation
|
check on conflicts |
|
|
||
| private ServerConfig parse(Path serverXml, Path base) { | ||
| try { | ||
| Path resolverBase = Files.isDirectory(base) ? base : base.getParent().getParent(); |
There was a problem hiding this comment.
NPE when --left/--right is a bare filename (e.g., server.xml). Null-check getParent() first
There was a problem hiding this comment.
Fixed. getParent() result is now null-checked before calling getParent() again; PropertyResolver.create(null) is safe (it skips property loading) so a bare filename like server.xml no longer throws NPE.
| } | ||
| } | ||
|
|
||
| private void compareConnectors(String svcPath, |
There was a problem hiding this comment.
skips sslHostConfigs; TLS certificate/keystore/cipher changes are silently missed
There was a problem hiding this comment.
Fixed. Added compareSslHostConfigs and compareCertificates methods keyed by hostName (with index fallback) and certificate type (with index fallback) respectively. SSL block diff now covers protocols, sslEnabledProtocols, ciphers, certificateVerification, and per-certificate keystoreFile/keystoreType/type fields.
| return new DiffReport(leftBase, rightBase, entries); | ||
| } | ||
|
|
||
| private void compareServer(ServerConfig left, ServerConfig right, List<DiffEntry> out) { |
There was a problem hiding this comment.
skips shutdownCommand; security-relevant change (SEC-003 fix) would go undetected
There was a problem hiding this comment.
Fixed. Added diffNullable("server.shutdownCommand", ...) call in compareServer. A changed or missing SHUTDOWN token will now appear in the diff output.
c5f0763 to
9f744d4
Compare
|
@onkar717 can you add tests for the SSL, certificate and shutdownCommand diff logic? |
Summary
jws-diag diff --left <base> --right <base>(stretch goal, Week 12)server.xmlfiles, emits structural diff of connectors, executors, and server-level settingsConfigValueprovenance (explicit/default) preserved so users see what changed and whether it was intentionalschemaVersion: "1.0"conventionconf/server.xml) or direct path to any XML fileNew files
diff/model/ChangeType.javadiff/model/DiffEntry.javadiff/model/DiffReport.javadiff/ConfigDiffer.javadiff/formatter/DiffHumanFormatter.javadiff/formatter/DiffJsonFormatter.javadiff/DiffCommand.javaTest plan
ConfigDifferTest- 9 tests: identical configs, shutdown port change, connector field change with provenance, connector ADDED/REMOVED, executor ADDED/REMOVED, executor field change, multiple changes, path metadataDiffHumanFormatterTest- 6 tests: no-diff message, CHANGED arrow, ADDED/REMOVED labels, change count header, section groupingDiffJsonFormatterTest- 6 tests: schemaVersion, left/right in root, changeCount, CHANGED entry fields, ADDED null-left, empty diff arraymvn verify)jws-diag diff --helprenders correctly