You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by "nightcityblade (via GitHub)" <gi...@apache.org> on 2026/08/13 15:15:23 UTC

[PR] Fix Azure Blob SAS signatures for encoded object paths [libcloud]

nightcityblade opened a new pull request, #2181:
URL: https://github.com/apache/libcloud/pull/2181

   ## Fix Azure Blob SAS signatures for encoded object paths
   
   ### Description
   
   Azure Blob SAS canonical resources must use the decoded object path when the
   signature is calculated, while the returned URL must remain percent-encoded.
   Decode the path only for the string-to-sign and add regression coverage for an
   object name containing a space.
   
   Fixes #1805.
   
   For more information on contributing, please see [Contributing](http://libcloud.readthedocs.org/en/latest/development.html#contributing)
   section of our documentation.
   
   ### Status
   
   - done, ready for review
   
   ### Checklist (tick everything that applies)
   
   - [x] [Code linting](http://libcloud.readthedocs.org/en/latest/development.html#code-style-guide) (`black --check`, `isort --check-only`, and focused `flake8` passed)
   - [ ] Documentation — N/A; this corrects existing signed-URL behavior without changing the public API
   - [x] [Tests](http://libcloud.readthedocs.org/en/latest/testing.html) (`pytest -q libcloud/test/storage/test_azure_blobs.py`: 86 passed)
   - [ ] [ICLA](http://libcloud.readthedocs.org/en/latest/development.html#contributing-bigger-changes) — N/A; this is a focused two-file bug fix
   


-- 
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: notifications-unsubscribe@libcloud.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix Azure Blob SAS signatures for encoded object paths [libcloud]

Posted by "micafer (via GitHub)" <gi...@apache.org>.
micafer commented on PR #2181:
URL: https://github.com/apache/libcloud/pull/2181#issuecomment-5521375466

   LGTM, could you add the information about this change in the CHANGES.rst file?


-- 
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: notifications-unsubscribe@libcloud.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix Azure Blob SAS signatures for encoded object paths [libcloud]

Posted by "micafer (via GitHub)" <gi...@apache.org>.
micafer commented on code in PR #2181:
URL: https://github.com/apache/libcloud/pull/2181#discussion_r3911284646


##########
libcloud/test/storage/test_azure_blobs.py:
##########
@@ -520,6 +521,19 @@ def test_get_object_cdn_url_put(self):
         self.assertEqual(len(query["sig"]), 1)
         self.assertGreater(len(query["sig"][0]), 0)
 
+    @patch("libcloud.storage.drivers.azure_blobs.hmac.new")
+    def test_get_object_cdn_url_with_spaces(self, mock_hmac_new):
+        mock_hmac_new.return_value.digest.return_value = b"signature"
+        container = Container(name="test_container200", extra={}, driver=self.driver)
+        obj = Object("file name.txt", 0, None, {}, {}, container, self.driver)
+
+        url = self.driver.get_object_cdn_url(obj)
+        string_to_sign = mock_hmac_new.call_args.args[1].decode("utf-8")

Review Comment:
   @nightcityblade, could you please check this revision?



-- 
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: notifications-unsubscribe@libcloud.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix Azure Blob SAS signatures for encoded object paths [libcloud]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #2181:
URL: https://github.com/apache/libcloud/pull/2181#discussion_r3903959385


##########
libcloud/test/storage/test_azure_blobs.py:
##########
@@ -520,6 +521,19 @@ def test_get_object_cdn_url_put(self):
         self.assertEqual(len(query["sig"]), 1)
         self.assertGreater(len(query["sig"][0]), 0)
 
+    @patch("libcloud.storage.drivers.azure_blobs.hmac.new")
+    def test_get_object_cdn_url_with_spaces(self, mock_hmac_new):
+        mock_hmac_new.return_value.digest.return_value = b"signature"
+        container = Container(name="test_container200", extra={}, driver=self.driver)
+        obj = Object("file name.txt", 0, None, {}, {}, container, self.driver)
+
+        url = self.driver.get_object_cdn_url(obj)
+        string_to_sign = mock_hmac_new.call_args.args[1].decode("utf-8")

Review Comment:
   `mock_hmac_new.call_args.args[1]` is brittle because it assumes the implementation always passes the HMAC message as the 2nd positional argument. If the production code switches to using keyword arguments (e.g., `msg=`) or changes positional ordering, this test will break even though behavior is unchanged. Consider extracting the message from either `call_args.kwargs.get('msg')` (or equivalent) fallback to positional args, or asserting against a helper that returns the string-to-sign rather than inspecting HMAC call internals.



-- 
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: notifications-unsubscribe@libcloud.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix Azure Blob SAS signatures for encoded object paths [libcloud]

Posted by "micafer (via GitHub)" <gi...@apache.org>.
micafer merged PR #2181:
URL: https://github.com/apache/libcloud/pull/2181


-- 
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: notifications-unsubscribe@libcloud.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix Azure Blob SAS signatures for encoded object paths [libcloud]

Posted by "nightcityblade (via GitHub)" <gi...@apache.org>.
nightcityblade commented on PR #2181:
URL: https://github.com/apache/libcloud/pull/2181#issuecomment-5564480242

   Added the Azure Blob SAS fix to CHANGES.rst as requested. The focused Azure Blob storage tests continue to pass.


-- 
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: notifications-unsubscribe@libcloud.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix Azure Blob SAS signatures for encoded object paths [libcloud]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #2181:
URL: https://github.com/apache/libcloud/pull/2181#issuecomment-5494146954

   ## [Codecov](https://app.codecov.io/gh/apache/libcloud/pull/2181?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 83.58%. Comparing base ([`9d14320`](https://app.codecov.io/gh/apache/libcloud/commit/9d1432048ec198ae0c3d7b9cbcced03a2a94d16a?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`d3abdc0`](https://app.codecov.io/gh/apache/libcloud/commit/d3abdc00719163f4fa7e0b8c5393a17e62cbb599?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@           Coverage Diff           @@
   ##            trunk    #2181   +/-   ##
   =======================================
     Coverage   83.58%   83.58%           
   =======================================
     Files         352      352           
     Lines       81808    81818   +10     
     Branches     8769     8770    +1     
   =======================================
   + Hits        68373    68383   +10     
     Misses      10562    10562           
     Partials     2873     2873           
   ```
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/libcloud/pull/2181?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [libcloud/storage/drivers/azure\_blobs.py](https://app.codecov.io/gh/apache/libcloud/pull/2181?src=pr&el=tree&filepath=libcloud%2Fstorage%2Fdrivers%2Fazure_blobs.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-bGliY2xvdWQvc3RvcmFnZS9kcml2ZXJzL2F6dXJlX2Jsb2JzLnB5) | `86.78% <ø> (ø)` | |
   | [libcloud/test/storage/test\_azure\_blobs.py](https://app.codecov.io/gh/apache/libcloud/pull/2181?src=pr&el=tree&filepath=libcloud%2Ftest%2Fstorage%2Ftest_azure_blobs.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-bGliY2xvdWQvdGVzdC9zdG9yYWdlL3Rlc3RfYXp1cmVfYmxvYnMucHk=) | `94.78% <100.00%> (+0.09%)` | :arrow_up: |
   </details>
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   </details>


-- 
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: notifications-unsubscribe@libcloud.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix Azure Blob SAS signatures for encoded object paths [libcloud]

Posted by "nightcityblade (via GitHub)" <gi...@apache.org>.
nightcityblade commented on PR #2181:
URL: https://github.com/apache/libcloud/pull/2181#issuecomment-5511694938

   Addressed in ce6f2ba: the test now reads the HMAC message from the msg keyword when present and otherwise falls back to the positional argument, avoiding dependence on one calling style. Focused Azure Blob tests: 2 passed.


-- 
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: notifications-unsubscribe@libcloud.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix Azure Blob SAS signatures for encoded object paths [libcloud]

Posted by "nightcityblade (via GitHub)" <gi...@apache.org>.
nightcityblade commented on PR #2181:
URL: https://github.com/apache/libcloud/pull/2181#issuecomment-5527720320

   Added the Azure Blob SAS fix to `CHANGES.rst` under Storage, including the issue reference and attribution. `git diff --check` passes; the focused test suite remains at the previously reported 86 passing tests (this checkout could not rerun it because `requests_mock` is unavailable in the system Python).


-- 
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: notifications-unsubscribe@libcloud.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org