Skip to content

Commit 91db7fc

Browse files
authored
Fix: Set version correctly for dotnet cpm directory packages (#2046)
* Update packages Signed-off-by: Prabhu Subramanian <[email protected]> * Bug fix. Version was undefined when using CPM with Directory.Packages.Props Signed-off-by: Prabhu Subramanian <[email protected]> --------- Signed-off-by: Prabhu Subramanian <[email protected]>
1 parent 225bb28 commit 91db7fc

File tree

7 files changed

+203
-199
lines changed

7 files changed

+203
-199
lines changed

bin/cdxgen.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ if (process.env.GLOBAL_AGENT_HTTP_PROXY || process.env.HTTP_PROXY) {
402402
process.env.GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE = "";
403403
}
404404
globalAgent.bootstrap();
405+
thoughtLog("Using the configured HTTP proxy. 🌐");
405406
}
406407

407408
const filePath = args._[0] || process.cwd();

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/2.0.6/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.1.1/schema.json",
33
"assist": {
44
"actions": {
55
"source": {

lib/cli/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3327,7 +3327,7 @@ export async function createNodejsBom(path, options) {
33273327
});
33283328
}
33293329
if (safeExistsSync(pnpmLock)) {
3330-
let pnpmLockObj = await parsePnpmLock(pnpmLock);
3330+
const pnpmLockObj = await parsePnpmLock(pnpmLock);
33313331
if (allImports && Object.keys(allImports).length) {
33323332
pkgList = await addEvidenceForImports(
33333333
pnpmLockObj.pkgList,
@@ -6609,11 +6609,11 @@ export async function createCsharpBom(path, options) {
66096609
}
66106610
}
66116611
}
6612+
const pkgNameVersions = {};
66126613
if (csProjFiles.length) {
66136614
manifestFiles = manifestFiles.concat(csProjFiles);
66146615
// Parsing csproj is quite error-prone. Some project files may not have versions specified
66156616
// To work around this, we make use of the version from the existing list
6616-
const pkgNameVersions = {};
66176617
for (const p of pkgList) {
66186618
if (p.version) {
66196619
pkgNameVersions[p.name] = p.version;

lib/helpers/utils.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,7 @@ export const cdxgenAgent = got.extend({
692692
retry: {
693693
limit: 0,
694694
},
695+
followRedirect: !isSecureMode,
695696
hooks: {
696697
beforeRequest: [
697698
(options) => {
@@ -9822,7 +9823,7 @@ export function parseCsProjData(csProjData, projFile, pkgNameVersions = {}) {
98229823
continue;
98239824
}
98249825
pkg.name = pref.Include;
9825-
pkg.version = pref.Version;
9826+
pkg.version = pref.Version || pkgNameVersions[pkg.name];
98269827
pkg.purl = `pkg:nuget/${pkg.name}@${pkg.version}`;
98279828
pkg["bom-ref"] = pkg.purl;
98289829
if (projFile) {
@@ -9859,9 +9860,11 @@ export function parseCsProjData(csProjData, projFile, pkgNameVersions = {}) {
98599860
pkg.name = incParts[0];
98609861
pkg.properties = [];
98619862
if (incParts.length > 1 && incParts[1].includes("Version")) {
9862-
pkg.version = incParts[1].replace("Version=", "").trim();
9863+
pkg.version =
9864+
incParts[1].replace("Version=", "").trim() ||
9865+
pkgNameVersions[pkg.name];
98639866
}
9864-
const version = pkg.version || pkgNameVersions[pkg.name];
9867+
const version = pkg.version;
98659868
if (version) {
98669869
pkg.purl = `pkg:nuget/${pkg.name}@${version}`;
98679870
} else {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
"bugs": {
7676
"url": "https://github.com/cyclonedx/cdxgen/issues"
7777
},
78-
"packageManager": "pnpm@10.12.4",
78+
"packageManager": "pnpm@10.13.1",
7979
"lint-staged": {
8080
"*": "biome check --fix --no-errors-on-unmatched"
8181
},
@@ -139,7 +139,7 @@
139139
"index.cjs"
140140
],
141141
"devDependencies": {
142-
"@biomejs/biome": "2.0.6",
142+
"@biomejs/biome": "2.1.1",
143143
"jest": "^30.0.4",
144144
"typescript": "^5.8.3"
145145
},

0 commit comments

Comments
 (0)