@cyclonedx/cdxgen 8.0.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 ADDED
@@ -0,0 +1,1660 @@
1
+ const utils = require("./utils");
2
+ const fs = require("fs");
3
+ const ssri = require("ssri");
4
+
5
+ test("SSRI test", () => {
6
+ // gopkg.lock hash
7
+ ss = ssri.parse(
8
+ "2ca532a6bc655663344004ba102436d29031018eab236247678db1d8978627bf"
9
+ );
10
+ expect(ss).toEqual(null);
11
+ ss = ssri.parse(
12
+ "sha256-2ca532a6bc655663344004ba102436d29031018eab236247678db1d8978627bf"
13
+ );
14
+ expect(ss.sha256[0].digest).toStrictEqual(
15
+ "2ca532a6bc655663344004ba102436d29031018eab236247678db1d8978627bf"
16
+ );
17
+ ss = ssri.parse(
18
+ "sha256-" +
19
+ Buffer.from(
20
+ "2ca532a6bc655663344004ba102436d29031018eab236247678db1d8978627bf",
21
+ "hex"
22
+ ).toString("base64")
23
+ );
24
+ expect(ss.sha256[0].digest).toStrictEqual(
25
+ "LKUyprxlVmM0QAS6ECQ20pAxAY6rI2JHZ42x2JeGJ78="
26
+ );
27
+ });
28
+
29
+ test("Parse requires dist string", () => {
30
+ expect(utils.parsePyRequiresDist("lazy-object-proxy (>=1.4.0)")).toEqual({
31
+ name: "lazy-object-proxy",
32
+ version: "1.4.0"
33
+ });
34
+ expect(utils.parsePyRequiresDist("wrapt (<1.13,>=1.11)")).toEqual({
35
+ name: "wrapt",
36
+ version: "1.13"
37
+ });
38
+ expect(
39
+ utils.parsePyRequiresDist(
40
+ 'typed-ast (<1.5,>=1.4.0) ; implementation_name == "cpython" and python_version < "3.8"'
41
+ )
42
+ ).toEqual({ name: "typed-ast", version: "1.5" });
43
+ expect(utils.parsePyRequiresDist("asgiref (<4,>=3.2.10)")).toEqual({
44
+ name: "asgiref",
45
+ version: "4"
46
+ });
47
+ expect(utils.parsePyRequiresDist("pytz")).toEqual({
48
+ name: "pytz",
49
+ version: ""
50
+ });
51
+ expect(utils.parsePyRequiresDist("sqlparse (>=0.2.2)")).toEqual({
52
+ name: "sqlparse",
53
+ version: "0.2.2"
54
+ });
55
+ expect(
56
+ utils.parsePyRequiresDist("argon2-cffi (>=16.1.0) ; extra == 'argon2'")
57
+ ).toEqual({ name: "argon2-cffi", version: "16.1.0" });
58
+ expect(utils.parsePyRequiresDist("bcrypt ; extra == 'bcrypt'")).toEqual({
59
+ name: "bcrypt",
60
+ version: ""
61
+ });
62
+ });
63
+
64
+ test("finds license id from name", () => {
65
+ expect(utils.findLicenseId("Apache License Version 2.0")).toEqual(
66
+ "Apache-2.0"
67
+ );
68
+ expect(
69
+ utils.findLicenseId("GNU General Public License (GPL) version 2.0")
70
+ ).toEqual("GPL-2.0-only");
71
+ });
72
+
73
+ test("parse gradle dependencies", () => {
74
+ expect(utils.parseGradleDep(null)).toEqual({});
75
+ let parsedList = utils.parseGradleDep(
76
+ fs.readFileSync("./test/gradle-dep.out", (encoding = "utf-8"))
77
+ );
78
+ expect(parsedList.pkgList.length).toEqual(34);
79
+ expect(parsedList.dependenciesList.length).toEqual(34);
80
+ expect(parsedList.pkgList[1]).toEqual({
81
+ group: "org.ethereum",
82
+ name: "solcJ-all",
83
+ qualifiers: {
84
+ type: "jar"
85
+ },
86
+ version: "0.4.25"
87
+ });
88
+
89
+ parsedList = utils.parseGradleDep(
90
+ fs.readFileSync("./test/data/gradle-android-dep.out", (encoding = "utf-8"))
91
+ );
92
+ expect(parsedList.pkgList.length).toEqual(106);
93
+ expect(parsedList.dependenciesList.length).toEqual(106);
94
+ expect(parsedList.pkgList[1]).toEqual({
95
+ group: "com.android.support.test",
96
+ name: "runner",
97
+ qualifiers: {
98
+ type: "jar"
99
+ },
100
+ version: "1.0.2"
101
+ });
102
+ expect(parsedList.pkgList[104]).toEqual({
103
+ group: "androidx.print",
104
+ name: "print",
105
+ qualifiers: {
106
+ type: "jar"
107
+ },
108
+ version: "1.0.0"
109
+ });
110
+ expect(parsedList.pkgList[105]).toEqual({
111
+ group: "androidx.core",
112
+ name: "core",
113
+ qualifiers: {
114
+ type: "jar"
115
+ },
116
+ version: "1.7.0"
117
+ });
118
+ parsedList = utils.parseGradleDep(
119
+ fs.readFileSync("./test/data/gradle-out1.dep", (encoding = "utf-8"))
120
+ );
121
+ expect(parsedList.pkgList.length).toEqual(90);
122
+ expect(parsedList.dependenciesList.length).toEqual(90);
123
+ expect(parsedList.pkgList[1]).toEqual({
124
+ group: "org.springframework.boot",
125
+ name: "spring-boot-starter-web",
126
+ version: "2.2.0.RELEASE",
127
+ qualifiers: { type: "jar" }
128
+ });
129
+ });
130
+
131
+ test("parse gradle projects", () => {
132
+ expect(utils.parseGradleProjects(null)).toEqual([]);
133
+ let proj_list = utils.parseGradleProjects(
134
+ fs.readFileSync("./test/data/gradle-projects.out", (encoding = "utf-8"))
135
+ );
136
+ expect(proj_list.length).toEqual(9);
137
+ });
138
+
139
+ test("parse maven tree", () => {
140
+ expect(utils.parseMavenTree(null)).toEqual([]);
141
+ let parsedList = utils.parseMavenTree(
142
+ fs.readFileSync("./test/data/sample-mvn-tree.txt", (encoding = "utf-8"))
143
+ );
144
+ expect(parsedList.pkgList.length).toEqual(59);
145
+ expect(parsedList.dependenciesList.length).toEqual(59);
146
+ expect(parsedList.pkgList[0]).toEqual({
147
+ group: "com.pogeyan.cmis",
148
+ name: "copper-server",
149
+ version: "1.15.2",
150
+ qualifiers: { type: "jar" }
151
+ });
152
+ expect(parsedList.dependenciesList[0]).toEqual({
153
+ ref: "pkg:maven/com.pogeyan.cmis/copper-server@1.15.2?type=jar",
154
+ dependsOn: [
155
+ "pkg:maven/javax/javaee-web-api@7.0?type=jar",
156
+ "pkg:maven/org.apache.chemistry.opencmis/chemistry-opencmis-server-support@1.0.0?type=jar",
157
+ "pkg:maven/com.pogeyan.cmis/copper-server-api@1.15.2?type=jar",
158
+ "pkg:maven/com.pogeyan.cmis/copper-server-impl@1.15.2?type=jar",
159
+ "pkg:maven/com.pogeyan.cmis/copper-server-ldap@1.15.2?type=jar",
160
+ "pkg:maven/com.pogeyan.cmis/copper-server-repo@1.15.2?type=jar",
161
+ "pkg:maven/com.pogeyan.cmis/copper-server-mongo@1.15.2?type=jar",
162
+ "pkg:maven/org.apache.commons/commons-lang3@3.4?type=jar",
163
+ "pkg:maven/io.dropwizard.metrics/metrics-core@3.1.2?type=jar",
164
+ "pkg:maven/com.github.davidb/metrics-influxdb@0.9.3?type=jar",
165
+ "pkg:maven/commons-fileupload/commons-fileupload@1.4?type=jar",
166
+ "pkg:maven/com.fasterxml.jackson.core/jackson-core@2.12.0?type=jar",
167
+ "pkg:maven/com.fasterxml.jackson.core/jackson-databind@2.12.0?type=jar",
168
+ "pkg:maven/com.typesafe.akka/akka-actor_2.11@2.4.14?type=jar",
169
+ "pkg:maven/com.typesafe.akka/akka-cluster_2.11@2.4.14?type=jar",
170
+ "pkg:maven/org.codehaus.jackson/jackson-mapper-asl@1.9.13?type=jar",
171
+ "pkg:maven/org.slf4j/slf4j-log4j12@1.7.21?type=jar",
172
+ "pkg:maven/commons-io/commons-io@2.6?type=jar"
173
+ ]
174
+ });
175
+ parsedList = utils.parseMavenTree(
176
+ fs.readFileSync("./test/data/mvn-dep-tree-simple.txt", (encoding = "utf-8"))
177
+ );
178
+ expect(parsedList.pkgList.length).toEqual(27);
179
+ expect(parsedList.dependenciesList.length).toEqual(27);
180
+ expect(parsedList.pkgList[0]).toEqual({
181
+ group: "com.gitlab.security_products.tests",
182
+ name: "java-maven",
183
+ version: "1.0-SNAPSHOT",
184
+ qualifiers: { type: "jar" }
185
+ });
186
+ expect(parsedList.dependenciesList[0]).toEqual({
187
+ ref: "pkg:maven/com.gitlab.security_products.tests/java-maven@1.0-SNAPSHOT?type=jar",
188
+ dependsOn: [
189
+ "pkg:maven/io.netty/netty@3.9.1.Final?type=jar",
190
+ "pkg:maven/org.apache.maven/maven-artifact@3.3.9?type=jar",
191
+ "pkg:maven/com.fasterxml.jackson.core/jackson-databind@2.9.2?type=jar",
192
+ "pkg:maven/org.mozilla/rhino@1.7.10?type=jar",
193
+ "pkg:maven/org.apache.geode/geode-core@1.1.1?type=jar"
194
+ ]
195
+ });
196
+ });
197
+
198
+ // Slow test
199
+ /*
200
+ test("get maven metadata", async () => {
201
+ let data = await utils.getMvnMetadata([
202
+ {
203
+ group: "com.squareup.okhttp3",
204
+ name: "okhttp",
205
+ version: "3.8.1",
206
+ },
207
+ ]);
208
+ expect(data).toEqual([
209
+ {
210
+ description: "",
211
+ group: "com.squareup.okhttp3",
212
+ name: "okhttp",
213
+ version: "3.8.1",
214
+ },
215
+ ]);
216
+
217
+ data = await utils.getMvnMetadata([
218
+ {
219
+ group: "com.fasterxml.jackson.core",
220
+ name: "jackson-databind",
221
+ version: "2.8.5",
222
+ },
223
+ {
224
+ group: "com.github.jnr",
225
+ name: "jnr-posix",
226
+ version: "3.0.47",
227
+ },
228
+ ]);
229
+ expect(data).toEqual([
230
+ {
231
+ group: "com.fasterxml.jackson.core",
232
+ name: "jackson-databind",
233
+ version: "2.8.5",
234
+ description:
235
+ "General data-binding functionality for Jackson: works on core streaming API",
236
+ repository: { url: "http://github.com/FasterXML/jackson-databind" },
237
+ },
238
+ {
239
+ group: "com.github.jnr",
240
+ name: "jnr-posix",
241
+ version: "3.0.47",
242
+ license: ["EPL-2.0", "GPL-2.0-only", "LGPL-2.1-only"],
243
+ description: "\n Common cross-project/cross-platform POSIX APIs\n ",
244
+ repository: { url: "git@github.com:jnr/jnr-posix.git" },
245
+ },
246
+ ]);
247
+ });
248
+ */
249
+
250
+ test("get py metadata", async () => {
251
+ jest.setTimeout(240000);
252
+ const data = await utils.getPyMetadata(
253
+ [
254
+ {
255
+ group: "",
256
+ name: "Flask",
257
+ version: "1.1.0"
258
+ }
259
+ ],
260
+ false
261
+ );
262
+ expect(data).toEqual([
263
+ {
264
+ group: "",
265
+ name: "Flask",
266
+ version: "1.1.0"
267
+ }
268
+ ]);
269
+ });
270
+
271
+ test("parseGoModData", async () => {
272
+ jest.setTimeout(120000);
273
+ let dep_list = await utils.parseGoModData(null);
274
+ expect(dep_list).toEqual([]);
275
+ const gosumMap = {
276
+ "google.golang.org/grpc/v1.21.0":
277
+ "sha256-oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=",
278
+ "github.com/aws/aws-sdk-go/v1.38.47": "sha256-fake-sha-for-aws-go-sdk=",
279
+ "github.com/spf13/cobra/v1.0.0":
280
+ "sha256-/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=",
281
+ "github.com/spf13/viper/v1.0.2":
282
+ "sha256-A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM=",
283
+ "github.com/stretchr/testify/v1.6.1":
284
+ "sha256-6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg="
285
+ };
286
+ dep_list = await utils.parseGoModData(
287
+ fs.readFileSync("./test/gomod/go.mod", (encoding = "utf-8")),
288
+ gosumMap
289
+ );
290
+ expect(dep_list.length).toEqual(4);
291
+ expect(dep_list[0]).toEqual({
292
+ group: "github.com/aws",
293
+ name: "aws-sdk-go",
294
+ license: undefined,
295
+ version: "v1.38.47",
296
+ _integrity: "sha256-fake-sha-for-aws-go-sdk="
297
+ });
298
+ expect(dep_list[1]).toEqual({
299
+ group: "github.com/spf13",
300
+ name: "cobra",
301
+ license: undefined,
302
+ version: "v1.0.0",
303
+ _integrity: "sha256-/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE="
304
+ });
305
+ expect(dep_list[2]).toEqual({
306
+ group: "google.golang.org",
307
+ name: "grpc",
308
+ license: undefined,
309
+ version: "v1.21.0",
310
+ _integrity: "sha256-oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM="
311
+ });
312
+ expect(dep_list[3]).toEqual({
313
+ group: "github.com/spf13",
314
+ name: "viper",
315
+ license: undefined,
316
+ version: "v1.0.2",
317
+ _integrity: "sha256-A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM="
318
+ });
319
+ dep_list.forEach((d) => {
320
+ expect(d.license);
321
+ });
322
+ });
323
+
324
+ test("parseGoSumData", async () => {
325
+ jest.setTimeout(120000);
326
+ let dep_list = await utils.parseGoModData(null);
327
+ expect(dep_list).toEqual([]);
328
+ dep_list = await utils.parseGosumData(
329
+ fs.readFileSync("./test/gomod/go.sum", (encoding = "utf-8"))
330
+ );
331
+ expect(dep_list.length).toEqual(4);
332
+ expect(dep_list[0]).toEqual({
333
+ group: "google.golang.org",
334
+ name: "grpc",
335
+ license: undefined,
336
+ version: "v1.21.0",
337
+ _integrity: "sha256-oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM="
338
+ });
339
+ expect(dep_list[1]).toEqual({
340
+ group: "github.com/spf13",
341
+ name: "cobra",
342
+ license: undefined,
343
+ version: "v1.0.0",
344
+ _integrity: "sha256-/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE="
345
+ });
346
+ expect(dep_list[2]).toEqual({
347
+ group: "github.com/spf13",
348
+ name: "viper",
349
+ license: undefined,
350
+ version: "v1.0.2",
351
+ _integrity: "sha256-A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM="
352
+ });
353
+ expect(dep_list[3]).toEqual({
354
+ group: "github.com/stretchr",
355
+ name: "testify",
356
+ license: undefined,
357
+ version: "v1.6.1",
358
+ _integrity: "sha256-6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg="
359
+ });
360
+ dep_list.forEach((d) => {
361
+ expect(d.license);
362
+ });
363
+ });
364
+
365
+ test("parse go list dependencies", async () => {
366
+ let dep_list = await utils.parseGoListDep(
367
+ fs.readFileSync("./test/data/golist-dep.txt", (encoding = "utf-8")),
368
+ {}
369
+ );
370
+ expect(dep_list.length).toEqual(8);
371
+ expect(dep_list[0]).toEqual({
372
+ group: "github.com/badoux",
373
+ name: "checkmail",
374
+ version: "v0.0.0-20181210160741-9661bd69e9ad"
375
+ });
376
+ });
377
+
378
+ test("parse go mod why dependencies", () => {
379
+ let pkg_name = utils.parseGoModWhy(
380
+ fs.readFileSync("./test/data/gomodwhy.txt", (encoding = "utf-8"))
381
+ );
382
+ expect(pkg_name).toEqual("github.com/mailgun/mailgun-go/v4");
383
+ pkg_name = utils.parseGoModWhy(
384
+ fs.readFileSync("./test/data/gomodwhynot.txt", (encoding = "utf-8"))
385
+ );
386
+ expect(pkg_name).toBeUndefined();
387
+ });
388
+
389
+ test("parseGopkgData", async () => {
390
+ jest.setTimeout(120000);
391
+ let dep_list = await utils.parseGopkgData(null);
392
+ expect(dep_list).toEqual([]);
393
+ dep_list = await utils.parseGopkgData(
394
+ fs.readFileSync("./test/gopkg/Gopkg.lock", (encoding = "utf-8"))
395
+ );
396
+ expect(dep_list.length).toEqual(36);
397
+ expect(dep_list[0]).toEqual({
398
+ group: "cloud.google.com",
399
+ name: "go",
400
+ version: "v0.39.0",
401
+ _integrity: "sha256-LKUyprxlVmM0QAS6ECQ20pAxAY6rI2JHZ42x2JeGJ78="
402
+ });
403
+ dep_list.forEach((d) => {
404
+ expect(d.license);
405
+ });
406
+ });
407
+
408
+ test("parse go version data", async () => {
409
+ let dep_list = await utils.parseGoVersionData(
410
+ fs.readFileSync("./test/data/goversion.txt", (encoding = "utf-8")),
411
+ {}
412
+ );
413
+ expect(dep_list.length).toEqual(125);
414
+ expect(dep_list[0]).toEqual({
415
+ group: "github.com/ShiftLeftSecurity",
416
+ name: "atlassian-connect-go",
417
+ version: "v0.0.2",
418
+ _integrity: "",
419
+ license: undefined
420
+ });
421
+ dep_list = await utils.parseGoVersionData(
422
+ fs.readFileSync("./test/data/goversion2.txt", (encoding = "utf-8")),
423
+ {}
424
+ );
425
+ expect(dep_list.length).toEqual(149);
426
+ expect(dep_list[0]).toEqual({
427
+ group: "cloud.google.com",
428
+ name: "go",
429
+ version: "v0.79.0",
430
+ _integrity: "sha256-oqqswrt4x6b9OGBnNqdssxBl1xf0rSUNjU2BR4BZar0=",
431
+ license: undefined
432
+ });
433
+ });
434
+
435
+ test("parse cargo lock", async () => {
436
+ expect(await utils.parseCargoData(null)).toEqual([]);
437
+ dep_list = await utils.parseCargoData(
438
+ fs.readFileSync("./test/Cargo.lock", (encoding = "utf-8"))
439
+ );
440
+ expect(dep_list.length).toEqual(224);
441
+ expect(dep_list[0]).toEqual({
442
+ group: "",
443
+ name: "abscissa_core",
444
+ version: "0.5.2",
445
+ _integrity:
446
+ "sha384-6a07677093120a02583717b6dd1ef81d8de1e8d01bd226c83f0f9bdf3e56bb3a"
447
+ });
448
+ dep_list = await utils.parseCargoData(
449
+ fs.readFileSync("./test/data/Cargom.lock", (encoding = "utf-8"))
450
+ );
451
+ expect(dep_list.length).toEqual(242);
452
+ expect(dep_list[0]).toEqual({
453
+ group: "",
454
+ name: "actix-codec",
455
+ version: "0.3.0",
456
+ _integrity:
457
+ "sha384-78d1833b3838dbe990df0f1f87baf640cf6146e898166afe401839d1b001e570"
458
+ });
459
+ });
460
+
461
+ test("parse cargo toml", async () => {
462
+ expect(await utils.parseCargoTomlData(null)).toEqual([]);
463
+ dep_list = await utils.parseCargoTomlData(
464
+ fs.readFileSync("./test/data/Cargo1.toml", (encoding = "utf-8"))
465
+ );
466
+ expect(dep_list.length).toEqual(4);
467
+ expect(dep_list).toEqual([
468
+ { group: "", name: "unwind", version: "0.0.0" },
469
+ { name: "libc", version: "0.2.79" },
470
+ { name: "compiler_builtins", version: "0.1.0" },
471
+ { name: "cfg-if", version: "0.1.8" }
472
+ ]);
473
+ dep_list = await utils.parseCargoTomlData(
474
+ fs.readFileSync("./test/data/Cargo2.toml", (encoding = "utf-8"))
475
+ );
476
+ expect(dep_list.length).toEqual(3);
477
+ expect(dep_list).toEqual([
478
+ { group: "", name: "quiche-fuzz", version: "0.1.0" },
479
+ { name: "lazy_static", version: "1" },
480
+ {
481
+ name: "libfuzzer-sys",
482
+ version: "git+https://github.com/rust-fuzz/libfuzzer-sys.git"
483
+ }
484
+ ]);
485
+ });
486
+
487
+ test("parse cargo auditable data", async () => {
488
+ expect(await utils.parseCargoAuditableData(null)).toEqual([]);
489
+ dep_list = await utils.parseCargoAuditableData(
490
+ fs.readFileSync("./test/data/cargo-auditable.txt", (encoding = "utf-8"))
491
+ );
492
+ expect(dep_list.length).toEqual(32);
493
+ expect(dep_list[0]).toEqual({
494
+ group: "",
495
+ name: "adler",
496
+ version: "1.0.2"
497
+ });
498
+ });
499
+
500
+ test("get crates metadata", async () => {
501
+ const dep_list = await utils.getCratesMetadata([
502
+ {
503
+ group: "",
504
+ name: "abscissa_core",
505
+ version: "0.5.2",
506
+ _integrity:
507
+ "sha256-6a07677093120a02583717b6dd1ef81d8de1e8d01bd226c83f0f9bdf3e56bb3a"
508
+ }
509
+ ]);
510
+ expect(dep_list.length).toEqual(1);
511
+ expect(dep_list[0]).toEqual({
512
+ group: "",
513
+ name: "abscissa_core",
514
+ version: "0.5.2",
515
+ _integrity:
516
+ "sha256-6a07677093120a02583717b6dd1ef81d8de1e8d01bd226c83f0f9bdf3e56bb3a",
517
+ description:
518
+ "Application microframework with support for command-line option parsing,\nconfiguration, error handling, logging, and terminal interactions.\nThis crate contains the framework's core functionality.\n",
519
+ license: ["Apache-2.0"],
520
+ repository: {
521
+ url: "https://github.com/iqlusioninc/abscissa/tree/main/core/"
522
+ },
523
+ homepage: { url: "https://github.com/iqlusioninc/abscissa/" }
524
+ });
525
+ });
526
+
527
+ test("parse pub lock", async () => {
528
+ expect(await utils.parsePubLockData(null)).toEqual([]);
529
+ dep_list = await utils.parsePubLockData(
530
+ fs.readFileSync("./test/data/pubspec.lock", (encoding = "utf-8"))
531
+ );
532
+ expect(dep_list.length).toEqual(26);
533
+ expect(dep_list[0]).toEqual({
534
+ name: "async",
535
+ version: "2.8.2"
536
+ });
537
+ dep_list = await utils.parsePubYamlData(
538
+ fs.readFileSync("./test/data/pubspec.yaml", (encoding = "utf-8"))
539
+ );
540
+ expect(dep_list.length).toEqual(1);
541
+ expect(dep_list[0]).toEqual({
542
+ name: "awesome_dialog",
543
+ version: "2.2.1",
544
+ description:
545
+ "Flutter package to show beautiful dialogs(INFO,QUESTION,WARNING,SUCCESS,ERROR) with animations as simply as possible.",
546
+ homepage: {
547
+ url: "https://github.com/marcos930807/awesomeDialogs"
548
+ }
549
+ });
550
+ });
551
+
552
+ test("get dart metadata", async () => {
553
+ const dep_list = await utils.getDartMetadata([
554
+ {
555
+ group: "",
556
+ name: "async",
557
+ version: "2.8.2"
558
+ }
559
+ ]);
560
+ expect(dep_list.length).toEqual(1);
561
+ expect(dep_list[0]).toEqual({
562
+ group: "",
563
+ name: "async",
564
+ version: "2.8.2",
565
+ description:
566
+ "Utility functions and classes related to the 'dart:async' library.",
567
+ license: "https://pub.dev/packages/async/license",
568
+ repository: {
569
+ url: "https://github.com/dart-lang/async"
570
+ }
571
+ });
572
+ });
573
+
574
+ test("parse cabal freeze", async () => {
575
+ expect(await utils.parseCabalData(null)).toEqual([]);
576
+ dep_list = await utils.parseCabalData(
577
+ fs.readFileSync("./test/data/cabal.project.freeze", (encoding = "utf-8"))
578
+ );
579
+ expect(dep_list.length).toEqual(24);
580
+ expect(dep_list[0]).toEqual({
581
+ name: "ansi-terminal",
582
+ version: "0.11.3"
583
+ });
584
+ dep_list = await utils.parseCabalData(
585
+ fs.readFileSync("./test/data/cabal-2.project.freeze", (encoding = "utf-8"))
586
+ );
587
+ expect(dep_list.length).toEqual(366);
588
+ expect(dep_list[0]).toEqual({
589
+ name: "Cabal",
590
+ version: "3.2.1.0"
591
+ });
592
+ });
593
+
594
+ test("parse conan data", async () => {
595
+ expect(await utils.parseConanLockData(null)).toEqual([]);
596
+ dep_list = await utils.parseConanLockData(
597
+ fs.readFileSync("./test/data/conan.lock", (encoding = "utf-8"))
598
+ );
599
+ expect(dep_list.length).toEqual(3);
600
+ expect(dep_list[0]).toEqual({
601
+ name: "zstd",
602
+ version: "1.4.4"
603
+ });
604
+
605
+ dep_list = await utils.parseConanData(
606
+ fs.readFileSync("./test/data/conanfile.txt", (encoding = "utf-8"))
607
+ );
608
+ expect(dep_list.length).toEqual(3);
609
+ expect(dep_list[0]).toEqual({
610
+ name: "zstd",
611
+ version: "1.4.4"
612
+ });
613
+ });
614
+
615
+ test("parse clojure data", () => {
616
+ expect(utils.parseLeiningenData(null)).toEqual([]);
617
+ let dep_list = utils.parseLeiningenData(
618
+ fs.readFileSync("./test/data/project.clj", (encoding = "utf-8"))
619
+ );
620
+ expect(dep_list.length).toEqual(14);
621
+ expect(dep_list[0]).toEqual({
622
+ group: "",
623
+ name: "leiningen-core",
624
+ version: "2.9.9-SNAPSHOT"
625
+ });
626
+ dep_list = utils.parseLeiningenData(
627
+ fs.readFileSync("./test/data/project.clj.1", (encoding = "utf-8"))
628
+ );
629
+ expect(dep_list.length).toEqual(17);
630
+ expect(dep_list[0]).toEqual({
631
+ group: "org.clojure",
632
+ name: "clojure",
633
+ version: "1.9.0"
634
+ });
635
+ dep_list = utils.parseLeiningenData(
636
+ fs.readFileSync("./test/data/project.clj.2", (encoding = "utf-8"))
637
+ );
638
+ expect(dep_list.length).toEqual(49);
639
+ expect(dep_list[0]).toEqual({
640
+ group: "",
641
+ name: "bidi",
642
+ version: "2.1.6"
643
+ });
644
+ dep_list = utils.parseEdnData(
645
+ fs.readFileSync("./test/data/deps.edn", (encoding = "utf-8"))
646
+ );
647
+ expect(dep_list.length).toEqual(20);
648
+ expect(dep_list[0]).toEqual({
649
+ group: "org.clojure",
650
+ name: "clojure",
651
+ version: "1.10.3"
652
+ });
653
+ dep_list = utils.parseEdnData(
654
+ fs.readFileSync("./test/data/deps.edn.1", (encoding = "utf-8"))
655
+ );
656
+ expect(dep_list.length).toEqual(11);
657
+ expect(dep_list[0]).toEqual({
658
+ group: "org.clojure",
659
+ name: "clojure",
660
+ version: "1.11.0-beta1"
661
+ });
662
+ dep_list = utils.parseEdnData(
663
+ fs.readFileSync("./test/data/deps.edn.2", (encoding = "utf-8"))
664
+ );
665
+ expect(dep_list.length).toEqual(5);
666
+ expect(dep_list[0]).toEqual({
667
+ group: "clj-commons",
668
+ name: "pomegranate",
669
+ version: "1.2.1"
670
+ });
671
+ dep_list = utils.parseCljDep(
672
+ fs.readFileSync("./test/data/clj-tree.txt", (encoding = "utf-8"))
673
+ );
674
+ expect(dep_list.length).toEqual(253);
675
+ expect(dep_list[0]).toEqual({
676
+ group: "org.bouncycastle",
677
+ name: "bcprov-jdk15on",
678
+ version: "1.70"
679
+ });
680
+
681
+ dep_list = utils.parseLeinDep(
682
+ fs.readFileSync("./test/data/lein-tree.txt", (encoding = "utf-8"))
683
+ );
684
+ expect(dep_list.length).toEqual(47);
685
+ expect(dep_list[0]).toEqual({
686
+ group: "javax.xml.bind",
687
+ name: "jaxb-api",
688
+ version: "2.4.0-b180830.0359"
689
+ });
690
+ });
691
+
692
+ test("parse mix lock data", async () => {
693
+ expect(await utils.parseMixLockData(null)).toEqual([]);
694
+ dep_list = await utils.parseMixLockData(
695
+ fs.readFileSync("./test/data/mix.lock", (encoding = "utf-8"))
696
+ );
697
+ expect(dep_list.length).toEqual(16);
698
+ expect(dep_list[0]).toEqual({
699
+ name: "absinthe",
700
+ version: "1.7.0"
701
+ });
702
+ dep_list = await utils.parseMixLockData(
703
+ fs.readFileSync("./test/data/mix.lock.1", (encoding = "utf-8"))
704
+ );
705
+ expect(dep_list.length).toEqual(23);
706
+ expect(dep_list[0]).toEqual({
707
+ name: "bunt",
708
+ version: "0.2.0"
709
+ });
710
+ });
711
+
712
+ test("parse github actions workflow data", async () => {
713
+ expect(await utils.parseGitHubWorkflowData(null)).toEqual([]);
714
+ dep_list = await utils.parseGitHubWorkflowData(
715
+ fs.readFileSync("./.github/workflows/nodejs.yml", (encoding = "utf-8"))
716
+ );
717
+ expect(dep_list.length).toEqual(3);
718
+ expect(dep_list[0]).toEqual({
719
+ group: "actions",
720
+ name: "checkout",
721
+ version: "v3"
722
+ });
723
+ dep_list = await utils.parseGitHubWorkflowData(
724
+ fs.readFileSync("./.github/workflows/repotests.yml", (encoding = "utf-8"))
725
+ );
726
+ expect(dep_list.length).toEqual(4);
727
+ expect(dep_list[0]).toEqual({
728
+ group: "actions",
729
+ name: "checkout",
730
+ version: "v3"
731
+ });
732
+ dep_list = await utils.parseGitHubWorkflowData(
733
+ fs.readFileSync("./.github/workflows/app-release.yml", (encoding = "utf-8"))
734
+ );
735
+ expect(dep_list.length).toEqual(4);
736
+ });
737
+
738
+ test("parse cs pkg data", async () => {
739
+ expect(await utils.parseCsPkgData(null)).toEqual([]);
740
+ const dep_list = await utils.parseCsPkgData(
741
+ fs.readFileSync("./test/data/packages.config", (encoding = "utf-8"))
742
+ );
743
+ expect(dep_list.length).toEqual(21);
744
+ expect(dep_list[0]).toEqual({
745
+ group: "",
746
+ name: "Antlr",
747
+ version: "3.5.0.2"
748
+ });
749
+ });
750
+
751
+ test("parse cs pkg data 2", async () => {
752
+ expect(await utils.parseCsPkgData(null)).toEqual([]);
753
+ const dep_list = await utils.parseCsPkgData(
754
+ fs.readFileSync("./test/data/packages2.config", (encoding = "utf-8"))
755
+ );
756
+ expect(dep_list.length).toEqual(1);
757
+ expect(dep_list[0]).toEqual({
758
+ group: "",
759
+ name: "EntityFramework",
760
+ version: "6.2.0"
761
+ });
762
+ });
763
+
764
+ test("parse cs proj", async () => {
765
+ expect(await utils.parseCsProjData(null)).toEqual([]);
766
+ const dep_list = await utils.parseCsProjData(
767
+ fs.readFileSync("./test/sample.csproj", (encoding = "utf-8"))
768
+ );
769
+ expect(dep_list.length).toEqual(5);
770
+ expect(dep_list[0]).toEqual({
771
+ group: "",
772
+ name: "Microsoft.AspNetCore.Mvc.NewtonsoftJson",
773
+ version: "3.1.1"
774
+ });
775
+ });
776
+
777
+ test("parse project.assets.json", async () => {
778
+ expect(await utils.parseCsProjAssetsData(null)).toEqual([]);
779
+ const dep_list = await utils.parseCsProjAssetsData(
780
+ fs.readFileSync("./test/data/project.assets.json", (encoding = "utf-8"))
781
+ );
782
+ expect(dep_list.length).toEqual(142);
783
+ expect(dep_list[0]).toEqual({
784
+ group: "",
785
+ name: "Castle.Core",
786
+ version: "4.4.1",
787
+ _integrity:
788
+ "sha512-zanbjWC0Y05gbx4eGXkzVycOQqVOFVeCjVsDSyuao9P4mtN1w3WxxTo193NGC7j3o2u3AJRswaoC6hEbnGACnQ=="
789
+ });
790
+ });
791
+
792
+ test("parse packages.lock.json", async () => {
793
+ expect(await utils.parseCsPkgLockData(null)).toEqual([]);
794
+ const dep_list = await utils.parseCsPkgLockData(
795
+ fs.readFileSync("./test/data/packages.lock.json", (encoding = "utf-8"))
796
+ );
797
+ expect(dep_list.length).toEqual(14);
798
+ expect(dep_list[0]).toEqual({
799
+ group: "",
800
+ name: "Antlr",
801
+ version: "3.5.0.2"
802
+ });
803
+ });
804
+
805
+ test("parse .net cs proj", async () => {
806
+ expect(await utils.parseCsProjData(null)).toEqual([]);
807
+ const dep_list = await utils.parseCsProjData(
808
+ fs.readFileSync("./test/data/sample-dotnet.csproj", (encoding = "utf-8"))
809
+ );
810
+ expect(dep_list.length).toEqual(19);
811
+ expect(dep_list[0]).toEqual({
812
+ group: "",
813
+ name: "Antlr3.Runtime",
814
+ version: "3.5.0.2"
815
+ });
816
+ });
817
+
818
+ test("get nget metadata", async () => {
819
+ const dep_list = await utils.getNugetMetadata([
820
+ {
821
+ group: "",
822
+ name: "Castle.Core",
823
+ version: "4.4.0"
824
+ }
825
+ ]);
826
+ expect(dep_list.length).toEqual(1);
827
+ expect(dep_list[0]).toEqual({
828
+ group: "",
829
+ name: "Castle.Core",
830
+ version: "4.4.0",
831
+ description:
832
+ "Castle Core, including DynamicProxy, Logging Abstractions and DictionaryAdapter",
833
+ homepage: {
834
+ url: "https://www.nuget.org/packages/Castle.Core/4.4.0/"
835
+ },
836
+ license: "http://www.apache.org/licenses/LICENSE-2.0.html",
837
+ repository: {
838
+ url: "http://www.castleproject.org/"
839
+ }
840
+ });
841
+ });
842
+
843
+ test("parsePomFile", () => {
844
+ const data = utils.parsePom("./test/pom.xml");
845
+ expect(data.length).toEqual(13);
846
+ });
847
+
848
+ test("parsePomMetadata", async () => {
849
+ const deps = utils.parsePom("./test/pom.xml");
850
+ const data = await utils.getMvnMetadata(deps);
851
+ expect(data.length).toEqual(deps.length);
852
+ });
853
+ /*
854
+ test("get repo license", async () => {
855
+ let license = await utils.getRepoLicense(
856
+ "https://github.com/ShiftLeftSecurity/sast-scan"
857
+ );
858
+ expect(license).toEqual({
859
+ id: "GPL-3.0-or-later",
860
+ url: "https://github.com/ShiftLeftSecurity/sast-scan/blob/master/LICENSE"
861
+ });
862
+
863
+ license = await utils.getRepoLicense("https://github.com/cyclonedx/cdxgen", {
864
+ group: "",
865
+ name: "cdxgen"
866
+ });
867
+ expect(license).toEqual({
868
+ id: "Apache-2.0",
869
+ url: "https://github.com/cyclonedx/cdxgen/blob/master/LICENSE"
870
+ });
871
+
872
+ license = await utils.getRepoLicense("https://cloud.google.com/go", {
873
+ group: "cloud.google.com",
874
+ name: "go"
875
+ });
876
+ expect(license).toEqual("Apache-2.0");
877
+
878
+ license = await utils.getRepoLicense(undefined, {
879
+ group: "github.com/ugorji",
880
+ name: "go"
881
+ });
882
+ expect(license).toEqual({
883
+ id: "MIT",
884
+ url: "https://github.com/ugorji/go/blob/master/LICENSE"
885
+ });
886
+ });
887
+ */
888
+ test("get go pkg license", async () => {
889
+ let license = await utils.getGoPkgLicense({
890
+ group: "github.com/Azure/azure-amqp-common-go",
891
+ name: "v2"
892
+ });
893
+ expect(license).toEqual([
894
+ {
895
+ id: "MIT",
896
+ url: "https://pkg.go.dev/github.com/Azure/azure-amqp-common-go/v2?tab=licenses"
897
+ }
898
+ ]);
899
+
900
+ license = await utils.getGoPkgLicense({
901
+ group: "go.opencensus.io",
902
+ name: "go.opencensus.io"
903
+ });
904
+ expect(license).toEqual([
905
+ {
906
+ id: "Apache-2.0",
907
+ url: "https://pkg.go.dev/go.opencensus.io?tab=licenses"
908
+ }
909
+ ]);
910
+
911
+ license = await utils.getGoPkgLicense({
912
+ group: "github.com/DataDog",
913
+ name: "zstd"
914
+ });
915
+ expect(license).toEqual([
916
+ {
917
+ id: "BSD-3-Clause",
918
+ url: "https://pkg.go.dev/github.com/DataDog/zstd?tab=licenses"
919
+ }
920
+ ]);
921
+ });
922
+
923
+ test("get licenses", () => {
924
+ let licenses = utils.getLicenses({ license: "MIT" });
925
+ expect(licenses).toEqual([
926
+ {
927
+ license: {
928
+ id: "MIT",
929
+ url: "https://opensource.org/licenses/MIT"
930
+ }
931
+ }
932
+ ]);
933
+
934
+ licenses = utils.getLicenses({ license: ["MIT", "GPL-3.0-or-later"] });
935
+ expect(licenses).toEqual([
936
+ {
937
+ license: {
938
+ id: "MIT",
939
+ url: "https://opensource.org/licenses/MIT"
940
+ }
941
+ },
942
+ {
943
+ license: {
944
+ id: "GPL-3.0-or-later",
945
+ url: "https://opensource.org/licenses/GPL-3.0-or-later"
946
+ }
947
+ }
948
+ ]);
949
+
950
+ licenses = utils.getLicenses({
951
+ license: {
952
+ id: "MIT",
953
+ url: "https://opensource.org/licenses/MIT"
954
+ }
955
+ });
956
+ expect(licenses).toEqual([
957
+ {
958
+ license: {
959
+ id: "MIT",
960
+ url: "https://opensource.org/licenses/MIT"
961
+ }
962
+ }
963
+ ]);
964
+ });
965
+
966
+ test("parsePkgLock", async () => {
967
+ let parsedList = await utils.parsePkgLock("./test/package-lock.json");
968
+ let deps = parsedList.pkgList;
969
+ expect(deps.length).toEqual(760);
970
+ expect(deps[1]._integrity).toEqual(
971
+ "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q=="
972
+ );
973
+ expect(parsedList.dependenciesList.length).toEqual(621);
974
+ parsedList = await utils.parsePkgLock("./test/data/package-lock-v1.json");
975
+ deps = parsedList.pkgList;
976
+ expect(deps.length).toEqual(639);
977
+ expect(deps[1]._integrity).toEqual(
978
+ "sha512-/r5HiDwOXTjucbBYkrTMpzWQAwil9MH7zSEfKH+RWWZv27r4vDiUd2FiBJItyQoPThLPxaf82IO6gCXyJR0ZnQ=="
979
+ );
980
+ expect(parsedList.dependenciesList.length).toEqual(572);
981
+ });
982
+
983
+ test("parseBowerJson", async () => {
984
+ const deps = await utils.parseBowerJson("./test/data/bower.json");
985
+ expect(deps.length).toEqual(1);
986
+ expect(deps[0].name).toEqual("jquery");
987
+ });
988
+
989
+ test("parseNodeShrinkwrap", async () => {
990
+ const deps = await utils.parseNodeShrinkwrap("./test/shrinkwrap-deps.json");
991
+ expect(deps.length).toEqual(496);
992
+ expect(deps[0]._integrity).toEqual(
993
+ "sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g=="
994
+ );
995
+ });
996
+
997
+ test("parseSetupPyFile", async () => {
998
+ let deps = await utils.parseSetupPyFile(`install_requires=[
999
+ 'colorama>=0.4.3',
1000
+ 'libsast>=1.0.3',
1001
+ ],`);
1002
+ expect(deps.length).toEqual(2);
1003
+ expect(deps[0].name).toEqual("colorama");
1004
+
1005
+ deps = await utils.parseSetupPyFile(
1006
+ `install_requires=['colorama>=0.4.3','libsast>=1.0.3',],`
1007
+ );
1008
+ expect(deps.length).toEqual(2);
1009
+ expect(deps[0].name).toEqual("colorama");
1010
+
1011
+ deps = await utils.parseSetupPyFile(
1012
+ `install_requires=['colorama>=0.4.3','libsast>=1.0.3']`
1013
+ );
1014
+ expect(deps.length).toEqual(2);
1015
+ expect(deps[0].name).toEqual("colorama");
1016
+
1017
+ deps = await utils.parseSetupPyFile(
1018
+ `install_requires=['colorama>=0.4.3', 'libsast>=1.0.3']`
1019
+ );
1020
+ expect(deps.length).toEqual(2);
1021
+ expect(deps[0].name).toEqual("colorama");
1022
+
1023
+ deps = await utils.parseSetupPyFile(`install_requires=[
1024
+ 'colorama>=0.4.3',
1025
+ 'libsast>=1.0.3',
1026
+ ]`);
1027
+ expect(deps.length).toEqual(2);
1028
+ expect(deps[0].name).toEqual("colorama");
1029
+ });
1030
+
1031
+ test("parsePnpmLock", async () => {
1032
+ let parsedList = await utils.parsePnpmLock("./test/pnpm-lock.yaml");
1033
+ expect(parsedList.pkgList.length).toEqual(1610);
1034
+ expect(parsedList.dependenciesList.length).toEqual(1610);
1035
+ expect(parsedList.pkgList[0]).toEqual({
1036
+ _integrity:
1037
+ "sha512-IGhtTmpjGbYzcEDOw7DcQtbQSXcG9ftmAXtWTu9V936vDye4xjjekktFAtgZsWpzTj/X01jocB46mTywm/4SZw==",
1038
+ group: "@babel",
1039
+ name: "code-frame",
1040
+ scope: undefined,
1041
+ version: "7.10.1",
1042
+ properties: [
1043
+ {
1044
+ name: "SrcFile",
1045
+ value: "./test/pnpm-lock.yaml"
1046
+ }
1047
+ ]
1048
+ });
1049
+ parsedList = await utils.parsePnpmLock("./test/data/pnpm-lock.yaml");
1050
+ expect(parsedList.pkgList.length).toEqual(308);
1051
+ expect(parsedList.dependenciesList.length).toEqual(308);
1052
+ expect(parsedList.pkgList[0]).toEqual({
1053
+ _integrity:
1054
+ "sha512-iAXqUn8IIeBTNd72xsFlgaXHkMBMt6y4HJp1tIaK465CWLT/fG1aqB7ykr95gHHmlBdGbFeWWfyB4NJJ0nmeIg==",
1055
+ group: "@babel",
1056
+ name: "code-frame",
1057
+ scope: "optional",
1058
+ version: "7.16.7",
1059
+ properties: [
1060
+ {
1061
+ name: "SrcFile",
1062
+ value: "./test/data/pnpm-lock.yaml"
1063
+ }
1064
+ ]
1065
+ });
1066
+ parsedList = await utils.parsePnpmLock("./test/data/pnpm-lock2.yaml");
1067
+ expect(parsedList.pkgList.length).toEqual(7);
1068
+ expect(parsedList.dependenciesList.length).toEqual(7);
1069
+ expect(parsedList.pkgList[0]).toEqual({
1070
+ group: "",
1071
+ name: "ansi-regex",
1072
+ version: "2.1.1",
1073
+ scope: undefined,
1074
+ _integrity: "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
1075
+ properties: [{ name: "SrcFile", value: "./test/data/pnpm-lock2.yaml" }]
1076
+ });
1077
+ expect(parsedList.dependenciesList[2]).toEqual({
1078
+ ref: "pkg:npm/chalk@1.1.3",
1079
+ dependsOn: [
1080
+ "pkg:npm/ansi-styles@2.2.1",
1081
+ "pkg:npm/escape-string-regexp@1.0.5",
1082
+ "pkg:npm/has-ansi@2.0.0",
1083
+ "pkg:npm/strip-ansi@3.0.1",
1084
+ "pkg:npm/supports-color@2.0.0"
1085
+ ]
1086
+ });
1087
+ parsedList = await utils.parsePnpmLock("./test/data/pnpm-lock3.yaml");
1088
+ expect(parsedList.pkgList.length).toEqual(448);
1089
+ expect(parsedList.dependenciesList.length).toEqual(448);
1090
+ expect(parsedList.pkgList[0]).toEqual({
1091
+ group: "@nodelib",
1092
+ name: "fs.scandir",
1093
+ version: "2.1.5",
1094
+ scope: undefined,
1095
+ _integrity:
1096
+ "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==",
1097
+ properties: [{ name: "SrcFile", value: "./test/data/pnpm-lock3.yaml" }]
1098
+ });
1099
+ expect(parsedList.dependenciesList[2]).toEqual({
1100
+ ref: "pkg:npm/@nodelib/fs.walk@1.2.8",
1101
+ dependsOn: ["pkg:npm/@nodelib/fs.scandir@2.1.5", "pkg:npm/fastq@1.13.0"]
1102
+ });
1103
+
1104
+ parsedList = await utils.parsePnpmLock("./test/data/pnpm-lock4.yaml");
1105
+ expect(parsedList.pkgList.length).toEqual(1);
1106
+ });
1107
+
1108
+ test("parseYarnLock", async () => {
1109
+ let identMap = utils.yarnLockToIdentMap(
1110
+ fs.readFileSync("./test/yarn.lock", "utf8")
1111
+ );
1112
+ expect(Object.keys(identMap).length).toEqual(62);
1113
+ let parsedList = await utils.parseYarnLock("./test/yarn.lock");
1114
+ expect(parsedList.pkgList.length).toEqual(56);
1115
+ expect(parsedList.pkgList[0]).toEqual({
1116
+ group: "",
1117
+ name: "asap",
1118
+ version: "2.0.5",
1119
+ _integrity: "sha256-522765b50c3510490e52d7dcfe085ef9ba96958f",
1120
+ properties: [
1121
+ {
1122
+ name: "SrcFile",
1123
+ value: "./test/yarn.lock"
1124
+ }
1125
+ ]
1126
+ });
1127
+
1128
+ identMap = utils.yarnLockToIdentMap(
1129
+ fs.readFileSync("./test/data/yarn_locks/yarn.lock", "utf8")
1130
+ );
1131
+ expect(Object.keys(identMap).length).toEqual(2566);
1132
+ parsedList = await utils.parseYarnLock("./test/data/yarn_locks/yarn.lock");
1133
+ expect(parsedList.pkgList.length).toEqual(2029);
1134
+ expect(parsedList.dependenciesList.length).toEqual(2029);
1135
+ expect(parsedList.pkgList[0]).toEqual({
1136
+ group: "babel",
1137
+ name: "cli",
1138
+ version: "7.10.1",
1139
+ _integrity:
1140
+ "sha512-cVB+dXeGhMOqViIaZs3A9OUAe4pKw4SBNdMw6yHJMYR7s4TB+Cei7ThquV/84O19PdIFWuwe03vxxES0BHUm5g==",
1141
+ properties: [
1142
+ {
1143
+ name: "SrcFile",
1144
+ value: "./test/data/yarn_locks/yarn.lock"
1145
+ }
1146
+ ]
1147
+ });
1148
+ parsedList.pkgList.forEach((d) => {
1149
+ expect(d.name).toBeDefined();
1150
+ expect(d.version).toBeDefined();
1151
+ });
1152
+
1153
+ parsedList = await utils.parseYarnLock(
1154
+ "./test/data/yarn_locks/yarn-multi.lock"
1155
+ );
1156
+ expect(parsedList.pkgList.length).toEqual(1909);
1157
+ expect(parsedList.dependenciesList.length).toEqual(1909);
1158
+ expect(parsedList.pkgList[0]).toEqual({
1159
+ _integrity:
1160
+ "sha512-zpruxnFMz6K94gs2pqc3sidzFDbQpKT5D6P/J/I9s8ekHZ5eczgnRp6pqXC86Bh7+44j/btpmOT0kwiboyqTnA==",
1161
+ group: "apollo",
1162
+ name: "client",
1163
+ version: "3.2.5",
1164
+ properties: [
1165
+ {
1166
+ name: "SrcFile",
1167
+ value: "./test/data/yarn_locks/yarn-multi.lock"
1168
+ }
1169
+ ]
1170
+ });
1171
+
1172
+ parsedList = await utils.parseYarnLock(
1173
+ "./test/data/yarn_locks/yarn-light.lock"
1174
+ );
1175
+ expect(parsedList.pkgList.length).toEqual(315);
1176
+ expect(parsedList.dependenciesList.length).toEqual(315);
1177
+ expect(parsedList.pkgList[0]).toEqual({
1178
+ _integrity:
1179
+ "sha512-rZ1k9kQvJX21Vwgx1L6kSQ6yeXo9cCMyqURSnjG+MRoJn+Mr3LblxmVdzScHXRzv0N9yzy49oG7Bqxp9Knyv/g==",
1180
+ group: "actions",
1181
+ name: "artifact",
1182
+ version: "0.6.1",
1183
+ properties: [
1184
+ {
1185
+ name: "SrcFile",
1186
+ value: "./test/data/yarn_locks/yarn-light.lock"
1187
+ }
1188
+ ]
1189
+ });
1190
+
1191
+ parsedList = await utils.parseYarnLock("./test/data/yarn_locks/yarn3.lock");
1192
+ expect(parsedList.pkgList.length).toEqual(5);
1193
+ expect(parsedList.dependenciesList.length).toEqual(5);
1194
+ expect(parsedList.pkgList[1]).toEqual({
1195
+ _integrity:
1196
+ "sha512-+X9Jn4mPI+RYV0ITiiLyJSYlT9um111BocJSaztsxXR+9ZxWErpzdfQqyk+EYZUOklugjJkerQZRtJGLfJeClw==",
1197
+ group: "",
1198
+ name: "lru-cache",
1199
+ version: "6.0.0",
1200
+ properties: [
1201
+ {
1202
+ name: "SrcFile",
1203
+ value: "./test/data/yarn_locks/yarn3.lock"
1204
+ }
1205
+ ]
1206
+ });
1207
+
1208
+ parsedList = await utils.parseYarnLock("./test/data/yarn_locks/yarnv2.lock");
1209
+ expect(parsedList.pkgList.length).toEqual(1090);
1210
+ expect(parsedList.dependenciesList.length).toEqual(1088);
1211
+ expect(parsedList.pkgList[0]).toEqual({
1212
+ _integrity:
1213
+ "sha512-G0U5NjBUYIs39l1J1ckgpVfVX2IxpzRAIT4/2An86O2Mcri3k5xNu7/RRkfObo12wN9s7BmnREAMhH7252oZiA==",
1214
+ group: "arcanis",
1215
+ name: "slice-ansi",
1216
+ version: "1.0.2",
1217
+ properties: [
1218
+ {
1219
+ name: "SrcFile",
1220
+ value: "./test/data/yarn_locks/yarnv2.lock"
1221
+ }
1222
+ ]
1223
+ });
1224
+ parsedList = await utils.parseYarnLock("./test/data/yarn_locks/yarnv3.lock");
1225
+ expect(parsedList.pkgList.length).toEqual(325);
1226
+ expect(parsedList.dependenciesList.length).toEqual(323);
1227
+ expect(parsedList.pkgList[0]).toEqual({
1228
+ _integrity:
1229
+ "sha512-vtU+q0TmdIDmezU7lKub73vObN6nmd3lkcKWz7R9hyNI8gz5o7grDb+FML9nykOLW+09gGIup2xyJ86j5vBKpg==",
1230
+ group: "babel",
1231
+ name: "code-frame",
1232
+ version: "7.16.7",
1233
+ properties: [
1234
+ {
1235
+ name: "SrcFile",
1236
+ value: "./test/data/yarn_locks/yarnv3.lock"
1237
+ }
1238
+ ]
1239
+ });
1240
+ parsedList = await utils.parseYarnLock("./test/data/yarn_locks/yarn4.lock");
1241
+ expect(parsedList.pkgList.length).toEqual(1);
1242
+ });
1243
+
1244
+ test("parseComposerLock", () => {
1245
+ let deps = utils.parseComposerLock("./test/data/composer.lock");
1246
+ expect(deps.length).toEqual(1);
1247
+ expect(deps[0]).toEqual({
1248
+ group: "quickbooks",
1249
+ name: "v3-php-sdk",
1250
+ scope: "required",
1251
+ version: "4.0.6.1",
1252
+ repository: {
1253
+ type: "git",
1254
+ url: "https://github.com/intuit/QuickBooks-V3-PHP-SDK.git",
1255
+ reference: "fe42e409bcdc431614f1cfc80cfc4191b926f3ed"
1256
+ },
1257
+ license: ["Apache-2.0"],
1258
+ description: "The Official PHP SDK for QuickBooks Online Accounting API",
1259
+ properties: [
1260
+ {
1261
+ name: "SrcFile",
1262
+ value: "./test/data/composer.lock"
1263
+ }
1264
+ ]
1265
+ });
1266
+
1267
+ deps = utils.parseComposerLock("./test/data/composer-2.lock");
1268
+ expect(deps.length).toEqual(73);
1269
+ expect(deps[0]).toEqual({
1270
+ group: "amphp",
1271
+ name: "amp",
1272
+ scope: "required",
1273
+ version: "2.4.4",
1274
+ repository: {
1275
+ type: "git",
1276
+ url: "https://github.com/amphp/amp.git",
1277
+ reference: "1e58d53e4af390efc7813e36cd215bd82cba4b06"
1278
+ },
1279
+ license: ["MIT"],
1280
+ description: "A non-blocking concurrency framework for PHP applications.",
1281
+ properties: [
1282
+ {
1283
+ name: "SrcFile",
1284
+ value: "./test/data/composer-2.lock"
1285
+ }
1286
+ ]
1287
+ });
1288
+ });
1289
+
1290
+ test("parseGemfileLockData", async () => {
1291
+ let deps = await utils.parseGemfileLockData(
1292
+ fs.readFileSync("./test/data/Gemfile.lock", (encoding = "utf-8"))
1293
+ );
1294
+ expect(deps.length).toEqual(140);
1295
+ expect(deps[0]).toEqual({
1296
+ name: "actioncable",
1297
+ version: "6.0.0"
1298
+ });
1299
+ });
1300
+
1301
+ test("parseGemspecData", async () => {
1302
+ let deps = await utils.parseGemspecData(
1303
+ fs.readFileSync("./test/data/xmlrpc.gemspec", (encoding = "utf-8"))
1304
+ );
1305
+ expect(deps.length).toEqual(1);
1306
+ expect(deps[0]).toEqual({
1307
+ name: "xmlrpc",
1308
+ version: "0.3.0",
1309
+ description:
1310
+ "XMLRPC is a lightweight protocol that enables remote procedure calls over HTTP."
1311
+ });
1312
+ });
1313
+
1314
+ test("parse requirements.txt with comments", async () => {
1315
+ jest.setTimeout(120000);
1316
+ let deps = await utils.parseReqFile(
1317
+ fs.readFileSync(
1318
+ "./test/data/requirements.comments.txt",
1319
+ (encoding = "utf-8")
1320
+ )
1321
+ );
1322
+ expect(deps.length).toEqual(31);
1323
+ });
1324
+
1325
+ test("parse poetry.lock", async () => {
1326
+ jest.setTimeout(120000);
1327
+ let deps = await utils.parsePoetrylockData(
1328
+ fs.readFileSync("./test/data/poetry.lock", (encoding = "utf-8"))
1329
+ );
1330
+ expect(deps.length).toEqual(31);
1331
+ deps = await utils.parsePoetrylockData(
1332
+ fs.readFileSync("./test/data/poetry1.lock", (encoding = "utf-8"))
1333
+ );
1334
+ expect(deps.length).toEqual(67);
1335
+ });
1336
+
1337
+ test("parse wheel metadata", () => {
1338
+ let deps = utils.parseBdistMetadata(
1339
+ fs.readFileSync("./test/data/METADATA", (encoding = "utf-8"))
1340
+ );
1341
+ expect(deps.length).toEqual(1);
1342
+ expect(deps[0]).toEqual({
1343
+ version: "1.26.1",
1344
+ name: "yamllint",
1345
+ publisher: "Adrien Vergé",
1346
+ description: "A linter for YAML files.",
1347
+ homepage: { url: "https://github.com/adrienverge/yamllint" },
1348
+ repository: { url: "https://github.com/adrienverge/yamllint" }
1349
+ });
1350
+ deps = utils.parseBdistMetadata(
1351
+ fs.readFileSync(
1352
+ "./test/data/mercurial-5.5.2-py3.8.egg-info",
1353
+ (encoding = "utf-8")
1354
+ )
1355
+ );
1356
+ expect(deps.length).toEqual(1);
1357
+ expect(deps[0]).toEqual({
1358
+ version: "5.5.2",
1359
+ name: "mercurial",
1360
+ publisher: "Matt Mackall and many others",
1361
+ description:
1362
+ "Fast scalable distributed SCM (revision control, version control) system",
1363
+ homepage: { url: "https://mercurial-scm.org/" }
1364
+ });
1365
+ });
1366
+
1367
+ test("parse wheel", async () => {
1368
+ let metadata = await utils.readZipEntry(
1369
+ "./test/data/appthreat_depscan-2.0.2-py3-none-any.whl",
1370
+ "METADATA"
1371
+ );
1372
+ expect(metadata);
1373
+ const parsed = utils.parseBdistMetadata(metadata);
1374
+ expect(parsed[0]).toEqual({
1375
+ version: "2.0.2",
1376
+ name: "appthreat-depscan",
1377
+ description:
1378
+ "Fully open-source security audit for project dependencies based on known vulnerabilities and advisories.",
1379
+ homepage: { url: "https://github.com/appthreat/dep-scan" },
1380
+ publisher: "Team AppThreat"
1381
+ });
1382
+ });
1383
+
1384
+ test("parse pipfile.lock with hashes", async () => {
1385
+ jest.setTimeout(120000);
1386
+ let deps = await utils.parsePiplockData(
1387
+ JSON.parse(
1388
+ fs.readFileSync("./test/data/Pipfile.lock", (encoding = "utf-8"))
1389
+ )
1390
+ );
1391
+ expect(deps.length).toEqual(46);
1392
+ });
1393
+
1394
+ test("parse scala sbt list", async () => {
1395
+ let deps = utils.parseKVDep(
1396
+ fs.readFileSync("./test/data/sbt-dl.list", { encoding: "utf-8" })
1397
+ );
1398
+ expect(deps.length).toEqual(57);
1399
+ });
1400
+
1401
+ test("parse scala sbt lock", async () => {
1402
+ let deps = utils.parseSbtLock("./test/data/build.sbt.lock");
1403
+ expect(deps.length).toEqual(117);
1404
+ });
1405
+
1406
+ test("parse nupkg file", async () => {
1407
+ let deps = await utils.parseNupkg("./test/data/jquery.3.6.0.nupkg");
1408
+ expect(deps.length).toEqual(1);
1409
+ expect(deps[0].name).toEqual("jQuery");
1410
+ });
1411
+
1412
+ test("parse bazel skyframe", () => {
1413
+ let deps = utils.parseBazelSkyframe(
1414
+ fs.readFileSync("./test/data/bazel/bazel-state.txt", (encoding = "utf-8"))
1415
+ );
1416
+ expect(deps.length).toEqual(16);
1417
+ expect(deps[0].name).toEqual("guava");
1418
+ });
1419
+
1420
+ test("parse bazel build", () => {
1421
+ let projs = utils.parseBazelBuild(
1422
+ fs.readFileSync("./test/data/bazel/BUILD", (encoding = "utf-8"))
1423
+ );
1424
+ expect(projs.length).toEqual(2);
1425
+ expect(projs[0]).toEqual("java-maven-lib");
1426
+ });
1427
+
1428
+ test("parse helm charts", async () => {
1429
+ let dep_list = await utils.parseHelmYamlData(
1430
+ fs.readFileSync("./test/data/Chart.yaml", (encoding = "utf-8"))
1431
+ );
1432
+ expect(dep_list.length).toEqual(3);
1433
+ expect(dep_list[0]).toEqual({
1434
+ name: "prometheus",
1435
+ version: "16.0.0",
1436
+ description: "Prometheus is a monitoring system and time series database.",
1437
+ homepage: {
1438
+ url: "https://prometheus.io/"
1439
+ }
1440
+ });
1441
+ dep_list = await utils.parseHelmYamlData(
1442
+ fs.readFileSync(
1443
+ "./test/data/prometheus-community-index.yaml",
1444
+ (encoding = "utf-8")
1445
+ )
1446
+ );
1447
+ expect(dep_list.length).toEqual(1836);
1448
+ expect(dep_list[0]).toEqual({
1449
+ name: "alertmanager",
1450
+ version: "0.22.0",
1451
+ description:
1452
+ "The Alertmanager handles alerts sent by client applications such as the Prometheus server.",
1453
+ homepage: { url: "https://prometheus.io/" },
1454
+ _integrity:
1455
+ "sha256-c8ece226669d90fa56a3424fa789b80a10de2cd458cd93141b8e445e26c6054d",
1456
+ repository: { url: "https://github.com/prometheus/alertmanager" }
1457
+ });
1458
+ });
1459
+
1460
+ test("parse container spec like files", async () => {
1461
+ let dep_list = await utils.parseContainerSpecData(
1462
+ fs.readFileSync("./test/data/docker-compose.yml", (encoding = "utf-8"))
1463
+ );
1464
+ expect(dep_list.length).toEqual(4);
1465
+ dep_list = await utils.parseContainerSpecData(
1466
+ fs.readFileSync("./test/data/docker-compose-ng.yml", (encoding = "utf-8"))
1467
+ );
1468
+ expect(dep_list.length).toEqual(8);
1469
+ expect(dep_list[0]).toEqual({
1470
+ service: "frontend"
1471
+ });
1472
+ dep_list = await utils.parseContainerSpecData(
1473
+ fs.readFileSync("./test/data/docker-compose-cr.yml", (encoding = "utf-8"))
1474
+ );
1475
+ expect(dep_list.length).toEqual(14);
1476
+ expect(dep_list[0]).toEqual({
1477
+ service: "crapi-identity"
1478
+ });
1479
+ dep_list = await utils.parseContainerSpecData(
1480
+ fs.readFileSync("./test/data/tekton-task.yml", (encoding = "utf-8"))
1481
+ );
1482
+ expect(dep_list.length).toEqual(2);
1483
+ expect(dep_list[0]).toEqual({
1484
+ image:
1485
+ "docker.io/amazon/aws-cli:2.0.52@sha256:1506cec98a7101c935176d440a14302ea528b8f92fcaf4a6f1ea2d7ecef7edc4"
1486
+ });
1487
+ dep_list = await utils.parseContainerSpecData(
1488
+ fs.readFileSync("./test/data/postgrescluster.yaml", (encoding = "utf-8"))
1489
+ );
1490
+ expect(dep_list.length).toEqual(6);
1491
+ expect(dep_list[0]).toEqual({
1492
+ image:
1493
+ "registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi8-14.5-1"
1494
+ });
1495
+ dep_list = await utils.parseContainerSpecData(
1496
+ fs.readFileSync("./test/data/deployment.yaml", (encoding = "utf-8"))
1497
+ );
1498
+ expect(dep_list.length).toEqual(2);
1499
+ expect(dep_list[0]).toEqual({
1500
+ image: "node-typescript-example"
1501
+ });
1502
+ dep_list = await utils.parseContainerSpecData(
1503
+ fs.readFileSync("./test/data/skaffold.yaml", (encoding = "utf-8"))
1504
+ );
1505
+ expect(dep_list.length).toEqual(6);
1506
+ expect(dep_list[0]).toEqual({
1507
+ image: "leeroy-web"
1508
+ });
1509
+ dep_list = await utils.parseContainerSpecData(
1510
+ fs.readFileSync("./test/data/skaffold-ms.yaml", (encoding = "utf-8"))
1511
+ );
1512
+ expect(dep_list.length).toEqual(22);
1513
+ expect(dep_list[0]).toEqual({
1514
+ image: "emailservice"
1515
+ });
1516
+ dep_list = await utils.parseContainerSpecData(
1517
+ fs.readFileSync("./test/data/emailservice.yaml", (encoding = "utf-8"))
1518
+ );
1519
+ expect(dep_list.length).toEqual(2);
1520
+ expect(dep_list[0]).toEqual({
1521
+ image: "emailservice"
1522
+ });
1523
+ dep_list = await utils.parseContainerSpecData(
1524
+ fs.readFileSync("./test/data/redis.yaml", (encoding = "utf-8"))
1525
+ );
1526
+ expect(dep_list.length).toEqual(2);
1527
+ expect(dep_list[0]).toEqual({
1528
+ image: "redis:alpine"
1529
+ });
1530
+ dep_list = await utils.parseContainerSpecData(
1531
+ fs.readFileSync("./test/data/adservice.yaml", (encoding = "utf-8"))
1532
+ );
1533
+ expect(dep_list.length).toEqual(2);
1534
+ expect(dep_list[0]).toEqual({
1535
+ image: "gcr.io/google-samples/microservices-demo/adservice:v0.4.1"
1536
+ });
1537
+ dep_list = await utils.parseContainerSpecData(
1538
+ fs.readFileSync("./test/data/kustomization.yaml", (encoding = "utf-8"))
1539
+ );
1540
+ expect(dep_list.length).toEqual(22);
1541
+ expect(dep_list[0]).toEqual({
1542
+ image: "gcr.io/google-samples/microservices-demo/adservice"
1543
+ });
1544
+ });
1545
+
1546
+ test("parse cloudbuild data", async () => {
1547
+ expect(await utils.parseCloudBuildData(null)).toEqual([]);
1548
+ dep_list = await utils.parseCloudBuildData(
1549
+ fs.readFileSync("./test/data/cloudbuild.yaml", (encoding = "utf-8"))
1550
+ );
1551
+ expect(dep_list.length).toEqual(1);
1552
+ expect(dep_list[0]).toEqual({
1553
+ group: "gcr.io/k8s-skaffold",
1554
+ name: "skaffold",
1555
+ version: "v2.0.1"
1556
+ });
1557
+ });
1558
+
1559
+ test("parse privado files", () => {
1560
+ let servList = utils.parsePrivadoFile("./test/data/privado.json");
1561
+ expect(servList.length).toEqual(1);
1562
+ expect(servList[0].data.length).toEqual(11);
1563
+ expect(servList[0].endpoints.length).toEqual(17);
1564
+ expect(servList[0].properties.length).toEqual(5);
1565
+ });
1566
+
1567
+ test("parse openapi spec files", async () => {
1568
+ let aservice = await utils.parseOpenapiSpecData(
1569
+ fs.readFileSync(
1570
+ "./test/data/openapi/openapi-spec.json",
1571
+ (encoding = "utf-8")
1572
+ )
1573
+ );
1574
+ expect(aservice.length).toEqual(1);
1575
+ expect(aservice[0]).toEqual({
1576
+ "bom-ref": "urn:service:OWASP-crAPI-API:1-oas3",
1577
+ name: "OWASP-crAPI-API",
1578
+ description: "",
1579
+ version: "1-oas3",
1580
+ endpoints: [
1581
+ "http://localhost:8888/identity/api/auth/signup",
1582
+ "http://localhost:8888/identity/api/auth/login",
1583
+ "http://localhost:8888/identity/api/auth/forget-password",
1584
+ "http://localhost:8888/identity/api/auth/v3/check-otp",
1585
+ "http://localhost:8888/identity/api/auth/v2/check-otp",
1586
+ "http://localhost:8888/identity/api/auth/v4.0/user/login-with-token",
1587
+ "http://localhost:8888/identity/api/auth/v2.7/user/login-with-token",
1588
+ "http://localhost:8888/identity/api/v2/user/reset-password",
1589
+ "http://localhost:8888/identity/api/v2/user/change-email",
1590
+ "http://localhost:8888/identity/api/v2/user/verify-email-token",
1591
+ "http://localhost:8888/identity/api/v2/user/dashboard",
1592
+ "http://localhost:8888/identity/api/v2/user/pictures",
1593
+ "http://localhost:8888/identity/api/v2/user/videos",
1594
+ "http://localhost:8888/identity/api/v2/user/videos/{video_id}",
1595
+ "http://localhost:8888/identity/api/v2/user/videos/convert_video",
1596
+ "http://localhost:8888/identity/api/v2/admin/videos/{video_id}",
1597
+ "http://localhost:8888/identity/api/v2/vehicle/vehicles",
1598
+ "http://localhost:8888/identity/api/v2/vehicle/add_vehicle",
1599
+ "http://localhost:8888/identity/api/v2/vehicle/{vehicleId}/location",
1600
+ "http://localhost:8888/identity/api/v2/vehicle/resend_email",
1601
+ "http://localhost:8888/community/api/v2/community/posts/{postId}",
1602
+ "http://localhost:8888/community/api/v2/community/posts",
1603
+ "http://localhost:8888/community/api/v2/community/posts/{postId}/comment",
1604
+ "http://localhost:8888/community/api/v2/community/posts/recent",
1605
+ "http://localhost:8888/community/api/v2/coupon/new-coupon",
1606
+ "http://localhost:8888/community/api/v2/coupon/validate-coupon",
1607
+ "http://localhost:8888/workshop/api/shop/products",
1608
+ "http://localhost:8888/workshop/api/shop/orders",
1609
+ "http://localhost:8888/workshop/api/shop/orders/{order_id}",
1610
+ "http://localhost:8888/workshop/api/shop/orders/all",
1611
+ "http://localhost:8888/workshop/api/shop/orders/return_order",
1612
+ "http://localhost:8888/workshop/api/shop/apply_coupon",
1613
+ "http://localhost:8888/workshop/api/shop/return_qr_code",
1614
+ "http://localhost:8888/workshop/api/mechanic/",
1615
+ "http://localhost:8888/workshop/api/merchant/contact_mechanic",
1616
+ "http://localhost:8888/workshop/api/mechanic/receive_report",
1617
+ "http://localhost:8888/workshop/api/mechanic/mechanic_report",
1618
+ "http://localhost:8888/workshop/api/mechanic/service_requests",
1619
+ "http://localhost:8888/workshop/api/mechanic/signup"
1620
+ ],
1621
+ authenticated: true
1622
+ });
1623
+ aservice = await utils.parseOpenapiSpecData(
1624
+ fs.readFileSync(
1625
+ "./test/data/openapi/openapi-oai.yaml",
1626
+ (encoding = "utf-8")
1627
+ )
1628
+ );
1629
+ expect(aservice.length).toEqual(1);
1630
+ expect(aservice[0]).toEqual({
1631
+ "bom-ref": "urn:service:OpenAI-API:1.1.0",
1632
+ name: "OpenAI-API",
1633
+ description: "",
1634
+ version: "1.1.0",
1635
+ endpoints: [
1636
+ "https://api.openai.com/v1/engines",
1637
+ "https://api.openai.com/v1/engines/{engine_id}",
1638
+ "https://api.openai.com/v1/completions",
1639
+ "https://api.openai.com/v1/edits",
1640
+ "https://api.openai.com/v1/images/generations",
1641
+ "https://api.openai.com/v1/images/edits",
1642
+ "https://api.openai.com/v1/images/variations",
1643
+ "https://api.openai.com/v1/embeddings",
1644
+ "https://api.openai.com/v1/engines/{engine_id}/search",
1645
+ "https://api.openai.com/v1/files",
1646
+ "https://api.openai.com/v1/files/{file_id}",
1647
+ "https://api.openai.com/v1/files/{file_id}/content",
1648
+ "https://api.openai.com/v1/answers",
1649
+ "https://api.openai.com/v1/classifications",
1650
+ "https://api.openai.com/v1/fine-tunes",
1651
+ "https://api.openai.com/v1/fine-tunes/{fine_tune_id}",
1652
+ "https://api.openai.com/v1/fine-tunes/{fine_tune_id}/cancel",
1653
+ "https://api.openai.com/v1/fine-tunes/{fine_tune_id}/events",
1654
+ "https://api.openai.com/v1/models",
1655
+ "https://api.openai.com/v1/models/{model}",
1656
+ "https://api.openai.com/v1/moderations"
1657
+ ],
1658
+ authenticated: false
1659
+ });
1660
+ });