You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "PApostol (via GitHub)" <gi...@apache.org> on 2023/08/11 20:36:37 UTC
[GitHub] [airflow] PApostol opened a new pull request, #33328: Sanitize filenames in MySQLHook
PApostol opened a new pull request, #33328:
URL: https://github.com/apache/airflow/pull/33328
This PR ensures filenames in MySQLHook are sanitized, so no arbitrary SQL execution could happen with e.g. `filename = "myfile; SELECT * FROM DUAL"`. Closes #33283.
--
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@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Sanitize filenames in MySQLHook [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #33328:
URL: https://github.com/apache/airflow/pull/33328#issuecomment-1875577456
Cool. Thanks for fixing it :)
--
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@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] eladkal commented on pull request #33328: Sanitize filenames in MySQLHook
Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on PR #33328:
URL: https://github.com/apache/airflow/pull/33328#issuecomment-1675378268
Can you please amend the commit message to a meaningful one? We generate release notes based on commit message thus it's important
--
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@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Sanitize filenames in MySQLHook [airflow]
Posted by "PApostol (via GitHub)" <gi...@apache.org>.
PApostol commented on PR #33328:
URL: https://github.com/apache/airflow/pull/33328#issuecomment-1826985831
Perhaps this can be merged now?
--
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@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Sanitize filenames in MySQLHook [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #33328:
URL: https://github.com/apache/airflow/pull/33328
--
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@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] potiuk commented on pull request #33328: Sanitize filenames in MySQLHook
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #33328:
URL: https://github.com/apache/airflow/pull/33328#issuecomment-1675825804
> > In the linked issue, I see:
> > ```
> > fillename = " file; SELECT * FROM DUAL"
> > ```
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Does your change remove the leading space? If not, could you add a strip on `re.sub` result?
>
> The change doesn't remove leading spaces. I presumed the issue was with SQL commands following any `;` - not sure if leading spaces cause any problems here. Happy to include a `strip()` though!
I think it's a little bit more complex though, sheer presence of ";" is not enough, it will be " ';" that will trigger it.
I am thinking that better solution will be to actually use prepared statement in this case. Not sure if that works for this command (but there is no reason it should not):
https://dev.mysql.com/doc/connector-python/en/connector-python-api-mysqlcursorprepared.html
This is the ultimate way how you can avoid sql injection type of problems like this one.
--
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@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Sanitize filenames in MySQLHook [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #33328:
URL: https://github.com/apache/airflow/pull/33328#issuecomment-1831033558
There was an error that looked suspiciously related (MySQL test failed but also could be flake) I re-run it - if it happens again I think you will need to fix it @PApostol
--
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@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Sanitize filenames in MySQLHook [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #33328:
URL: https://github.com/apache/airflow/pull/33328#issuecomment-1827002456
Rebased it. Generatlly when we have old PRs that (for whatever reason) has not been built for some time, rebasing is firt thing to do.
--
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@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Sanitize filenames in MySQLHook [airflow]
Posted by "PApostol (via GitHub)" <gi...@apache.org>.
PApostol commented on PR #33328:
URL: https://github.com/apache/airflow/pull/33328#issuecomment-1875561872
Hello, I have updated the PR, tests seem to pass now. Perhaps it can be reviewed?
--
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@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] potiuk commented on pull request #33328: Sanitize filenames in MySQLHook
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #33328:
URL: https://github.com/apache/airflow/pull/33328#issuecomment-1676500976
Shall we wait :)?
https://endoflife.date/mysql
> Ends in 2 months and 2 weeks (31 Oct 2023)
Actually I would be qute fine to make it MySQL 8 only feature in anticipation of us dropping support in provider. Users might still use older provoders if they want to keep 5.7.
--
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@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] PApostol commented on pull request #33328: Sanitize filenames in MySQLHook
Posted by "PApostol (via GitHub)" <gi...@apache.org>.
PApostol commented on PR #33328:
URL: https://github.com/apache/airflow/pull/33328#issuecomment-1740746537
I wonder is this PR can still be useful in 1 month when MySQL 5.7 reaches EOL?
--
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@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] potiuk commented on pull request #33328: Sanitize filenames in MySQLHook
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #33328:
URL: https://github.com/apache/airflow/pull/33328#issuecomment-1676445343
Very much so.
--
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@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] potiuk commented on pull request #33328: Sanitize filenames in MySQLHook
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #33328:
URL: https://github.com/apache/airflow/pull/33328#issuecomment-1675826742
Then you do not have sanitize file name at all. It's effectively mitigated by the driver parsing the statement first and adding filename later.
--
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@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] PApostol commented on pull request #33328: Sanitize filenames in MySQLHook
Posted by "PApostol (via GitHub)" <gi...@apache.org>.
PApostol commented on PR #33328:
URL: https://github.com/apache/airflow/pull/33328#issuecomment-1676460108
It looks like the above syntax doesn't sit well with MySQL 5.7!
--
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@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] github-actions[bot] commented on pull request #33328: Sanitize filenames in MySQLHook
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #33328:
URL: https://github.com/apache/airflow/pull/33328#issuecomment-1740145637
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.
--
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@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Sanitize filenames in MySQLHook [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #33328:
URL: https://github.com/apache/airflow/pull/33328#issuecomment-1752130679
yes
--
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@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] PApostol commented on pull request #33328: Sanitize filenames in MySQLHook
Posted by "PApostol (via GitHub)" <gi...@apache.org>.
PApostol commented on PR #33328:
URL: https://github.com/apache/airflow/pull/33328#issuecomment-1675765515
> In the linked issue, I see:
>
> ```
> fillename = " file; SELECT * FROM DUAL"
> ```
>
> Does your change remove the leading space? If not, could you add a strip on `re.sub` result?
The change doesn't remove leading spaces. I presumed the issue was with SQL commands following any `;` - not sure if leading spaces cause any problems here. Happy to include a `strip()` though!
--
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@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] PApostol commented on pull request #33328: Sanitize filenames in MySQLHook
Posted by "PApostol (via GitHub)" <gi...@apache.org>.
PApostol commented on PR #33328:
URL: https://github.com/apache/airflow/pull/33328#issuecomment-1676444419
Regarding PREPARE statements, would changing
```
cur = conn.cursor()
cur.execute(
f"""
LOAD DATA LOCAL INFILE '{tmp_file}'
INTO TABLE {table}
"""
)
```
into
```
cur = conn.cursor(prepared=True)
cur.execute(
"""
LOAD DATA LOCAL INFILE '%s'
INTO TABLE %s
""",
(tmp_file, table)
)
```
do the trick?
--
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@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Sanitize filenames in MySQLHook [airflow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #33328:
URL: https://github.com/apache/airflow/pull/33328#issuecomment-1823681701
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.
--
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@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Sanitize filenames in MySQLHook [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #33328:
URL: https://github.com/apache/airflow/pull/33328#issuecomment-1831042545
Yep. it looks like:
> Perhaps this can be merged now?
So ... no :) until it is fixed :)
--
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@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] PApostol commented on pull request #33328: Sanitize filenames in MySQLHook
Posted by "PApostol (via GitHub)" <gi...@apache.org>.
PApostol commented on PR #33328:
URL: https://github.com/apache/airflow/pull/33328#issuecomment-1675384407
> Can you please amend the commit message to a meaningful one? We generate release notes based on commit message thus it's important
Done, sorry, I must have replaced the main commit message accidentally.
--
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@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] potiuk commented on pull request #33328: Sanitize filenames in MySQLHook
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #33328:
URL: https://github.com/apache/airflow/pull/33328#issuecomment-1677100135
One of the ways to do it is to make if (mysql 8 -> prepare, if not, don't) for now and then in 2 months we will drop it completely.
--
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@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org