You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "oscerd (via GitHub)" <gi...@apache.org> on 2026/07/29 11:24:05 UTC
[PR] CAMEL-24293: Strip path segments from externally-derived filenames before setting CamelFileName [camel]
oscerd opened a new pull request, #25218:
URL: https://github.com/apache/camel/pull/25218
Reduces externally-derived filenames to a leaf name (`FileUtil.stripPath`) before they are placed in the `CamelFileName` control header, so path segments carried by an archive/multipart name are not propagated to downstream file/ftp producers. This aligns these paths with the normalisation other file-producing paths already apply.
### What
`CamelFileName` (`Exchange.FILE_NAME`) is consumed by file/ftp producers to choose the output filename. Three paths set it from an externally-derived name that may contain path segments:
- **camel-platform-http-vertx** — `VertxPlatformHttpConsumer` set it from the raw multipart `Content-Disposition` filename (`upload.fileName()`).
- **camel-zipfile** — `ZipFileDataFormat` / `ZipIterator` set it from the raw ZIP entry name.
- **camel-tarfile** — `TarFileDataFormat` / `TarIterator` set it from the raw TAR entry name.
Each now applies `FileUtil.stripPath(...)`. The **marshal** paths (`ZipFileDataFormat` / `TarFileDataFormat` output-filename headers, which are route-author-controlled) are intentionally left unchanged.
### Tests
New `ZipFileNameStripPathTest` and `TarFileNameStripPathTest` assert that an entry name with a directory prefix (`subdir/evil.txt`) yields `CamelFileName = evil.txt` after unmarshal. The vertx multipart path uses the identical `FileUtil.stripPath` call.
### Notes
- Non-breaking: legitimate leaf filenames are unaffected.
- Improvement / consistency hardening — **not backported** (main only).
- Full reactor build (`mvn clean install -DskipTests`) succeeds with no generated-file drift.
---
_Claude Code on behalf of Andrea Cosentino (@oscerd)_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-24293: Strip path segments from externally-derived filenames before setting CamelFileName [camel]
Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd commented on PR #25218:
URL: https://github.com/apache/camel/pull/25218#issuecomment-5128022757
Pushed e33199a to green the CI and complete the change:
- The tarfile/zipfile `testUnzip/UntarWithEmptyDirectory*` tests rebuilt the archive's directory layout from `CamelFileName`. Since this PR now hardens `CamelFileName` to the stripped base name (Tar/Zip Slip prevention), `getParentFile()` was null for the stripped directory entry → NPE. Updated the tests to rebuild structure from the full entry name that is still exposed on a dedicated header (`CamelTarFileEntryName` for tar, `zipFileName` for zip).
- Added a **4.22 upgrade-guide** entry, since setting `CamelFileName` to the base name is a behavior change for routes that relied on the full path being in that header.
The rest of the diff (tar/zip/vertx-platform-http) is unchanged. Both dataformat test suites pass locally (tar 16, zip 17).
_Claude Code on behalf of Andrea Cosentino (@oscerd)._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-24293: Strip path segments from externally-derived filenames before setting CamelFileName [camel]
Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd commented on PR #25218:
URL: https://github.com/apache/camel/pull/25218#issuecomment-5129306569
Thanks for the re-review, @gnodet. I believe the iterator finding is a misread of the diff — both iterators **do** apply `FileUtil.stripPath()` to `CamelFileName`. The lines cited (ZipIterator:148, TarIterator:135) are the *dedicated full-name headers*, not `CamelFileName`:
**ZipIterator.java**
- L148 `answer.setHeader("zipFileName", zipFileName);` ← full name preserved on the dedicated header
- L151 `answer.setHeader(Exchange.FILE_NAME, FileUtil.stripPath(zipFileName));` ← **CamelFileName stripped**
**TarIterator.java**
- L135 `answer.setHeader(TARFILE_ENTRY_NAME_HEADER, current.getName());` ← full name on `CamelTarFileEntryName`
- L139 `answer.setHeader(Exchange.FILE_NAME, FileUtil.stripPath(current.getName()));` ← **CamelFileName stripped**
So the splitter paths (`ZipSplitter`/`TarSplitter`, which iterate via these classes) are covered, and the upgrade-guide wording ("both the data format and the iterator/splitter modes") is accurate. `ZipFileNameStripPathTest`/`TarFileNameStripPathTest` exercise the iterator path.
Both iterator files are in the diff (`git diff origin/main...HEAD -- ...ZipIterator.java ...TarIterator.java` shows the `FileUtil.stripPath` change). Re-requesting review — happy to add an explicit `ZipSplitter`-based test if you'd like belt-and-suspenders coverage.
_Claude Code on behalf of Andrea Cosentino (@oscerd)._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-24293: Strip path segments from externally-derived filenames before setting CamelFileName [camel]
Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd merged PR #25218:
URL: https://github.com/apache/camel/pull/25218
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-24293: Strip path segments from externally-derived filenames before setting CamelFileName [camel]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #25218:
URL: https://github.com/apache/camel/pull/25218#issuecomment-5117561519
:star2: Thank you for your contribution to the Apache Camel project! :star2:
:robot: CI automation will test this PR automatically.
:camel: Apache Camel Committers, please review the following items:
* First-time contributors **require MANUAL approval** for the GitHub Actions to run
* You can use the command `/component-test (camel-)component-name1 (camel-)component-name2..` to request a test from the test bot although they are normally detected and executed by CI.
* You can label PRs using `skip-tests` and `test-dependents` to fine-tune the checks executed by this PR.
* Build and test logs are available in the summary page. **Only** [Apache Camel committers](https://camel.apache.org/community/team/#committers) have access to the summary.
:warning: Be careful when sharing logs. Review their contents before sharing them publicly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-24293: Strip path segments from externally-derived filenames before setting CamelFileName [camel]
Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd commented on PR #25218:
URL: https://github.com/apache/camel/pull/25218#issuecomment-5130564445
Thanks @gnodet — you're right on both counts. The earlier commit (`e33199a`) prepared the tests + upgrade guide for the iterator fix, but the iterator change itself never landed: it had been reverted when a naive strip broke the empty-directory splitter tests, and wasn't correctly re-applied. Fixed now in `04f3f9a`:
- **`ZipIterator`** and **`TarIterator`** now set `CamelFileName` via `FileUtil.stripPath(...)`, matching the data-format paths. The full entry name stays on the dedicated headers (`zipFileName` / `CamelTarFileEntryName`), so directory-structure reconstruction (e.g. the empty-directory splitter tests) keeps working — reading from the dedicated header is exactly what makes the strip safe here, and why the earlier naive revert was needed.
- **Regression coverage added:** `ZipFileNameStripPathTest` / `TarFileNameStripPathTest` now also exercise `.split(new ZipSplitter())` / `.split(new TarSplitter())` and assert `CamelFileName == "evil.txt"` while the dedicated header keeps `"subdir/evil.txt"`.
- **Upgrade guide** needs no change — it already documented both the data-format and iterator/splitter modes; the code now matches it.
Verified: full `camel-zipfile` + `camel-tarfile` suites green (including `testUnzipWithEmptyDirectory*` / `testUntarWithEmptyDirectory*`), plus a full-reactor `mvn clean install -DskipTests` with no generated-file drift.
_Claude Code on behalf of Andrea Cosentino_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-24293: Strip path segments from externally-derived filenames before setting CamelFileName [camel]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #25218:
URL: https://github.com/apache/camel/pull/25218#issuecomment-5118113941
<!-- ci-tested-modules -->
:test_tube: **CI tested the following changed modules:**
- `components/camel-platform-http-vertx`
- `components/camel-tarfile`
- `components/camel-zipfile`
---
<details><summary>:microscope: Scalpel shadow comparison — Scalpel: 19 tested, 29 compile-only — current: 19 all tested</summary>
[Maveniverse Scalpel](https://github.com/maveniverse/scalpel) detected **48 affected modules** (current approach: 19).
<details><summary>:warning: Modules only in Scalpel (29)</summary>
- `apache-camel`
- `camel-allcomponents`
- `camel-catalog`
- `camel-catalog-console`
- `camel-catalog-lucene`
- `camel-catalog-maven`
- `camel-catalog-suggest`
- `camel-componentdsl`
- `camel-csimple-maven-plugin`
- `camel-endpointdsl`
- `camel-endpointdsl-support`
- `camel-itest`
- `camel-jbang-core`
- `camel-jbang-it`
- `camel-jbang-main`
- `camel-jbang-plugin-edit`
- `camel-jbang-plugin-generate`
- `camel-jbang-plugin-kubernetes`
- `camel-jbang-plugin-test`
- `camel-kamelet-main`
- `camel-launcher`
- `camel-report-maven-plugin`
- `camel-route-parser`
- `camel-yaml-dsl`
- `camel-yaml-dsl-deserializers`
- `camel-yaml-dsl-maven-plugin`
- `coverage`
- `docs`
- `dummy-component`
</details>
**Skip-tests mode would test 19 modules** (3 direct + 16 downstream), **skip tests for 29** (generated code, meta-modules)
<details><summary>Modules Scalpel would test (19)</summary>
- `camel-a2a`
- `camel-jbang-mcp`
- `camel-jbang-plugin-mcp`
- `camel-jbang-plugin-route-parser`
- `camel-jbang-plugin-tui`
- `camel-jbang-plugin-validate`
- `camel-jsonpath`
- `camel-knative-http`
- `camel-launcher-container`
- `camel-micrometer-prometheus`
- `camel-oauth`
- `camel-observability-services`
- `camel-openapi-validator`
- `camel-platform-http-main`
- `camel-platform-http-vertx`
- `camel-tarfile`
- `camel-yaml-dsl-validator`
- `camel-yaml-dsl-validator-maven-plugin`
- `camel-zipfile`
</details>
<details><summary>Modules with tests skipped (29)</summary>
- `apache-camel`
- `camel-allcomponents`
- `camel-catalog`
- `camel-catalog-console`
- `camel-catalog-lucene`
- `camel-catalog-maven`
- `camel-catalog-suggest`
- `camel-componentdsl`
- `camel-csimple-maven-plugin`
- `camel-endpointdsl`
- `camel-endpointdsl-support`
- `camel-itest`
- `camel-jbang-core`
- `camel-jbang-it`
- `camel-jbang-main`
- `camel-jbang-plugin-edit`
- `camel-jbang-plugin-generate`
- `camel-jbang-plugin-kubernetes`
- `camel-jbang-plugin-test`
- `camel-kamelet-main`
- `camel-launcher`
- `camel-report-maven-plugin`
- `camel-route-parser`
- `camel-yaml-dsl`
- `camel-yaml-dsl-deserializers`
- `camel-yaml-dsl-maven-plugin`
- `coverage`
- `docs`
- `dummy-component`
</details>
> :information_source: Shadow mode — Scalpel observes but does not affect test execution. [Learn more](https://github.com/maveniverse/scalpel)
</details>
<details><summary>All tested modules (48 modules)</summary>
- Camel :: AI :: A2A
- Camel :: All Components Sync point
- Camel :: Assembly
- Camel :: Catalog :: CSimple Maven Plugin (deprecated)
- Camel :: Catalog :: Camel Catalog
- Camel :: Catalog :: Camel Report Maven Plugin
- Camel :: Catalog :: Camel Route Parser
- Camel :: Catalog :: Console
- Camel :: Catalog :: Dummy Component
- Camel :: Catalog :: Lucene (deprecated)
- Camel :: Catalog :: Maven
- Camel :: Catalog :: Suggest
- Camel :: Component DSL
- Camel :: Coverage
- Camel :: Docs
- Camel :: Endpoint DSL
- Camel :: Endpoint DSL :: Support
- Camel :: Integration Tests
- Camel :: JBang :: Core
- Camel :: JBang :: Integration tests
- Camel :: JBang :: MCP
- Camel :: JBang :: Main
- Camel :: JBang :: Plugin :: Edit
- Camel :: JBang :: Plugin :: Generate
- Camel :: JBang :: Plugin :: Kubernetes
- Camel :: JBang :: Plugin :: MCP
- Camel :: JBang :: Plugin :: Route Parser
- Camel :: JBang :: Plugin :: TUI
- Camel :: JBang :: Plugin :: Testing
- Camel :: JBang :: Plugin :: Validate
- Camel :: JSon Path
- Camel :: Kamelet Main
- Camel :: Knative HTTP
- Camel :: Launcher
- Camel :: Launcher :: Container
- Camel :: Micrometer :: Prometheus
- Camel :: OAuth
- Camel :: Observability Services
- Camel :: OpenAPI :: Validator
- Camel :: Platform HTTP :: Main
- Camel :: Platform HTTP :: Vert.x
- Camel :: Tar File
- Camel :: YAML DSL
- Camel :: YAML DSL :: Deserializers
- Camel :: YAML DSL :: Maven Plugins
- Camel :: YAML DSL :: Validator
- Camel :: YAML DSL :: Validator Maven Plugin
- Camel :: Zip File
</details>
---
:gear: [View full build and test results](https://github.com/apache/camel/actions/runs/30447421160)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org