Skip to content

feat(maven/analyze): surface property source file in analysis output#97

Merged
dnegreira merged 1 commit into
chainguard-dev:mainfrom
dnegreira:parent-pom-property-resolution
Jun 4, 2026
Merged

feat(maven/analyze): surface property source file in analysis output#97
dnegreira merged 1 commit into
chainguard-dev:mainfrom
dnegreira:parent-pom-property-resolution

Conversation

@dnegreira
Copy link
Copy Markdown
Contributor

@dnegreira dnegreira commented Jun 4, 2026

Why

Maven projects commonly declare version properties in a parent POM referenced via <parent><relativePath> rather than in the analysed pom.xml. Before this change the analyzer had no concept of where a property came from, so properties in parent POMs showed as (new) with a warning — even though the update command found and patched them correctly. Additionally, parent chain traversal during analysis had no boundary, meaning it could read POM files outside the project tree.

What

pkg/analyzer/interface.go

  • Add PropertySources map[string]string to AnalysisResult, mapping each property name to the manifest file (project-relative path) that declares it.

pkg/languages/java/maven/analyzer.go

  • Introduce pomFileProperties struct (POM file path + property map) so searchForProperties groups discovered properties by file rather than flattening to a single map.
  • Add resolveUnknownProperties: after the filesystem walk, looks up any property still missing by following the <parent><relativePath> chain via the same resolvePropertyPomPath the updater uses — keeping analyze and update consistent.
  • Add mergeProperty helper (first-definition-wins, warns on conflicting values).
  • Bound findProjectRoot, resolveUnknownProperties, and searchForProperties to the analyzed project path using the existing validatePathWithinRoot helper, preventing reads outside the project tree.

pkg/languages/java/maven/updater.go / maven.go

  • Add rootDir boundary parameter to resolvePropertyPomPath and dependencyPropertyUpdates. The update path was already bounded by cfg.RootDir for writes; read traversal is now bounded consistently using the same helper.

cmd/omnibump/analyze.go

  • Text output shows [manifest: X] next to each property in the Property Usage section and a manifest: line above each property update in the Strategy section.

🤖 Generated with Claude Code

@dnegreira dnegreira force-pushed the parent-pom-property-resolution branch from 02eb93c to cf83e13 Compare June 4, 2026 12:02
@dnegreira dnegreira marked this pull request as draft June 4, 2026 12:06
@dnegreira dnegreira force-pushed the parent-pom-property-resolution branch 2 times, most recently from e61696b to 6a9c3e1 Compare June 4, 2026 15:22
…sal boundary

Maven projects commonly declare version properties in a parent POM
referenced via <parent><relativePath>. Before this change the analyzer
had no concept of where a property came from, showing properties in
parent POMs as '(new)' with a warning, even though the update command
found and patched them correctly. Additionally, parent chain traversal
during analysis had no boundary and could read POM files outside the
project tree.

What changed:
- Add PropertySources map[string]string to AnalysisResult, mapping each
  property name to the manifest file (project-relative path).
- Introduce pomFileProperties struct so searchForProperties groups
  discovered properties by file rather than flattening to a single map.
- Add resolveUnknownProperties, which looks up missing properties by
  following the <parent><relativePath> chain via resolvePropertyPomPath,
  keeping analyze and update consistent.
- Add mergeProperty helper (first-definition-wins, warns on conflict).
- Bound all parent POM traversal (findProjectRoot, resolveUnknownProperties,
  resolvePropertyPomPath, dependencyPropertyUpdates) to the analyzed project
  path using the existing validatePathWithinRoot helper, preventing reads
  outside the project tree. The update path was already bounded by
  cfg.RootDir for writes; analysis is now bounded consistently.
- Text output shows [manifest: X] next to each property in Property
  Usage and manifest: above each property update in the Strategy section.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@dnegreira dnegreira force-pushed the parent-pom-property-resolution branch from 6a9c3e1 to 426fc03 Compare June 4, 2026 15:28
@dnegreira dnegreira marked this pull request as ready for review June 4, 2026 15:45
@dnegreira dnegreira merged commit 80250b9 into chainguard-dev:main Jun 4, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants