git-r3.eclass: Explicitly warn about unsecure protocols
authorMichał Górny <mgorny@gentoo.org>
Sat, 19 Aug 2017 08:23:47 +0000 (10:23 +0200)
committerMichał Górny <mgorny@gentoo.org>
Fri, 25 Aug 2017 13:51:54 +0000 (15:51 +0200)
Explicitly warn about any URI that uses an unsecure protocol (git, http)
even if it's a fallback URI. This is necessary because an attacker may
block HTTPS connections, effectively forcing the fallback to
the unsecure protocol.

eclass/git-r3.eclass

index a0aa004caa259ad3396e7feae82cd903de3204ee..ee6050c3cdd25750ec5f4e69b2edc1c07fa5406d 100644 (file)
@@ -570,6 +570,16 @@ git-r3_fetch() {
 
        [[ ${repos[@]} ]] || die "No URI provided and EGIT_REPO_URI unset"
 
+       local r
+       for r in "${repos[@]}"; do
+               if [[ ${r} == git:* || ${r} == http:* ]]; then
+                       ewarn "git-r3: ${r%%:*} protocol is completely unsecure and may render the ebuild"
+                       ewarn "easily suspectible to MITM attacks (even if used only as fallback). Please"
+                       ewarn "use https instead."
+                       ewarn "[URI: ${r}]"
+               fi
+       done
+
        local -x GIT_DIR
        _git-r3_set_gitdir "${repos[0]}"
 
@@ -582,7 +592,7 @@ git-r3_fetch() {
        fi
 
        # try to fetch from the remote
-       local success saved_umask
+       local success saved_umask
        if [[ ${EVCS_UMASK} ]]; then
                saved_umask=$(umask)
                umask "${EVCS_UMASK}" || die "Bad options to umask: ${EVCS_UMASK}"