fluidattacks_core_git 12.2.0__tar.gz → 12.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. {fluidattacks_core_git-12.2.0 → fluidattacks_core_git-12.2.1}/PKG-INFO +1 -1
  2. {fluidattacks_core_git-12.2.0 → fluidattacks_core_git-12.2.1}/fluidattacks_core/git/utils.py +1 -0
  3. {fluidattacks_core_git-12.2.0 → fluidattacks_core_git-12.2.1}/pyproject.toml +1 -1
  4. fluidattacks_core_git-12.2.1/tests/test_utils.py +64 -0
  5. {fluidattacks_core_git-12.2.0 → fluidattacks_core_git-12.2.1}/.envrc +0 -0
  6. {fluidattacks_core_git-12.2.0 → fluidattacks_core_git-12.2.1}/.gitignore +0 -0
  7. {fluidattacks_core_git-12.2.0 → fluidattacks_core_git-12.2.1}/fluidattacks_core/git/__init__.py +0 -0
  8. {fluidattacks_core_git-12.2.0 → fluidattacks_core_git-12.2.1}/fluidattacks_core/git/classes.py +0 -0
  9. {fluidattacks_core_git-12.2.0 → fluidattacks_core_git-12.2.1}/fluidattacks_core/git/clone.py +0 -0
  10. {fluidattacks_core_git-12.2.0 → fluidattacks_core_git-12.2.1}/fluidattacks_core/git/codecommit_utils.py +0 -0
  11. {fluidattacks_core_git-12.2.0 → fluidattacks_core_git-12.2.1}/fluidattacks_core/git/constants.py +0 -0
  12. {fluidattacks_core_git-12.2.0 → fluidattacks_core_git-12.2.1}/fluidattacks_core/git/delete_files.py +0 -0
  13. {fluidattacks_core_git-12.2.0 → fluidattacks_core_git-12.2.1}/fluidattacks_core/git/download_file.py +0 -0
  14. {fluidattacks_core_git-12.2.0 → fluidattacks_core_git-12.2.1}/fluidattacks_core/git/download_repo.py +0 -0
  15. {fluidattacks_core_git-12.2.0 → fluidattacks_core_git-12.2.1}/fluidattacks_core/git/https_utils.py +0 -0
  16. {fluidattacks_core_git-12.2.0 → fluidattacks_core_git-12.2.1}/fluidattacks_core/git/py.typed +0 -0
  17. {fluidattacks_core_git-12.2.0 → fluidattacks_core_git-12.2.1}/fluidattacks_core/git/remote.py +0 -0
  18. {fluidattacks_core_git-12.2.0 → fluidattacks_core_git-12.2.1}/fluidattacks_core/git/show_file.py +0 -0
  19. {fluidattacks_core_git-12.2.0 → fluidattacks_core_git-12.2.1}/fluidattacks_core/git/ssh_utils.py +0 -0
  20. {fluidattacks_core_git-12.2.0 → fluidattacks_core_git-12.2.1}/fluidattacks_core/git/upload_repo.py +0 -0
  21. {fluidattacks_core_git-12.2.0 → fluidattacks_core_git-12.2.1}/fluidattacks_core/git/warp.py +0 -0
  22. {fluidattacks_core_git-12.2.0 → fluidattacks_core_git-12.2.1}/import-linter.cfg +0 -0
  23. {fluidattacks_core_git-12.2.0 → fluidattacks_core_git-12.2.1}/mypy.ini +0 -0
  24. {fluidattacks_core_git-12.2.0 → fluidattacks_core_git-12.2.1}/ruff.toml +0 -0
  25. {fluidattacks_core_git-12.2.0 → fluidattacks_core_git-12.2.1}/tests/__init__.py +0 -0
  26. {fluidattacks_core_git-12.2.0 → fluidattacks_core_git-12.2.1}/tests/test_git.py +0 -0
  27. {fluidattacks_core_git-12.2.0 → fluidattacks_core_git-12.2.1}/tests/test_remote.py +0 -0
  28. {fluidattacks_core_git-12.2.0 → fluidattacks_core_git-12.2.1}/tests/test_upload_repo.py +0 -0
  29. {fluidattacks_core_git-12.2.0 → fluidattacks_core_git-12.2.1}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: fluidattacks_core_git
3
- Version: 12.2.0
3
+ Version: 12.2.1
4
4
  Summary: Fluid Attacks Core Git Library
5
5
  Author-email: Development <development@fluidattacks.com>
6
6
  License: MPL-2.0
@@ -40,6 +40,7 @@ def _replace_netloc_in_url(parsed_url: ParseResult, netloc: str) -> str:
40
40
 
41
41
 
42
42
  def _format_token_for_provider(provider: str | None, token: str, host: str) -> str:
43
+ token = quote(token, safe="")
43
44
  if provider == "BITBUCKET":
44
45
  return f"x-token-auth:{token}@{host}"
45
46
  if provider:
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "fluidattacks_core_git"
3
- version = "12.2.0"
3
+ version = "12.2.1"
4
4
  description = "Fluid Attacks Core Git Library"
5
5
  authors = [{ name = "Development", email = "development@fluidattacks.com" }]
6
6
  license = { text = "MPL-2.0" }
@@ -0,0 +1,64 @@
1
+ from urllib.parse import urlparse
2
+
3
+ import pytest
4
+
5
+ from fluidattacks_core.git.utils import format_url
6
+
7
+
8
+ @pytest.mark.parametrize(
9
+ "token",
10
+ [
11
+ "internal.svc.local:9200/#",
12
+ "a/b",
13
+ "a@b",
14
+ "a:b",
15
+ "a#b",
16
+ ],
17
+ )
18
+ def test_format_url_with_a_token_containing_url_metacharacters_keeps_the_host(
19
+ token: str,
20
+ ) -> None:
21
+ url = format_url(repo_url="https://github.com/fluidattacks/universe", token=token)
22
+
23
+ assert urlparse(url).hostname == "github.com"
24
+
25
+
26
+ def test_format_url_with_a_token_percent_encodes_it() -> None:
27
+ url = format_url(
28
+ repo_url="https://github.com/fluidattacks/universe",
29
+ token="internal.svc.local:9200/#", # noqa: S106
30
+ )
31
+
32
+ assert url == ("https://internal.svc.local%3A9200%2F%23@github.com/fluidattacks/universe")
33
+
34
+
35
+ def test_format_url_with_a_bitbucket_provider_token_keeps_the_host() -> None:
36
+ url = format_url(
37
+ repo_url="https://bitbucket.org/fluidattacks/universe",
38
+ token="a/token@with:chars", # noqa: S106
39
+ provider="BITBUCKET",
40
+ )
41
+
42
+ assert urlparse(url).hostname == "bitbucket.org"
43
+ assert url.startswith("https://x-token-auth:")
44
+
45
+
46
+ def test_format_url_with_an_oauth_provider_token_keeps_the_host() -> None:
47
+ url = format_url(
48
+ repo_url="https://gitlab.com/fluidattacks/universe",
49
+ token="a/token@with:chars", # noqa: S106
50
+ provider="GITLAB",
51
+ )
52
+
53
+ assert urlparse(url).hostname == "gitlab.com"
54
+ assert url.startswith("https://oauth2:")
55
+
56
+
57
+ def test_format_url_with_user_and_password_still_percent_encodes_them() -> None:
58
+ url = format_url(
59
+ repo_url="https://github.com/fluidattacks/universe",
60
+ user="a/user",
61
+ password="a:pass@word", # noqa: S106
62
+ )
63
+
64
+ assert urlparse(url).hostname == "github.com"