Skip to content

[CALCITE-7860] Add controls for remote fetches on file adapter - #5334

Merged
rubenada merged 1 commit into
apache:mainfrom
rubenada:CALCITE-7860
Oct 29, 2026
Merged

rubenada merged 1 commit into
apache:mainfrom
rubenada:CALCITE-7860

Conversation

@rubenada

@rubenada rubenada commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Jira Link

CALCITE-7860

Changes Proposed

Disable remote fetches by default to comply with threat model. Add new opt-in property to enable this feature.

@zabetak zabetak left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of adding two new properties for filtering URLs based on protocols and hosts why not simply going for a single property defining a list of allowed URL prefixes (e.g., calcite.file.urls.allowed). This would simplify documentation, implementation, and usage.

@rubenada

Copy link
Copy Markdown
Contributor Author

@zabetak what about proposing something like calcite.file.urls.allowed=https:,http://data.example.com/datasets/ , where:

  • An entry that is only a scheme (for example https:) allows any URL with that scheme, whatever its host, port and path.
  • Otherwise, in case of a "full" url (for example http://data.example.com/datasets/), it must be a match: the scheme must be equal (case-insensitive), the host must be equal (case-insensitive, exact, so that example.com does not admit my-example.com nor example.com.other.org), the port must be equal (an entry or URL without a port stands for the scheme's default port), if the entry has a path other than /, it must be equal to it or lie beneath it (e.g. http://data.example.com/datasets/t.csv would admitted in our example, but not http://data.example.com/datasets-abc)

@zabetak

zabetak commented Oct 26, 2026

Copy link
Copy Markdown
Member

calcite.file.urls.allowed=https:,http://data.example.com/datasets/ is inline with the simpe check I had in mind:

for(String prefix: allowedPrefixes) {
  if(url.startWith(prefix) {
    return true;
  }
}
return false;

As a conf separator the pipe char | is probably safer than comma ,.

@rubenada

Copy link
Copy Markdown
Contributor Author

startsWith check might be a bit problematic (https://data.example.com would let in https://data.example.com.bad.com/). I have pushed a refactoring with a bit more thorough validation based on url parts.

Comment thread file/src/main/java/org/apache/calcite/adapter/file/FileSchema.java Outdated

@zabetak zabetak left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The regex based proposal LGTM! I left some minor refactor/nit suggestions to handle at your discretion.

Comment thread core/src/main/java/org/apache/calcite/config/CalciteSystemProperty.java Outdated
Comment thread core/src/main/java/org/apache/calcite/config/CalciteSystemProperty.java Outdated
Comment thread file/src/main/java/org/apache/calcite/adapter/file/FileSchema.java Outdated
Comment thread file/src/main/java/org/apache/calcite/adapter/file/FileSchema.java Outdated
Comment thread file/src/main/java/org/apache/calcite/adapter/file/FileSchema.java Outdated
Comment thread file/src/test/java/org/apache/calcite/adapter/file/FileSchemaProtocolTest.java Outdated
Comment thread file/src/test/java/org/apache/calcite/adapter/file/FileSchemaProtocolTest.java Outdated
Comment thread file/src/test/java/org/apache/calcite/adapter/file/FileSchemaProtocolTest.java Outdated
Comment thread site/_docs/file_adapter.md
Comment thread site/_docs/history.md
@rubenada

Copy link
Copy Markdown
Contributor Author

Thanks for the review @zabetak ! I think I have applied all your suggestions. If you want to take another look, please let me know if you have any further remark.

@zabetak zabetak left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

All of my comments are addressed! Many thanks for pushing this @rubenada !

@sonarqubecloud

Copy link
Copy Markdown

@rubenada rubenada added the LGTM-will-merge-soon Overall PR looks OK. Only minor things left. label Oct 28, 2026
@rubenada
rubenada merged commit ba8f1f9 into apache:main Oct 29, 2026
22 checks passed
@rubenada

Copy link
Copy Markdown
Contributor Author

Thanks @zabetak for your help here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LGTM-will-merge-soon Overall PR looks OK. Only minor things left.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants