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

Credentials from origin appear in the Changelog #61

Closed
sandzhaj opened this issue Oct 10, 2023 · 1 comment
Closed

Credentials from origin appear in the Changelog #61

sandzhaj opened this issue Oct 10, 2023 · 1 comment

Comments

@sandzhaj
Copy link
Contributor

Describe the bug
If you use origin like "https://user:token@mygitlab.com" (it is a common case in ci, f.e. gitlab), you will get the same links in your Changelog.

Expected behavior
Credentials should't appear in the Changelog

in my fork i made that fix

providers.py

class ProviderRefParser(ABC):
    """A base class for specific providers reference parsers."""

    url: str
    namespace: str
    project: str
    REF: ClassVar[dict[str, RefDef]] = {}

    def __init__(self, namespace: str, project: str, url: str | None = None):
        """Initialization method.

        Arguments:
            namespace: The Bitbucket namespace.
            project: The Bitbucket project.
            url: The Bitbucket URL.
        """
        self.namespace: str = namespace
        self.project: str = project
-        self.url: str = url or self.url
+        self.url: str = self.clean_url(url or self.url)
...

+    @staticmethod
+    def clean_url(url: str) -> str:
+        """Clean the http URL from tokens.
+
+        Arguments:
+            url: The URL to clean.
+
+        Returns:
+            The cleaned URL.
+        """
+        if url.startswith(('http://', 'https://')):
+            protocol, remaining = url.split("://", 1)
+            parts = remaining.split("@")
+            if len(parts) > 1:
+                return f"{protocol}://{parts[-1]}"
+        return url
@pawamoy
Copy link
Owner

pawamoy commented Oct 10, 2023

Hello, thanks for the report. That is similar to #50.
Instead of parsing GitHub tokens like we do now, which works for GitHub only, we could indeed simply parse the URL to remove the credentials part 👍 Fixed in v2.3.1!

@pawamoy pawamoy closed this as completed Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants