Skip to content

Commit 508c9a5

Browse files
authored
[ANE-1861] strip auth from git projects cloned via url (#1451)
* strip auth from https urls for git projects * use stripAuthFromURL * update changelog * include in 3.9.26 * fossa test * typo
1 parent 09a72b0 commit 508c9a5

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## 3.9.26
44

55
- Reports: Add `includeCopyrightList` to JSON attribution report request. This will ensure that all copyrights are included in the JSON attribution report once the FOSSA API starts including them. All other formats of attribution reports will receive all copyrights without needing to add this query param. [#1450](https://github.com/fossas/fossa-cli/pull/1450)
6+
- Resolves an issue where git projects cloned with an url including a username were unable to be found when running `fossa test`. [#1451](https://github.com/fossas/fossa-cli/pull/1451)
67

78
## 3.9.25
89

src/App/Fossa/ProjectInference.hs

+11-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import Data.Time.Format.ISO8601 (iso8601Show)
3636
import Effect.Exec
3737
import Effect.ReadFS
3838
import Errata (Errata (..))
39+
import Network.URI (URI (..), URIAuth (..), isURI, parseURI, uriToString)
3940
import Path
4041
import Path.IO (getTempDir)
4142
import System.FilePath.Posix qualified as FP
@@ -203,13 +204,22 @@ parseGitProjectName dir = do
203204
Nothing -> fatal InvalidRemote
204205
Just (Section _ properties) ->
205206
case HM.lookup "url" properties of
206-
Just url -> pure url
207+
Just url ->
208+
pure $
209+
if isURI (toString url) then stripAuthFromURL url else url
207210
Nothing -> fatal InvalidRemote
208211
where
209212
isOrigin :: Section -> Bool
210213
isOrigin (Section ["remote", "origin"] _) = True
211214
isOrigin _ = False
212215

216+
stripAuthFromURL :: Text -> Text
217+
stripAuthFromURL url = case parseURI (toString url) of
218+
Just uri -> case uriAuthority uri of
219+
Just auth -> toText $ uriToString id uri{uriAuthority = Just auth{uriUserInfo = ""}} ""
220+
Nothing -> url
221+
Nothing -> url
222+
213223
parseGitProjectRevision ::
214224
( Has ReadFS sig m
215225
, Has Diagnostics sig m

0 commit comments

Comments
 (0)