Skip to content

Commit 9608c38

Browse files
oheger-boschsschuberth
authored andcommitted
fix(fossid): Use the URL with credentials when cloning the repo
This is a fixup for af95c97, which removed the credentials from the repository URL before adding it to the scan comment. Since the `CloneRepositoryHandler` used to take the URL from the comment, it does not have the credentials to clone the repository anymore. To fix this, extend the `EventHandler` interface, so that the original URL with credentials can be explicitly passed and used for the cloning. Signed-off-by: Oliver Heger <oliver.heger@bosch.com>
1 parent 46dfc5d commit 9608c38

4 files changed

Lines changed: 8 additions & 4 deletions

File tree

plugins/scanners/fossid/src/main/kotlin/FossId.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ class FossId internal constructor(
668668

669669
val urlWithoutCredentials = url.replaceCredentialsInUri()
670670
val comment = createOrtScanComment(urlWithoutCredentials, revision, reference)
671-
val response = handler.createScan(projectCode, scanCode, comment)
671+
val response = handler.createScan(url, projectCode, scanCode, comment)
672672

673673
val data = response.data?.value
674674

plugins/scanners/fossid/src/main/kotlin/events/CloneRepositoryHandler.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class CloneRepositoryHandler(val config: FossIdConfig, val service: FossIdServic
6767
override fun transformURL(url: String): String = urlProvider.getUrl(url)
6868

6969
override suspend fun createScan(
70+
repositoryUrl: String,
7071
projectCode: String,
7172
scanCode: String,
7273
comment: OrtScanComment
@@ -77,7 +78,7 @@ class CloneRepositoryHandler(val config: FossIdConfig, val service: FossIdServic
7778
config.apiKey.value,
7879
projectCode,
7980
scanCode,
80-
comment.ort.repositoryURL,
81+
repositoryUrl,
8182
comment.ort.revision,
8283
comment.asJsonString()
8384
)

plugins/scanners/fossid/src/main/kotlin/events/EventHandler.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,12 @@ interface EventHandler {
101101
fun transformURL(url: String): String = url
102102

103103
/**
104-
* Create a scan in FossID with the given [projectCode], [scanCode], and url, revision and reference contained in
105-
* the [comment]. Return the response from FossID or null if the scan could not be created.
104+
* Create a scan in FossID with the given [repositoryUrl], [projectCode], [scanCode], and revision and reference
105+
* contained in the [comment]. Return the response from FossID or null if the scan could not be created. Note that
106+
* the [repositoryUrl] may contain the credentials for cloning the repository.
106107
*/
107108
suspend fun createScan(
109+
repositoryUrl: String,
108110
projectCode: String,
109111
scanCode: String,
110112
comment: OrtScanComment

plugins/scanners/fossid/src/main/kotlin/events/UploadArchiveHandler.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class UploadArchiveHandler(
5959
val provenance: NestedProvenance
6060
) : EventHandler {
6161
override suspend fun createScan(
62+
repositoryUrl: String,
6263
projectCode: String,
6364
scanCode: String,
6465
comment: OrtScanComment

0 commit comments

Comments
 (0)