@cyclonedx/cdxgen 8.4.13 → 8.5.0

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,79 @@ 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-elastic.txt", {
315
+ encoding: "utf-8"
316
+ })
317
+ );
318
+ expect(retMap.rootProject).toEqual("elasticsearch");
319
+ expect(retMap.projects.length).toEqual(409);
320
+ });
321
+
270
322
  test("parse maven tree", () => {
271
323
  expect(utils.parseMavenTree(null)).toEqual({});
272
324
  let parsedList = utils.parseMavenTree(
@@ -384,7 +436,6 @@ test("get maven metadata", async () => {
384
436
  */
385
437
 
386
438
  test("get py metadata", async () => {
387
- jest.setTimeout(240000);
388
439
  const data = await utils.getPyMetadata(
389
440
  [
390
441
  {
@@ -402,10 +453,9 @@ test("get py metadata", async () => {
402
453
  version: "1.1.0"
403
454
  }
404
455
  ]);
405
- });
456
+ }, 240000);
406
457
 
407
458
  test("parseGoModData", async () => {
408
- jest.setTimeout(120000);
409
459
  let dep_list = await utils.parseGoModData(null);
410
460
  expect(dep_list).toEqual([]);
411
461
  const gosumMap = {
@@ -455,10 +505,9 @@ test("parseGoModData", async () => {
455
505
  dep_list.forEach((d) => {
456
506
  expect(d.license);
457
507
  });
458
- });
508
+ }, 120000);
459
509
 
460
510
  test("parseGoSumData", async () => {
461
- jest.setTimeout(120000);
462
511
  let dep_list = await utils.parseGoModData(null);
463
512
  expect(dep_list).toEqual([]);
464
513
  dep_list = await utils.parseGosumData(
@@ -496,7 +545,7 @@ test("parseGoSumData", async () => {
496
545
  dep_list.forEach((d) => {
497
546
  expect(d.license);
498
547
  });
499
- });
548
+ }, 120000);
500
549
 
501
550
  test("parse go list dependencies", async () => {
502
551
  let dep_list = await utils.parseGoListDep(
@@ -1563,13 +1612,15 @@ test("parse requirements.txt", async () => {
1563
1612
  let deps = await utils.parseReqFile(
1564
1613
  fs.readFileSync("./test/data/requirements.comments.txt", {
1565
1614
  encoding: "utf-8"
1566
- })
1615
+ }),
1616
+ false
1567
1617
  );
1568
1618
  expect(deps.length).toEqual(31);
1569
1619
  deps = await utils.parseReqFile(
1570
1620
  fs.readFileSync("./test/data/requirements.freeze.txt", {
1571
1621
  encoding: "utf-8"
1572
- })
1622
+ }),
1623
+ false
1573
1624
  );
1574
1625
  expect(deps.length).toEqual(113);
1575
1626
  expect(deps[0]).toEqual({