@cyclonedx/cdxgen 8.4.13 → 8.5.1

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.
package/utils.test.js CHANGED
@@ -76,9 +76,9 @@ test("parse gradle dependencies", () => {
76
76
  let parsedList = utils.parseGradleDep(
77
77
  fs.readFileSync("./test/gradle-dep.out", { encoding: "utf-8" })
78
78
  );
79
- expect(parsedList.pkgList.length).toEqual(34);
79
+ expect(parsedList.pkgList.length).toEqual(33);
80
80
  expect(parsedList.dependenciesList.length).toEqual(34);
81
- expect(parsedList.pkgList[1]).toEqual({
81
+ expect(parsedList.pkgList[0]).toEqual({
82
82
  group: "org.ethereum",
83
83
  name: "solcJ-all",
84
84
  qualifiers: {
@@ -90,9 +90,9 @@ test("parse gradle dependencies", () => {
90
90
  parsedList = utils.parseGradleDep(
91
91
  fs.readFileSync("./test/data/gradle-android-dep.out", { encoding: "utf-8" })
92
92
  );
93
- expect(parsedList.pkgList.length).toEqual(106);
93
+ expect(parsedList.pkgList.length).toEqual(105);
94
94
  expect(parsedList.dependenciesList.length).toEqual(106);
95
- expect(parsedList.pkgList[1]).toEqual({
95
+ expect(parsedList.pkgList[0]).toEqual({
96
96
  group: "com.android.support.test",
97
97
  name: "runner",
98
98
  qualifiers: {
@@ -107,7 +107,7 @@ test("parse gradle dependencies", () => {
107
107
  }
108
108
  ]
109
109
  });
110
- expect(parsedList.pkgList[104]).toEqual({
110
+ expect(parsedList.pkgList[103]).toEqual({
111
111
  group: "androidx.print",
112
112
  name: "print",
113
113
  qualifiers: {
@@ -125,9 +125,9 @@ test("parse gradle dependencies", () => {
125
125
  parsedList = utils.parseGradleDep(
126
126
  fs.readFileSync("./test/data/gradle-out1.dep", { encoding: "utf-8" })
127
127
  );
128
- expect(parsedList.pkgList.length).toEqual(90);
128
+ expect(parsedList.pkgList.length).toEqual(89);
129
129
  expect(parsedList.dependenciesList.length).toEqual(90);
130
- expect(parsedList.pkgList[1]).toEqual({
130
+ expect(parsedList.pkgList[0]).toEqual({
131
131
  group: "org.springframework.boot",
132
132
  name: "spring-boot-starter-web",
133
133
  version: "2.2.0.RELEASE",
@@ -143,7 +143,7 @@ test("parse gradle dependencies", () => {
143
143
  parsedList = utils.parseGradleDep(
144
144
  fs.readFileSync("./test/data/gradle-rich1.dep", { encoding: "utf-8" })
145
145
  );
146
- expect(parsedList.pkgList.length).toEqual(5);
146
+ expect(parsedList.pkgList.length).toEqual(4);
147
147
  expect(parsedList.pkgList[parsedList.pkgList.length - 1]).toEqual({
148
148
  group: "ch.qos.logback",
149
149
  name: "logback-core",
@@ -153,15 +153,8 @@ test("parse gradle dependencies", () => {
153
153
  parsedList = utils.parseGradleDep(
154
154
  fs.readFileSync("./test/data/gradle-rich2.dep", { encoding: "utf-8" })
155
155
  );
156
- expect(parsedList.pkgList.length).toEqual(3);
156
+ expect(parsedList.pkgList.length).toEqual(2);
157
157
  expect(parsedList.pkgList).toEqual([
158
- {
159
- group: "",
160
- name: "root",
161
- qualifiers: { type: "jar" },
162
- type: "maven",
163
- version: "latest"
164
- },
165
158
  {
166
159
  group: "io.appium",
167
160
  name: "java-client",
@@ -178,15 +171,8 @@ test("parse gradle dependencies", () => {
178
171
  parsedList = utils.parseGradleDep(
179
172
  fs.readFileSync("./test/data/gradle-rich3.dep", { encoding: "utf-8" })
180
173
  );
181
- expect(parsedList.pkgList.length).toEqual(2);
174
+ expect(parsedList.pkgList.length).toEqual(1);
182
175
  expect(parsedList.pkgList).toEqual([
183
- {
184
- group: "",
185
- name: "root",
186
- version: "latest",
187
- type: "maven",
188
- qualifiers: { type: "jar" }
189
- },
190
176
  {
191
177
  group: "org.seleniumhq.selenium",
192
178
  name: "selenium-remote-driver",
@@ -197,15 +183,8 @@ test("parse gradle dependencies", () => {
197
183
  parsedList = utils.parseGradleDep(
198
184
  fs.readFileSync("./test/data/gradle-rich4.dep", { encoding: "utf-8" })
199
185
  );
200
- expect(parsedList.pkgList.length).toEqual(2);
186
+ expect(parsedList.pkgList.length).toEqual(1);
201
187
  expect(parsedList.pkgList).toEqual([
202
- {
203
- group: "",
204
- name: "root",
205
- version: "latest",
206
- type: "maven",
207
- qualifiers: { type: "jar" }
208
- },
209
188
  {
210
189
  group: "org.seleniumhq.selenium",
211
190
  name: "selenium-api",
@@ -216,32 +195,32 @@ test("parse gradle dependencies", () => {
216
195
  parsedList = utils.parseGradleDep(
217
196
  fs.readFileSync("./test/data/gradle-rich5.dep", { encoding: "utf-8" })
218
197
  );
219
- expect(parsedList.pkgList.length).toEqual(68);
198
+ expect(parsedList.pkgList.length).toEqual(67);
220
199
  expect(parsedList.dependenciesList.length).toEqual(68);
221
200
  parsedList = utils.parseGradleDep(
222
201
  fs.readFileSync("./test/data/gradle-out-249.dep", { encoding: "utf-8" })
223
202
  );
224
- expect(parsedList.pkgList.length).toEqual(21);
203
+ expect(parsedList.pkgList.length).toEqual(20);
225
204
  expect(parsedList.dependenciesList.length).toEqual(22);
226
205
  parsedList = utils.parseGradleDep(
227
206
  fs.readFileSync("./test/data/gradle-service.out", { encoding: "utf-8" })
228
207
  );
229
- expect(parsedList.pkgList.length).toEqual(35);
208
+ expect(parsedList.pkgList.length).toEqual(34);
230
209
  expect(parsedList.dependenciesList.length).toEqual(36);
231
210
  parsedList = utils.parseGradleDep(
232
211
  fs.readFileSync("./test/data/gradle-s.out", { encoding: "utf-8" })
233
212
  );
234
- expect(parsedList.pkgList.length).toEqual(28);
213
+ expect(parsedList.pkgList.length).toEqual(27);
235
214
  expect(parsedList.dependenciesList.length).toEqual(29);
236
215
  parsedList = utils.parseGradleDep(
237
216
  fs.readFileSync("./test/data/gradle-core.out", { encoding: "utf-8" })
238
217
  );
239
- expect(parsedList.pkgList.length).toEqual(19);
218
+ expect(parsedList.pkgList.length).toEqual(18);
240
219
  expect(parsedList.dependenciesList.length).toEqual(19);
241
220
  parsedList = utils.parseGradleDep(
242
221
  fs.readFileSync("./test/data/gradle-single.out", { encoding: "utf-8" })
243
222
  );
244
- expect(parsedList.pkgList.length).toEqual(153);
223
+ expect(parsedList.pkgList.length).toEqual(152);
245
224
  expect(parsedList.dependenciesList.length).toEqual(153);
246
225
  });
247
226
 
@@ -259,7 +238,7 @@ test("parse gradle projects", () => {
259
238
  fs.readFileSync("./test/data/gradle-projects1.out", { encoding: "utf-8" })
260
239
  );
261
240
  expect(retMap.rootProject).toEqual("elasticsearch");
262
- expect(retMap.projects.length).toEqual(403);
241
+ expect(retMap.projects.length).toEqual(409);
263
242
  retMap = utils.parseGradleProjects(
264
243
  fs.readFileSync("./test/data/gradle-projects2.out", { encoding: "utf-8" })
265
244
  );
@@ -267,6 +246,100 @@ test("parse gradle projects", () => {
267
246
  expect(retMap.projects.length).toEqual(22);
268
247
  });
269
248
 
249
+ test("parse gradle properties", () => {
250
+ expect(utils.parseGradleProperties(null)).toEqual({
251
+ projects: [],
252
+ rootProject: "root",
253
+ metadata: {
254
+ group: "",
255
+ version: "latest",
256
+ properties: []
257
+ }
258
+ });
259
+ let retMap = utils.parseGradleProperties(
260
+ fs.readFileSync("./test/data/gradle-properties.txt", { encoding: "utf-8" })
261
+ );
262
+ expect(retMap).toEqual({
263
+ rootProject: "dependency-diff-check",
264
+ projects: [
265
+ ":dependency-diff-check-client-starter",
266
+ ":dependency-diff-check-common-core",
267
+ ":dependency-diff-check-service"
268
+ ],
269
+ metadata: {
270
+ group: "com.ajmalab",
271
+ version: "0.0.1-SNAPSHOT",
272
+ properties: [
273
+ {
274
+ name: "buildFile",
275
+ value:
276
+ "/home/almalinux/work/sandbox/dependency-diff-check/build.gradle"
277
+ },
278
+ {
279
+ name: "projectDir",
280
+ value: "/home/almalinux/work/sandbox/dependency-diff-check"
281
+ },
282
+ {
283
+ name: "rootDir",
284
+ value: "/home/almalinux/work/sandbox/dependency-diff-check"
285
+ }
286
+ ]
287
+ }
288
+ });
289
+ retMap = utils.parseGradleProperties(
290
+ fs.readFileSync("./test/data/gradle-properties-single.txt", {
291
+ encoding: "utf-8"
292
+ })
293
+ );
294
+ expect(retMap).toEqual({
295
+ rootProject: "java-test",
296
+ projects: [],
297
+ metadata: {
298
+ group: "com.ajmalab.demo",
299
+ version: "latest",
300
+ properties: [
301
+ {
302
+ name: "buildFile",
303
+ value: "/home/almalinux/work/sandbox/java-test/build.gradle"
304
+ },
305
+ {
306
+ name: "projectDir",
307
+ value: "/home/almalinux/work/sandbox/java-test"
308
+ },
309
+ { name: "rootDir", value: "/home/almalinux/work/sandbox/java-test" }
310
+ ]
311
+ }
312
+ });
313
+ retMap = utils.parseGradleProperties(
314
+ fs.readFileSync("./test/data/gradle-properties-single2.txt", {
315
+ encoding: "utf-8"
316
+ })
317
+ );
318
+ expect(retMap).toEqual({
319
+ rootProject: "java-test",
320
+ projects: [],
321
+ metadata: {
322
+ group: "com.ajmalab.demo",
323
+ version: "latest",
324
+ properties: [
325
+ {
326
+ name: "buildFile",
327
+ value: "/home/almalinux/work/sandbox/java-test/build.gradle"
328
+ },
329
+ { name: "projectDir", value: "/home/almalinux/work/sandbox/java-test" },
330
+ { name: "rootDir", value: "/home/almalinux/work/sandbox/java-test" }
331
+ ]
332
+ }
333
+ });
334
+ retMap = utils.parseGradleProperties(
335
+ fs.readFileSync("./test/data/gradle-properties-elastic.txt", {
336
+ encoding: "utf-8"
337
+ })
338
+ );
339
+ expect(retMap.rootProject).toEqual("elasticsearch");
340
+ expect(retMap.projects.length).toEqual(409);
341
+ });
342
+
270
343
  test("parse maven tree", () => {
271
344
  expect(utils.parseMavenTree(null)).toEqual({});
272
345
  let parsedList = utils.parseMavenTree(
@@ -384,7 +457,6 @@ test("get maven metadata", async () => {
384
457
  */
385
458
 
386
459
  test("get py metadata", async () => {
387
- jest.setTimeout(240000);
388
460
  const data = await utils.getPyMetadata(
389
461
  [
390
462
  {
@@ -402,10 +474,9 @@ test("get py metadata", async () => {
402
474
  version: "1.1.0"
403
475
  }
404
476
  ]);
405
- });
477
+ }, 240000);
406
478
 
407
479
  test("parseGoModData", async () => {
408
- jest.setTimeout(120000);
409
480
  let dep_list = await utils.parseGoModData(null);
410
481
  expect(dep_list).toEqual([]);
411
482
  const gosumMap = {
@@ -455,10 +526,9 @@ test("parseGoModData", async () => {
455
526
  dep_list.forEach((d) => {
456
527
  expect(d.license);
457
528
  });
458
- });
529
+ }, 120000);
459
530
 
460
531
  test("parseGoSumData", async () => {
461
- jest.setTimeout(120000);
462
532
  let dep_list = await utils.parseGoModData(null);
463
533
  expect(dep_list).toEqual([]);
464
534
  dep_list = await utils.parseGosumData(
@@ -496,7 +566,7 @@ test("parseGoSumData", async () => {
496
566
  dep_list.forEach((d) => {
497
567
  expect(d.license);
498
568
  });
499
- });
569
+ }, 120000);
500
570
 
501
571
  test("parse go list dependencies", async () => {
502
572
  let dep_list = await utils.parseGoListDep(
@@ -1563,13 +1633,15 @@ test("parse requirements.txt", async () => {
1563
1633
  let deps = await utils.parseReqFile(
1564
1634
  fs.readFileSync("./test/data/requirements.comments.txt", {
1565
1635
  encoding: "utf-8"
1566
- })
1636
+ }),
1637
+ false
1567
1638
  );
1568
1639
  expect(deps.length).toEqual(31);
1569
1640
  deps = await utils.parseReqFile(
1570
1641
  fs.readFileSync("./test/data/requirements.freeze.txt", {
1571
1642
  encoding: "utf-8"
1572
- })
1643
+ }),
1644
+ false
1573
1645
  );
1574
1646
  expect(deps.length).toEqual(113);
1575
1647
  expect(deps[0]).toEqual({