@cyclonedx/cdxgen 11.0.7 → 11.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import { Buffer } from "node:buffer";
2
2
  import { readFileSync } from "node:fs";
3
3
  import path from "node:path";
4
- import { expect, test } from "@jest/globals";
4
+ import { afterAll, beforeAll, describe, expect, test } from "@jest/globals";
5
5
  import { parse } from "ssri";
6
6
  import {
7
7
  buildObjectForGradleModule,
@@ -80,7 +80,7 @@ import {
80
80
  parsePrivadoFile,
81
81
  parsePubLockData,
82
82
  parsePubYamlData,
83
- parsePyProjectToml,
83
+ parsePyProjectTomlFile,
84
84
  parsePyRequiresDist,
85
85
  parseReqFile,
86
86
  parseSbtLock,
@@ -1053,6 +1053,8 @@ test("parseGoSumData", async () => {
1053
1053
  license: undefined,
1054
1054
  version: "v1.21.0",
1055
1055
  _integrity: "sha256-oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=",
1056
+ "bom-ref": "pkg:golang/google.golang.org/grpc@v1.21.0",
1057
+ purl: "pkg:golang/google.golang.org/grpc@v1.21.0",
1056
1058
  });
1057
1059
  expect(dep_list[1]).toEqual({
1058
1060
  group: "",
@@ -1060,6 +1062,8 @@ test("parseGoSumData", async () => {
1060
1062
  license: undefined,
1061
1063
  version: "v1.0.0",
1062
1064
  _integrity: "sha256-/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=",
1065
+ "bom-ref": "pkg:golang/github.com/spf13/cobra@v1.0.0",
1066
+ purl: "pkg:golang/github.com/spf13/cobra@v1.0.0",
1063
1067
  });
1064
1068
  expect(dep_list[2]).toEqual({
1065
1069
  group: "",
@@ -1067,6 +1071,8 @@ test("parseGoSumData", async () => {
1067
1071
  license: undefined,
1068
1072
  version: "v1.0.2",
1069
1073
  _integrity: "sha256-A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM=",
1074
+ "bom-ref": "pkg:golang/github.com/spf13/viper@v1.0.2",
1075
+ purl: "pkg:golang/github.com/spf13/viper@v1.0.2",
1070
1076
  });
1071
1077
  expect(dep_list[3]).toEqual({
1072
1078
  group: "",
@@ -1074,12 +1080,436 @@ test("parseGoSumData", async () => {
1074
1080
  license: undefined,
1075
1081
  version: "v1.6.1",
1076
1082
  _integrity: "sha256-6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=",
1083
+ "bom-ref": "pkg:golang/github.com/stretchr/testify@v1.6.1",
1084
+ purl: "pkg:golang/github.com/stretchr/testify@v1.6.1",
1077
1085
  });
1078
1086
  dep_list.forEach((d) => {
1079
1087
  expect(d.license);
1080
1088
  });
1081
1089
  }, 120000);
1082
1090
 
1091
+ describe("go data with vcs", () => {
1092
+ beforeAll(() => {
1093
+ process.env.GO_FETCH_VCS = "true";
1094
+ });
1095
+ afterAll(() => {
1096
+ delete process.env.GO_FETCH_VCS;
1097
+ });
1098
+ test("parseGoSumData with vcs", async () => {
1099
+ let dep_list = await parseGosumData(null);
1100
+ expect(dep_list).toEqual([]);
1101
+ dep_list = await parseGosumData(
1102
+ readFileSync("./test/gomod/go.sum", { encoding: "utf-8" }),
1103
+ );
1104
+ expect(dep_list.length).toEqual(4);
1105
+ expect(dep_list[0]).toEqual({
1106
+ group: "",
1107
+ name: "google.golang.org/grpc",
1108
+ license: undefined,
1109
+ version: "v1.21.0",
1110
+ _integrity: "sha256-oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=",
1111
+ "bom-ref": "pkg:golang/google.golang.org/grpc@v1.21.0",
1112
+ purl: "pkg:golang/google.golang.org/grpc@v1.21.0",
1113
+ externalReferences: [
1114
+ {
1115
+ type: "vcs",
1116
+ url: "https://github.com/grpc/grpc-go",
1117
+ },
1118
+ ],
1119
+ });
1120
+ expect(dep_list[1]).toEqual({
1121
+ group: "",
1122
+ name: "github.com/spf13/cobra",
1123
+ license: undefined,
1124
+ version: "v1.0.0",
1125
+ _integrity: "sha256-/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=",
1126
+ "bom-ref": "pkg:golang/github.com/spf13/cobra@v1.0.0",
1127
+ purl: "pkg:golang/github.com/spf13/cobra@v1.0.0",
1128
+ externalReferences: [
1129
+ {
1130
+ type: "vcs",
1131
+ url: "https://github.com/spf13/cobra",
1132
+ },
1133
+ ],
1134
+ });
1135
+ expect(dep_list[2]).toEqual({
1136
+ group: "",
1137
+ name: "github.com/spf13/viper",
1138
+ license: undefined,
1139
+ version: "v1.0.2",
1140
+ _integrity: "sha256-A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM=",
1141
+ "bom-ref": "pkg:golang/github.com/spf13/viper@v1.0.2",
1142
+ purl: "pkg:golang/github.com/spf13/viper@v1.0.2",
1143
+ externalReferences: [
1144
+ {
1145
+ type: "vcs",
1146
+ url: "https://github.com/spf13/viper",
1147
+ },
1148
+ ],
1149
+ });
1150
+ expect(dep_list[3]).toEqual({
1151
+ group: "",
1152
+ name: "github.com/stretchr/testify",
1153
+ license: undefined,
1154
+ version: "v1.6.1",
1155
+ _integrity: "sha256-6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=",
1156
+ "bom-ref": "pkg:golang/github.com/stretchr/testify@v1.6.1",
1157
+ purl: "pkg:golang/github.com/stretchr/testify@v1.6.1",
1158
+ externalReferences: [
1159
+ {
1160
+ type: "vcs",
1161
+ url: "https://github.com/stretchr/testify",
1162
+ },
1163
+ ],
1164
+ });
1165
+ dep_list.forEach((d) => {
1166
+ expect(d.license);
1167
+ });
1168
+ }, 120000);
1169
+
1170
+ test("parseGoModData", async () => {
1171
+ let retMap = await parseGoModData(null);
1172
+ expect(retMap).toEqual({});
1173
+ const gosumMap = {
1174
+ "google.golang.org/grpc@v1.21.0":
1175
+ "sha256-oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=",
1176
+ "github.com/aws/aws-sdk-go@v1.38.47": "sha256-fake-sha-for-aws-go-sdk=",
1177
+ "github.com/spf13/cobra@v1.0.0":
1178
+ "sha256-/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=",
1179
+ "github.com/spf13/viper@v1.3.0":
1180
+ "sha256-A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM=",
1181
+ "github.com/stretchr/testify@v1.6.1":
1182
+ "sha256-6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=",
1183
+ };
1184
+ retMap = await parseGoModData(
1185
+ readFileSync("./test/gomod/go.mod", { encoding: "utf-8" }),
1186
+ gosumMap,
1187
+ );
1188
+ expect(retMap.pkgList.length).toEqual(6);
1189
+ expect(retMap.pkgList).toEqual([
1190
+ {
1191
+ group: "",
1192
+ name: "github.com/aws/aws-sdk-go",
1193
+ version: "v1.38.47",
1194
+ _integrity: "sha256-fake-sha-for-aws-go-sdk=",
1195
+ purl: "pkg:golang/github.com/aws/aws-sdk-go@v1.38.47",
1196
+ "bom-ref": "pkg:golang/github.com/aws/aws-sdk-go@v1.38.47",
1197
+ externalReferences: [
1198
+ {
1199
+ type: "vcs",
1200
+ url: "https://github.com/aws/aws-sdk-go",
1201
+ },
1202
+ ],
1203
+ },
1204
+ {
1205
+ group: "",
1206
+ name: "github.com/spf13/cobra",
1207
+ version: "v1.0.0",
1208
+ _integrity: "sha256-/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=",
1209
+ purl: "pkg:golang/github.com/spf13/cobra@v1.0.0",
1210
+ "bom-ref": "pkg:golang/github.com/spf13/cobra@v1.0.0",
1211
+ externalReferences: [
1212
+ {
1213
+ type: "vcs",
1214
+ url: "https://github.com/spf13/cobra",
1215
+ },
1216
+ ],
1217
+ },
1218
+ {
1219
+ group: "",
1220
+ name: "github.com/spf13/viper",
1221
+ version: "v1.0.2",
1222
+ purl: "pkg:golang/github.com/spf13/viper@v1.0.2",
1223
+ "bom-ref": "pkg:golang/github.com/spf13/viper@v1.0.2",
1224
+ externalReferences: [
1225
+ {
1226
+ type: "vcs",
1227
+ url: "https://github.com/spf13/viper",
1228
+ },
1229
+ ],
1230
+ },
1231
+ {
1232
+ group: "",
1233
+ name: "github.com/spf13/viper",
1234
+ version: "v1.3.0",
1235
+ _integrity: "sha256-A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM=",
1236
+ purl: "pkg:golang/github.com/spf13/viper@v1.3.0",
1237
+ "bom-ref": "pkg:golang/github.com/spf13/viper@v1.3.0",
1238
+ externalReferences: [
1239
+ {
1240
+ type: "vcs",
1241
+ url: "https://github.com/spf13/viper",
1242
+ },
1243
+ ],
1244
+ },
1245
+ {
1246
+ group: "",
1247
+ name: "google.golang.org/grpc",
1248
+ version: "v1.21.0",
1249
+ _integrity: "sha256-oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=",
1250
+ purl: "pkg:golang/google.golang.org/grpc@v1.21.0",
1251
+ "bom-ref": "pkg:golang/google.golang.org/grpc@v1.21.0",
1252
+ externalReferences: [
1253
+ {
1254
+ type: "vcs",
1255
+ url: "https://github.com/grpc/grpc-go",
1256
+ },
1257
+ ],
1258
+ },
1259
+ {
1260
+ group: "",
1261
+ name: "google.golang.org/grpc",
1262
+ version: "v1.32.0",
1263
+ purl: "pkg:golang/google.golang.org/grpc@v1.32.0",
1264
+ "bom-ref": "pkg:golang/google.golang.org/grpc@v1.32.0",
1265
+ externalReferences: [
1266
+ {
1267
+ type: "vcs",
1268
+ url: "https://github.com/grpc/grpc-go",
1269
+ },
1270
+ ],
1271
+ },
1272
+ ]);
1273
+
1274
+ retMap.pkgList.forEach((d) => {
1275
+ expect(d.license);
1276
+ });
1277
+ retMap = await parseGoModData(
1278
+ readFileSync("./test/data/go-dvwa.mod", { encoding: "utf-8" }),
1279
+ {},
1280
+ );
1281
+ expect(retMap.parentComponent).toEqual({
1282
+ "bom-ref": "pkg:golang/github.com/sqreen/go-dvwa",
1283
+ name: "github.com/sqreen/go-dvwa",
1284
+ purl: "pkg:golang/github.com/sqreen/go-dvwa",
1285
+ type: "application",
1286
+ });
1287
+ expect(retMap.pkgList.length).toEqual(19);
1288
+ expect(retMap.rootList.length).toEqual(4);
1289
+ retMap = await parseGoModData(
1290
+ readFileSync("./test/data/go-syft.mod", { encoding: "utf-8" }),
1291
+ {},
1292
+ );
1293
+ expect(retMap.parentComponent).toEqual({
1294
+ "bom-ref": "pkg:golang/github.com/anchore/syft",
1295
+ name: "github.com/anchore/syft",
1296
+ purl: "pkg:golang/github.com/anchore/syft",
1297
+ type: "application",
1298
+ });
1299
+ expect(retMap.pkgList.length).toEqual(239);
1300
+ expect(retMap.rootList.length).toEqual(84);
1301
+ }, 120000);
1302
+ });
1303
+
1304
+ describe("go data with licenses", () => {
1305
+ beforeAll(() => {
1306
+ process.env.FETCH_LICENSE = "true";
1307
+ });
1308
+ afterAll(() => {
1309
+ delete process.env.FETCH_LICENSE;
1310
+ });
1311
+ test("parseGoSumData with licenses", async () => {
1312
+ let dep_list = await parseGosumData(null);
1313
+ expect(dep_list).toEqual([]);
1314
+ dep_list = await parseGosumData(
1315
+ readFileSync("./test/gomod/go.sum", { encoding: "utf-8" }),
1316
+ );
1317
+ expect(dep_list.length).toEqual(4);
1318
+ expect(dep_list[0]).toEqual({
1319
+ group: "",
1320
+ name: "google.golang.org/grpc",
1321
+ version: "v1.21.0",
1322
+ _integrity: "sha256-oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=",
1323
+ "bom-ref": "pkg:golang/google.golang.org/grpc@v1.21.0",
1324
+ purl: "pkg:golang/google.golang.org/grpc@v1.21.0",
1325
+ license: [
1326
+ {
1327
+ id: "Apache-2.0",
1328
+ url: "https://pkg.go.dev/google.golang.org/grpc?tab=licenses",
1329
+ },
1330
+ ],
1331
+ });
1332
+ expect(dep_list[1]).toEqual({
1333
+ group: "",
1334
+ name: "github.com/spf13/cobra",
1335
+ version: "v1.0.0",
1336
+ _integrity: "sha256-/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=",
1337
+ "bom-ref": "pkg:golang/github.com/spf13/cobra@v1.0.0",
1338
+ purl: "pkg:golang/github.com/spf13/cobra@v1.0.0",
1339
+ license: [
1340
+ {
1341
+ id: "Apache-2.0",
1342
+ url: "https://pkg.go.dev/github.com/spf13/cobra?tab=licenses",
1343
+ },
1344
+ ],
1345
+ });
1346
+ expect(dep_list[2]).toEqual({
1347
+ group: "",
1348
+ name: "github.com/spf13/viper",
1349
+ version: "v1.0.2",
1350
+ _integrity: "sha256-A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM=",
1351
+ "bom-ref": "pkg:golang/github.com/spf13/viper@v1.0.2",
1352
+ purl: "pkg:golang/github.com/spf13/viper@v1.0.2",
1353
+ license: [
1354
+ {
1355
+ id: "MIT",
1356
+ url: "https://pkg.go.dev/github.com/spf13/viper?tab=licenses",
1357
+ },
1358
+ ],
1359
+ });
1360
+ expect(dep_list[3]).toEqual({
1361
+ group: "",
1362
+ name: "github.com/stretchr/testify",
1363
+ version: "v1.6.1",
1364
+ _integrity: "sha256-6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=",
1365
+ "bom-ref": "pkg:golang/github.com/stretchr/testify@v1.6.1",
1366
+ purl: "pkg:golang/github.com/stretchr/testify@v1.6.1",
1367
+ license: [
1368
+ {
1369
+ id: "MIT",
1370
+ url: "https://pkg.go.dev/github.com/stretchr/testify?tab=licenses",
1371
+ },
1372
+ ],
1373
+ });
1374
+ dep_list.forEach((d) => {
1375
+ expect(d.license);
1376
+ });
1377
+ }, 120000);
1378
+
1379
+ test("parseGoModData with licenses", async () => {
1380
+ let retMap = await parseGoModData(null);
1381
+ expect(retMap).toEqual({});
1382
+ const gosumMap = {
1383
+ "google.golang.org/grpc@v1.21.0":
1384
+ "sha256-oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=",
1385
+ "github.com/aws/aws-sdk-go@v1.38.47": "sha256-fake-sha-for-aws-go-sdk=",
1386
+ "github.com/spf13/cobra@v1.0.0":
1387
+ "sha256-/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=",
1388
+ "github.com/spf13/viper@v1.3.0":
1389
+ "sha256-A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM=",
1390
+ "github.com/stretchr/testify@v1.6.1":
1391
+ "sha256-6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=",
1392
+ };
1393
+ retMap = await parseGoModData(
1394
+ readFileSync("./test/gomod/go.mod", { encoding: "utf-8" }),
1395
+ gosumMap,
1396
+ );
1397
+ expect(retMap.pkgList.length).toEqual(6);
1398
+ expect(retMap.pkgList).toEqual([
1399
+ {
1400
+ group: "",
1401
+ name: "github.com/aws/aws-sdk-go",
1402
+ version: "v1.38.47",
1403
+ _integrity: "sha256-fake-sha-for-aws-go-sdk=",
1404
+ purl: "pkg:golang/github.com/aws/aws-sdk-go@v1.38.47",
1405
+ "bom-ref": "pkg:golang/github.com/aws/aws-sdk-go@v1.38.47",
1406
+ license: [
1407
+ {
1408
+ id: "Apache-2.0",
1409
+ url: "https://pkg.go.dev/github.com/aws/aws-sdk-go?tab=licenses",
1410
+ },
1411
+ ],
1412
+ },
1413
+ {
1414
+ group: "",
1415
+ name: "github.com/spf13/cobra",
1416
+ version: "v1.0.0",
1417
+ _integrity: "sha256-/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=",
1418
+ purl: "pkg:golang/github.com/spf13/cobra@v1.0.0",
1419
+ "bom-ref": "pkg:golang/github.com/spf13/cobra@v1.0.0",
1420
+ license: [
1421
+ {
1422
+ id: "Apache-2.0",
1423
+ url: "https://pkg.go.dev/github.com/spf13/cobra?tab=licenses",
1424
+ },
1425
+ ],
1426
+ },
1427
+ {
1428
+ group: "",
1429
+ name: "github.com/spf13/viper",
1430
+ version: "v1.0.2",
1431
+ purl: "pkg:golang/github.com/spf13/viper@v1.0.2",
1432
+ "bom-ref": "pkg:golang/github.com/spf13/viper@v1.0.2",
1433
+ license: [
1434
+ {
1435
+ id: "MIT",
1436
+ url: "https://pkg.go.dev/github.com/spf13/viper?tab=licenses",
1437
+ },
1438
+ ],
1439
+ },
1440
+ {
1441
+ group: "",
1442
+ name: "github.com/spf13/viper",
1443
+ version: "v1.3.0",
1444
+ _integrity: "sha256-A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM=",
1445
+ purl: "pkg:golang/github.com/spf13/viper@v1.3.0",
1446
+ "bom-ref": "pkg:golang/github.com/spf13/viper@v1.3.0",
1447
+ license: [
1448
+ {
1449
+ id: "MIT",
1450
+ url: "https://pkg.go.dev/github.com/spf13/viper?tab=licenses",
1451
+ },
1452
+ ],
1453
+ },
1454
+ {
1455
+ group: "",
1456
+ name: "google.golang.org/grpc",
1457
+ version: "v1.21.0",
1458
+ _integrity: "sha256-oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=",
1459
+ purl: "pkg:golang/google.golang.org/grpc@v1.21.0",
1460
+ "bom-ref": "pkg:golang/google.golang.org/grpc@v1.21.0",
1461
+ license: [
1462
+ {
1463
+ id: "Apache-2.0",
1464
+ url: "https://pkg.go.dev/google.golang.org/grpc?tab=licenses",
1465
+ },
1466
+ ],
1467
+ },
1468
+ {
1469
+ group: "",
1470
+ name: "google.golang.org/grpc",
1471
+ version: "v1.32.0",
1472
+ purl: "pkg:golang/google.golang.org/grpc@v1.32.0",
1473
+ "bom-ref": "pkg:golang/google.golang.org/grpc@v1.32.0",
1474
+ license: [
1475
+ {
1476
+ id: "Apache-2.0",
1477
+ url: "https://pkg.go.dev/google.golang.org/grpc?tab=licenses",
1478
+ },
1479
+ ],
1480
+ },
1481
+ ]);
1482
+
1483
+ retMap.pkgList.forEach((d) => {
1484
+ expect(d.license);
1485
+ });
1486
+ retMap = await parseGoModData(
1487
+ readFileSync("./test/data/go-dvwa.mod", { encoding: "utf-8" }),
1488
+ {},
1489
+ );
1490
+ expect(retMap.parentComponent).toEqual({
1491
+ "bom-ref": "pkg:golang/github.com/sqreen/go-dvwa",
1492
+ name: "github.com/sqreen/go-dvwa",
1493
+ purl: "pkg:golang/github.com/sqreen/go-dvwa",
1494
+ type: "application",
1495
+ });
1496
+ expect(retMap.pkgList.length).toEqual(19);
1497
+ expect(retMap.rootList.length).toEqual(4);
1498
+ retMap = await parseGoModData(
1499
+ readFileSync("./test/data/go-syft.mod", { encoding: "utf-8" }),
1500
+ {},
1501
+ );
1502
+ expect(retMap.parentComponent).toEqual({
1503
+ "bom-ref": "pkg:golang/github.com/anchore/syft",
1504
+ name: "github.com/anchore/syft",
1505
+ purl: "pkg:golang/github.com/anchore/syft",
1506
+ type: "application",
1507
+ });
1508
+ expect(retMap.pkgList.length).toEqual(239);
1509
+ expect(retMap.rootList.length).toEqual(84);
1510
+ }, 120000);
1511
+ });
1512
+
1083
1513
  test("parse go list dependencies", async () => {
1084
1514
  const retMap = await parseGoListDep(
1085
1515
  readFileSync("./test/data/golist-dep.txt", { encoding: "utf-8" }),
@@ -2928,12 +3358,12 @@ test("parsePkgLock v3", async () => {
2928
3358
  "sha512-s93jiP6GkRApn5duComx6RLwtP23YrulPxShz+8peX7svd6Q+MS8nKLhKCCazbP92C13eTVaIOxgeLt0ezIiCg==",
2929
3359
  );
2930
3360
  expect(deps[0]).toEqual({
2931
- "bom-ref": "pkg:npm/cdxgen@latest",
2932
- purl: "pkg:npm/cdxgen@latest",
3361
+ "bom-ref": "pkg:npm/clase-21---jwt@latest",
3362
+ purl: "pkg:npm/clase-21---jwt@latest",
2933
3363
  group: "",
2934
3364
  author: "",
2935
3365
  license: "ISC",
2936
- name: "cdxgen",
3366
+ name: "clase-21---jwt",
2937
3367
  type: "application",
2938
3368
  version: "latest",
2939
3369
  });
@@ -3298,8 +3728,8 @@ test("parsePnpmLock", async () => {
3298
3728
  expect(parsedList.dependenciesList).toHaveLength(462);
3299
3729
  expect(parsedList.pkgList.filter((pkg) => !pkg.scope)).toHaveLength(3);
3300
3730
  parsedList = await parsePnpmLock("./pnpm-lock.yaml");
3301
- expect(parsedList.pkgList.length).toEqual(627);
3302
- expect(parsedList.dependenciesList.length).toEqual(627);
3731
+ expect(parsedList.pkgList.length).toEqual(625);
3732
+ expect(parsedList.dependenciesList.length).toEqual(625);
3303
3733
  expect(parsedList.pkgList[0]).toEqual({
3304
3734
  group: "@ampproject",
3305
3735
  name: "remapping",
@@ -4102,41 +4532,207 @@ test("parse requirements.txt", async () => {
4102
4532
  });
4103
4533
 
4104
4534
  test("parse pyproject.toml", () => {
4105
- let pkg = parsePyProjectToml("./test/data/pyproject.toml");
4106
- expect(pkg).toEqual({
4107
- name: "cpggen",
4108
- version: "1.9.0",
4535
+ let retMap = parsePyProjectTomlFile("./test/data/pyproject.toml");
4536
+ expect(retMap.parentComponent).toEqual({
4537
+ author: "Team AppThreat <cloud@appthreat.com>",
4538
+ "bom-ref": "pkg:pypi/cpggen@1.9.0",
4109
4539
  description:
4110
4540
  "Generate CPG for multiple languages for code and threat analysis",
4111
- author: "Team AppThreat <cloud@appthreat.com>",
4112
- homepage: { url: "https://github.com/AppThreat/cpggen" },
4113
- repository: { url: "https://github.com/AppThreat/cpggen" },
4541
+ evidence: {
4542
+ identity: {
4543
+ confidence: 1,
4544
+ field: "purl",
4545
+ methods: [
4546
+ {
4547
+ confidence: 1,
4548
+ technique: "manifest-analysis",
4549
+ value: "./test/data/pyproject.toml",
4550
+ },
4551
+ ],
4552
+ },
4553
+ },
4554
+ homepage: {
4555
+ url: "https://github.com/AppThreat/cpggen",
4556
+ },
4557
+ license: "Apache-2.0",
4558
+ name: "cpggen",
4559
+ purl: "pkg:pypi/cpggen@1.9.0",
4560
+ repository: {
4561
+ url: "https://github.com/AppThreat/cpggen",
4562
+ },
4563
+ tags: [
4564
+ "atom",
4565
+ "code analysis",
4566
+ "code property graph",
4567
+ "cpg",
4568
+ "joern",
4569
+ "static analysis",
4570
+ "threat analysis",
4571
+ ],
4572
+ type: "application",
4573
+ version: "1.9.0",
4114
4574
  });
4115
- pkg = parsePyProjectToml("./test/data/pyproject-author-comma.toml");
4116
- expect(pkg).toEqual({
4117
- name: "rasa",
4118
- version: "3.7.0a1",
4575
+ expect(retMap.poetryMode).toBeTruthy();
4576
+ retMap = parsePyProjectTomlFile("./test/data/pyproject-author-comma.toml");
4577
+ expect(retMap.parentComponent).toEqual({
4578
+ author: "Rasa Technologies GmbH <hi@rasa.com>",
4579
+ "bom-ref": "pkg:pypi/rasa@3.7.0a1",
4580
+ purl: "pkg:pypi/rasa@3.7.0a1",
4581
+ evidence: {
4582
+ identity: {
4583
+ confidence: 1,
4584
+ field: "purl",
4585
+ methods: [
4586
+ {
4587
+ confidence: 1,
4588
+ technique: "manifest-analysis",
4589
+ value: "./test/data/pyproject-author-comma.toml",
4590
+ },
4591
+ ],
4592
+ },
4593
+ },
4119
4594
  description:
4120
4595
  "Open source machine learning framework to automate text- and voice-based conversations: NLU, dialogue management, connect to Slack, Facebook, and more - Create chatbots and voice assistants",
4121
- author: "Rasa Technologies GmbH <hi@rasa.com>",
4122
- homepage: { url: "https://rasa.com" },
4123
- repository: { url: "https://github.com/rasahq/rasa" },
4596
+ homepage: {
4597
+ url: "https://rasa.com",
4598
+ },
4599
+ license: "Apache-2.0",
4600
+ name: "rasa",
4601
+ repository: {
4602
+ url: "https://github.com/rasahq/rasa",
4603
+ },
4604
+ tags: [
4605
+ "bot",
4606
+ "bot-framework",
4607
+ "botkit",
4608
+ "bots",
4609
+ "chatbot",
4610
+ "chatbot-framework",
4611
+ "conversational-ai",
4612
+ "machine-learning",
4613
+ "machine-learning-library",
4614
+ "nlp",
4615
+ "rasa conversational-agents",
4616
+ ],
4617
+ type: "application",
4618
+ version: "3.7.0a1",
4619
+ });
4620
+ expect(Object.keys(retMap.directDepsKeys).length).toEqual(86);
4621
+ expect(Object.keys(retMap.groupDepsKeys).length).toEqual(36);
4622
+ retMap = parsePyProjectTomlFile("./test/data/pyproject_uv.toml");
4623
+ expect(retMap.parentComponent).toEqual({
4624
+ authors: [
4625
+ {
4626
+ email: "redowan.nafi@gmail.com",
4627
+ name: "Redowan Delowar",
4628
+ },
4629
+ ],
4630
+ "bom-ref": "pkg:pypi/fastapi-nano@0.1.0",
4631
+ purl: "pkg:pypi/fastapi-nano@0.1.0",
4632
+ description: "A minimal FastAPI project template.",
4633
+ evidence: {
4634
+ identity: {
4635
+ confidence: 1,
4636
+ field: "purl",
4637
+ methods: [
4638
+ {
4639
+ confidence: 1,
4640
+ technique: "manifest-analysis",
4641
+ value: "./test/data/pyproject_uv.toml",
4642
+ },
4643
+ ],
4644
+ },
4645
+ },
4646
+ name: "fastapi-nano",
4647
+ tags: ["cookiecutter", "docker", "fastapi", "minimal", "template"],
4648
+ version: "0.1.0",
4649
+ type: "application",
4650
+ properties: [
4651
+ {
4652
+ name: "cdx:pypi:requiresPython",
4653
+ value: ">=3.11",
4654
+ },
4655
+ ],
4656
+ });
4657
+ retMap = parsePyProjectTomlFile("./test/data/pyproject_uv2.toml");
4658
+ expect(retMap.parentComponent).toEqual({
4659
+ name: "una-root",
4660
+ evidence: {
4661
+ identity: {
4662
+ confidence: 1,
4663
+ field: "purl",
4664
+ methods: [
4665
+ {
4666
+ confidence: 1,
4667
+ technique: "manifest-analysis",
4668
+ value: "./test/data/pyproject_uv2.toml",
4669
+ },
4670
+ ],
4671
+ },
4672
+ },
4673
+ "bom-ref": "pkg:pypi/una-root@0",
4674
+ purl: "pkg:pypi/una-root@0",
4675
+ properties: [
4676
+ {
4677
+ name: "cdx:pypi:requiresPython",
4678
+ value: ">=3.11",
4679
+ },
4680
+ ],
4681
+ version: "0",
4682
+ type: "application",
4683
+ });
4684
+ expect(retMap.uvMode).toBeTruthy();
4685
+ expect(retMap.directDepsKeys).toEqual({
4686
+ "hatch-una": true,
4687
+ una: true,
4124
4688
  });
4125
4689
  });
4126
4690
 
4127
4691
  test("parse pyproject.toml with custom poetry source", () => {
4128
- const pkg = parsePyProjectToml(
4692
+ const retMap = parsePyProjectTomlFile(
4129
4693
  "./test/data/pyproject_with_custom_poetry_source.toml",
4130
4694
  );
4131
- expect(pkg).toEqual({
4132
- name: "cpggen",
4133
- version: "1.9.0",
4695
+ expect(retMap.parentComponent).toEqual({
4696
+ author: "Team AppThreat <cloud@appthreat.com>",
4697
+ "bom-ref": "pkg:pypi/cpggen@1.9.0",
4698
+ purl: "pkg:pypi/cpggen@1.9.0",
4134
4699
  description:
4135
4700
  "Generate CPG for multiple languages for code and threat analysis",
4136
- author: "Team AppThreat <cloud@appthreat.com>",
4137
- homepage: { url: "https://github.com/AppThreat/cpggen" },
4138
- repository: { url: "https://github.com/AppThreat/cpggen" },
4701
+ evidence: {
4702
+ identity: {
4703
+ confidence: 1,
4704
+ field: "purl",
4705
+ methods: [
4706
+ {
4707
+ confidence: 1,
4708
+ technique: "manifest-analysis",
4709
+ value: "./test/data/pyproject_with_custom_poetry_source.toml",
4710
+ },
4711
+ ],
4712
+ },
4713
+ },
4714
+ homepage: {
4715
+ url: "https://github.com/AppThreat/cpggen",
4716
+ },
4717
+ license: "Apache-2.0",
4718
+ name: "cpggen",
4719
+ repository: {
4720
+ url: "https://github.com/AppThreat/cpggen",
4721
+ },
4722
+ tags: [
4723
+ "atom",
4724
+ "code analysis",
4725
+ "code property graph",
4726
+ "cpg",
4727
+ "joern",
4728
+ "static analysis",
4729
+ "threat analysis",
4730
+ ],
4731
+ version: "1.9.0",
4732
+ type: "application",
4139
4733
  });
4734
+ expect(retMap.poetryMode).toBeTruthy();
4735
+ expect(Object.keys(retMap.directDepsKeys).length).toEqual(6);
4140
4736
  });
4141
4737
 
4142
4738
  test("parse poetry.lock", async () => {
@@ -4165,6 +4761,12 @@ test("parse poetry.lock", async () => {
4165
4761
  );
4166
4762
  expect(retMap.pkgList.length).toEqual(39);
4167
4763
  expect(retMap.dependenciesList.length).toEqual(37);
4764
+ retMap = await parsePoetrylockData(
4765
+ readFileSync("./test/data/uv.lock", { encoding: "utf-8" }),
4766
+ "./test/data/uv.lock",
4767
+ );
4768
+ expect(retMap.pkgList.length).toEqual(63);
4769
+ expect(retMap.dependenciesList.length).toEqual(63);
4168
4770
  }, 120000);
4169
4771
 
4170
4772
  test("parse wheel metadata", () => {