Skip to content

fix: Escape string literals in infer_schema.py - #425

Merged
Andreas Albert (AndreasAlbertQC) merged 1 commit into
mainfrom
string-escape
Nov 18, 2026
Merged

Andreas Albert (AndreasAlbertQC) merged 1 commit into
mainfrom
string-escape

Conversation

@AndreasAlbertQC

Copy link
Copy Markdown
Collaborator

Motivation

The experimental infer_schema feature currently passes through unvalidated user input into code generation logic. While the code is not executed by the library, and is meant for review by the caller, we still want to avoid allowing code injection opportunities here.

Changes

  • Added sanitization of untrusted inputs in infer_schema

Copilot AI balanced review requested due to automatic review settings November 18, 2026 15:41
@codecov

codecov Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (7f68841) to head (67240d3).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #425   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           46        46           
  Lines         2587      2592    +5     
=========================================
+ Hits          2587      2592    +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Both new tests omit the Arrange, Act, and Assert markers required by the repository’s testing guidelines.

1 open issue
What changed in this PR

This PR hardens experimental schema generation by escaping untrusted string values before inserting them into generated Python code.

Changes:

  • Adds a shared string-literal helper for aliases, struct field names, and temporal type arguments.
  • Adds regression coverage for special characters, injection payloads, and escaped output formatting.
File Description
tests/​experimental/​test_infer_schema.py Tests escaping, injection prevention, and generated formatting.
dataframely/​experimental/​infer_schema.py Safely renders string literals using repr while preserving preferred quoting where possible.

Review effort: Balanced

Comment thread tests/experimental/test_infer_schema.py Resolved
@AndreasAlbertQC
Andreas Albert (AndreasAlbertQC) merged commit 6b2ef33 into main Nov 18, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants