Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using quotes for file path in find command #46795

Merged
merged 2 commits into from
Feb 16, 2025

Conversation

amoghrajesh
Copy link
Contributor

We perform a find command here:

locate_file_cmd = """
sleep 10
find {{params.source_location}} -type f -printf "%f\n" | head -1
"""
t_view = BashOperator(
task_id="view_file",
bash_command=locate_file_cmd,
do_xcom_push=True,
params={"source_location": "/your/input_dir/path"},
dag=dag,
)
. Since its a file find, we should use quotes.


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

@potiuk
Copy link
Member

potiuk commented Feb 15, 2025

Still when the params contain "'" tt can be abused .

@amoghrajesh
Copy link
Contributor Author

Ah yes. good catch!

@amoghrajesh
Copy link
Contributor Author

@potiuk shlex is the way to go. I tried with double and single quotes, works as I expected.

@potiuk potiuk merged commit 7f98fde into apache:main Feb 16, 2025
60 checks passed
@Vincent550102
Copy link
Contributor

@amoghrajesh The injection still exists. I just send a PR.

#46809

dantonbertuol pushed a commit to dantonbertuol/airflow that referenced this pull request Feb 17, 2025
* Using quotes for file path in find command

* preventing quoted params
ntr pushed a commit to ntr/airflow that referenced this pull request Feb 20, 2025
* Using quotes for file path in find command

* preventing quoted params
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants