[llvm] Avoid exposing password and token from git repositories (PR #105220)
Tulio Magno Quites Machado Filho via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 10 06:26:01 PDT 2024
================
@@ -39,6 +39,30 @@ function(get_source_info path revision repository)
OUTPUT_VARIABLE git_output
ERROR_QUIET)
if(git_result EQUAL 0)
+ # Passwords or tokens should not be stored in the remote URL at the
+ # risk of being leaked. In case we find one, error out and teach the
+ # user the best practices.
+ string(REGEX MATCH "https?://[^/]*:[^/]*@.*"
+ http_password "${git_output}")
+ if(http_password)
+ message(SEND_ERROR "The git remote repository URL has an embedded \
+password. Remove the password from the URL or use \
+`-DLLVM_FORCE_VC_REPOSITORY=<URL without password>` in order to avoid \
+leaking your password (see https://git-scm.com/docs/gitcredentials for \
+alternatives).")
+ endif()
+ # Github token formats are described at:
+ # https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/about-authentication-to-github#githubs-token-formats
+ string(REGEX MATCH
+ "https?://(gh[pousr]|github_pat)_[^/]+ at github.com.*"
+ github_token "${git_output}")
+ if(github_token)
+ message(SEND_ERROR "The git remote repository URL has an embedded \
+Github Token. Remove the token from the URL or use \
----------------
tuliom wrote:
Good point! I changed this in my last commit as well as a source code comment a few lines above.
Thanks!
https://github.com/llvm/llvm-project/pull/105220
More information about the llvm-commits
mailing list