You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "potiuk (via GitHub)" <gi...@apache.org> on 2024/11/16 01:55:22 UTC
[PR] Add useforsecurity for sha1 algorithm [airflow]
potiuk opened a new pull request, #44081:
URL: https://github.com/apache/airflow/pull/44081
SHA1 is cryptographically weak and some restricted environments (FIPS compliant) are blocking weak algorithms. You can use them (as of Python 3.9) in those environments by specifically stating that the algorithm is not used for security.
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
<!-- Please keep an empty line above the dashes. -->
---
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
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](https://github.com/apache/airflow/tree/main/newsfragments).
--
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] Add usedforsecurity for sha1 algorithm [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #44081:
URL: https://github.com/apache/airflow/pull/44081#issuecomment-2480340778
Updated 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
Re: [PR] Add usedforsecurity for sha1 algorithm [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #44081:
URL: https://github.com/apache/airflow/pull/44081#issuecomment-2480353333
> The usedforsecurity parameter for hashlib.sha1 is available from Python 3.9 onwards. Verify that the project does not need to support older versions of Python.
Thanks Copiiot. That was a useful advice and yes we use Python 3.9+ - that's why we could apply those fixes :).
BTW. Today I got the Copilot Review access that I applied - I will be experimenting with it and adding it on some PRs to see how good it is.
--
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] Add usedforsecurity for sha1 algorithm [airflow]
Posted by "rawwar (via GitHub)" <gi...@apache.org>.
rawwar commented on PR #44081:
URL: https://github.com/apache/airflow/pull/44081#issuecomment-2480319467
@potiuk , I notice hashlib.sha1 being used in two other places as well:
1. https://github.com/apache/airflow/blob/19303ca655ad8f977642be49dc225433ffa3cef5/airflow/models/dagcode.py#L197
2. https://github.com/apache/airflow/blob/19303ca655ad8f977642be49dc225433ffa3cef5/airflow/models/taskinstance.py#L2543
--
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] Add usedforsecurity for sha1 algorithm [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #44081:
URL: https://github.com/apache/airflow/pull/44081
--
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] Add usedforsecurity for sha1 algorithm [airflow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #44081:
URL: https://github.com/apache/airflow/pull/44081#issuecomment-2480855391
### Backport failed to create: v2-10-test. View the failure log <a href='https://github.com/apache/airflow/actions/runs/11874200699'> Run details </a>
<table>
<tr>
<th>Status</th>
<th>Branch</th>
<th>Result</th>
</tr>
<tr>
<td>❌</td>
<td>v2-10-test</td>
<td><a href="https://github.com/apache/airflow/commit/a85d94e6cdcd09efe93c3acee0b4ce5c9508bc23"><img src='https://img.shields.io/badge/Commit-a85d94e-red' alt='Commit Link'></a></td>
</tr>
</table>
--
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] Add usedforsecurity for sha1 algorithm [airflow]
Posted by "gopidesupavan (via GitHub)" <gi...@apache.org>.
gopidesupavan commented on PR #44081:
URL: https://github.com/apache/airflow/pull/44081#issuecomment-2480881324
> ### Backport failed to create: v2-10-test. View the failure log [ Run details ](https://github.com/apache/airflow/actions/runs/11874200699)
> Status Branch Result
> ❌ v2-10-test [](https://github.com/apache/airflow/commit/a85d94e6cdcd09efe93c3acee0b4ce5c9508bc23)
Looks like it failed, due to conflicts
--
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] Add usedforsecurity for sha1 algorithm [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #44081:
URL: https://github.com/apache/airflow/pull/44081#issuecomment-2480336258
> @potiuk , I notice `hashlib.sha1` being used in two other places that can use this argument:
Oh nice. I wonder why CodeQL has not detected those :)
--
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] Add usedforsecurity for sha1 algorithm [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #44081:
URL: https://github.com/apache/airflow/pull/44081#issuecomment-2480304492
This has been detected by CodeQL scanning (cc: @vikramkoka -> FIPS compliance, that what we talked about on Thursday.
--
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] Add usedforsecurity for sha1 algorithm [airflow]
Posted by "shahar1 (via GitHub)" <gi...@apache.org>.
shahar1 commented on code in PR #44081:
URL: https://github.com/apache/airflow/pull/44081#discussion_r1845029040
##########
airflow/models/dagcode.py:
##########
@@ -194,4 +194,9 @@ def dag_fileloc_hash(full_filepath: str) -> int:
import hashlib
# Only 7 bytes because MySQL BigInteger can hold only 8 bytes (signed).
- return struct.unpack(">Q", hashlib.sha1(full_filepath.encode("utf-8")).digest()[-8:])[0] >> 8
+ return (
+ struct.unpack(
+ ">Q", hashlib.sha1(full_filepath.encode("utf-8"), usedforsecurity=False).digest()[-8:]
+ )[0]
+ >> 8
+ )
Review Comment:
Maybe adding a small unit test would be nice? (sanity check for the next time the algorithm changes)
Same for the other code parts, where it makes sense.
##########
airflow/models/dagcode.py:
##########
@@ -194,4 +194,9 @@ def dag_fileloc_hash(full_filepath: str) -> int:
import hashlib
# Only 7 bytes because MySQL BigInteger can hold only 8 bytes (signed).
- return struct.unpack(">Q", hashlib.sha1(full_filepath.encode("utf-8")).digest()[-8:])[0] >> 8
+ return (
+ struct.unpack(
+ ">Q", hashlib.sha1(full_filepath.encode("utf-8"), usedforsecurity=False).digest()[-8:]
+ )[0]
+ >> 8
+ )
Review Comment:
Maybe adding a small unit test would be nice? (sanity check for the next time the algorithm might change)
Same for the other code parts, where it makes sense.
--
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] Add usedforsecurity for sha1 algorithm [airflow]
Posted by "shahar1 (via GitHub)" <gi...@apache.org>.
shahar1 commented on code in PR #44081:
URL: https://github.com/apache/airflow/pull/44081#discussion_r1845029040
##########
airflow/models/dagcode.py:
##########
@@ -194,4 +194,9 @@ def dag_fileloc_hash(full_filepath: str) -> int:
import hashlib
# Only 7 bytes because MySQL BigInteger can hold only 8 bytes (signed).
- return struct.unpack(">Q", hashlib.sha1(full_filepath.encode("utf-8")).digest()[-8:])[0] >> 8
+ return (
+ struct.unpack(
+ ">Q", hashlib.sha1(full_filepath.encode("utf-8"), usedforsecurity=False).digest()[-8:]
+ )[0]
+ >> 8
+ )
Review Comment:
Maybe adding a small unit test would be nice? (sanity check for the next time the algorithm changes)
--
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] Add usedforsecurity for sha1 algorithm [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #44081:
URL: https://github.com/apache/airflow/pull/44081#discussion_r1845061486
##########
airflow/models/dagcode.py:
##########
@@ -194,4 +194,9 @@ def dag_fileloc_hash(full_filepath: str) -> int:
import hashlib
# Only 7 bytes because MySQL BigInteger can hold only 8 bytes (signed).
- return struct.unpack(">Q", hashlib.sha1(full_filepath.encode("utf-8")).digest()[-8:])[0] >> 8
+ return (
+ struct.unpack(
+ ">Q", hashlib.sha1(full_filepath.encode("utf-8"), usedforsecurity=False).digest()[-8:]
+ )[0]
+ >> 8
+ )
Review Comment:
We already have CodeQL scanning and detecting those. I think it's unlkely we will ever remove the flag, so it's not really prone to regression, what is more worrying is if we start using it elsewhere - but for that CodeQL scanning **should** in principle detect such future usages.
--
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