Skip to content

Commit 967d4c9

Browse files
committed
fix(spdxdocumentfile): Get VcsInfo from downloadLocation by default
If downloadLocation is set to vcs sources, it should always be in use first, as in many cases spdx files are being scanned from dedicated repositories that don't contain sources of declared components or project that is being scanned with spdx manager. Getting vcs source information from project dir will be neccessary in specific cases, where some internally developed dependencies are in use during scan. Signed-off-by: Mateusz Los <extern.mateusz.los@cariad.technology>
1 parent 32c060e commit 967d4c9

3 files changed

Lines changed: 27 additions & 27 deletions

File tree

plugins/package-managers/spdx-document-file/src/funTest/assets/projects/synthetic/spdx-project-cyclic-expected-output.yml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ packages:
5656
algorithm: ""
5757
vcs:
5858
type: "Git"
59-
url: "<REPLACE_VCS_URL>"
60-
revision: "<REPLACE_VCS_REVISION>"
61-
path: "plugins/package-managers/spdx-document-file/src/funTest/assets/projects/synthetic/cyclic-references"
59+
url: "ssh://gitlab.example.com:3389/products/abc.git"
60+
revision: "b2c358080011af6a366d2512a25a379fbe7b1f78"
61+
path: ""
6262
vcs_processed:
6363
type: "Git"
64-
url: "<REPLACE_VCS_PROCESSED_URL>"
65-
revision: "<REPLACE_VCS_REVISION>"
66-
path: "plugins/package-managers/spdx-document-file/src/funTest/assets/projects/synthetic/cyclic-references"
64+
url: "ssh://gitlab.example.com:3389/products/abc.git"
65+
revision: "b2c358080011af6a366d2512a25a379fbe7b1f78"
66+
path: ""
6767
- id: "SpdxDocumentFile::curl:7.70.0"
6868
purl: "pkg:generic/curl@7.70.0?download_url=https%3A%2F%2Fgithub.com%2Fcurl%2Fcurl%2Freleases%2Fdownload%2Fcurl-7_70_0%2Fcurl-7.70.0.tar.gz"
6969
cpe: "cpe:2.3:a:http:curl:7.70.0:*:*:*:*:*:*:*"
@@ -120,14 +120,14 @@ packages:
120120
algorithm: ""
121121
vcs:
122122
type: "Git"
123-
url: "<REPLACE_VCS_URL>"
124-
revision: "<REPLACE_VCS_REVISION>"
125-
path: "plugins/package-managers/spdx-document-file/src/funTest/assets/projects/synthetic/cyclic-references"
123+
url: "ssh://gitlab.example.com:3389/products/def.git"
124+
revision: "b2c358080011af6a366d2512a25a379fbe7b1f78"
125+
path: ""
126126
vcs_processed:
127127
type: "Git"
128-
url: "<REPLACE_VCS_PROCESSED_URL>"
129-
revision: "<REPLACE_VCS_REVISION>"
130-
path: "plugins/package-managers/spdx-document-file/src/funTest/assets/projects/synthetic/cyclic-references"
128+
url: "ssh://gitlab.example.com:3389/products/def.git"
129+
revision: "b2c358080011af6a366d2512a25a379fbe7b1f78"
130+
path: ""
131131
- id: "SpdxDocumentFile::zlib:1.2.11"
132132
purl: "pkg:generic/zlib@1.2.11?download_url=http%3A%2F%2Fzlib.net%2Fzlib-1.2.11.tar.gz"
133133
cpe: "cpe:/a:compress:zlib:1.2.11:::en-us"
@@ -186,11 +186,11 @@ packages:
186186
algorithm: ""
187187
vcs:
188188
type: "Git"
189-
url: "<REPLACE_VCS_URL>"
190-
revision: "<REPLACE_VCS_REVISION>"
191-
path: "plugins/package-managers/spdx-document-file/src/funTest/assets/projects/synthetic/libs/openssl"
189+
url: "ssh://github.com/openssl/openssl.git"
190+
revision: "e2e09d9fba1187f8d6aafaa34d4172f56f1ffb72"
191+
path: ""
192192
vcs_processed:
193193
type: "Git"
194-
url: "<REPLACE_VCS_PROCESSED_URL>"
195-
revision: "<REPLACE_VCS_REVISION>"
196-
path: "plugins/package-managers/spdx-document-file/src/funTest/assets/projects/synthetic/libs/openssl"
194+
url: "ssh://git@github.com/openssl/openssl.git"
195+
revision: "e2e09d9fba1187f8d6aafaa34d4172f56f1ffb72"
196+
path: ""

plugins/package-managers/spdx-document-file/src/funTest/assets/projects/synthetic/spdx-project-xyz-expected-output.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,11 @@ packages:
121121
algorithm: ""
122122
vcs:
123123
type: "Git"
124-
url: "<REPLACE_VCS_URL>"
125-
revision: "<REPLACE_VCS_REVISION>"
126-
path: "plugins/package-managers/spdx-document-file/src/funTest/assets/projects/synthetic/libs/openssl"
124+
url: "ssh://github.com/openssl/openssl.git"
125+
revision: "e2e09d9fba1187f8d6aafaa34d4172f56f1ffb72"
126+
path: ""
127127
vcs_processed:
128128
type: "Git"
129-
url: "<REPLACE_VCS_PROCESSED_URL>"
130-
revision: "<REPLACE_VCS_REVISION>"
131-
path: "plugins/package-managers/spdx-document-file/src/funTest/assets/projects/synthetic/libs/openssl"
129+
url: "ssh://git@github.com/openssl/openssl.git"
130+
revision: "e2e09d9fba1187f8d6aafaa34d4172f56f1ffb72"
131+
path: ""

plugins/package-managers/spdx-document-file/src/main/kotlin/utils/SpdxExtensions.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,10 @@ internal fun SpdxPackage.toPackage(
166166
): Package {
167167
val packageDescription = description.ifEmpty { summary }
168168

169-
// If the VCS information cannot be determined from the VCS working tree itself, fall back to try getting it
170-
// from the download location.
169+
// The VCS information should be taken from defined download location, if not provided,
170+
// get the VCS information from the working tree instead
171171
val packageDir = definitionFile?.resolveSibling(packageFilename)
172-
val vcs = packageDir?.let { VersionControlSystem.forDirectory(it)?.getInfo() } ?: getVcsInfo().orEmpty()
172+
val vcs = getVcsInfo() ?: packageDir?.let { VersionControlSystem.forDirectory(it)?.getInfo() }.orEmpty()
173173

174174
val generatedFromRelations = doc.relationships.filter {
175175
it.relationshipType == SpdxRelationship.Type.GENERATED_FROM

0 commit comments

Comments
 (0)