@cyclonedx/cdxgen 10.7.1 → 10.8.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/README.md +69 -90
- package/bin/cdxgen.js +37 -23
- package/bin/repl.js +10 -2
- package/binary.js +1 -0
- package/data/lic-mapping.json +6 -3
- package/display.js +32 -0
- package/docker.js +76 -10
- package/evinser.js +7 -4
- package/index.js +475 -449
- package/package.json +5 -5
- package/postgen.js +52 -0
- package/server.js +1 -1
- package/types/binary.d.ts.map +1 -1
- package/types/display.d.ts +1 -0
- package/types/display.d.ts.map +1 -1
- package/types/docker.d.ts +4 -0
- package/types/docker.d.ts.map +1 -1
- package/types/evinser.d.ts +1 -1
- package/types/evinser.d.ts.map +1 -1
- package/types/index.d.ts.map +1 -1
- package/types/postgen.d.ts +1 -0
- package/types/postgen.d.ts.map +1 -1
- package/types/utils.d.ts +38 -0
- package/types/utils.d.ts.map +1 -1
- package/utils.js +174 -17
- package/utils.test.js +203 -0
package/utils.test.js
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
getNugetMetadata,
|
|
14
14
|
getPyMetadata,
|
|
15
15
|
guessPypiMatchingVersion,
|
|
16
|
+
hasAnyProjectType,
|
|
16
17
|
isValidIriReference,
|
|
17
18
|
parseBazelActionGraph,
|
|
18
19
|
parseBazelBuild,
|
|
@@ -84,6 +85,7 @@ import {
|
|
|
84
85
|
parseSwiftResolved,
|
|
85
86
|
parseYarnLock,
|
|
86
87
|
readZipEntry,
|
|
88
|
+
splitOutputByGradleProjects,
|
|
87
89
|
yarnLockToIdentMap,
|
|
88
90
|
} from "./utils.js";
|
|
89
91
|
|
|
@@ -158,6 +160,64 @@ test("finds license id from name", () => {
|
|
|
158
160
|
);
|
|
159
161
|
});
|
|
160
162
|
|
|
163
|
+
test("splits parallel gradle properties output correctly", () => {
|
|
164
|
+
const parallelGradlePropertiesOutput = readFileSync(
|
|
165
|
+
"./test/gradle-prop-parallel.out",
|
|
166
|
+
{ encoding: "utf-8" },
|
|
167
|
+
);
|
|
168
|
+
const propOutputSplitBySubProject = splitOutputByGradleProjects(
|
|
169
|
+
parallelGradlePropertiesOutput,
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
expect(propOutputSplitBySubProject.size).toEqual(4);
|
|
173
|
+
expect(propOutputSplitBySubProject.has("dependency-diff-check")).toBe(true);
|
|
174
|
+
expect(propOutputSplitBySubProject.has("dependency-diff-check-service")).toBe(
|
|
175
|
+
true,
|
|
176
|
+
);
|
|
177
|
+
expect(
|
|
178
|
+
propOutputSplitBySubProject.has("dependency-diff-check-common-core"),
|
|
179
|
+
).toBe(true);
|
|
180
|
+
expect(
|
|
181
|
+
propOutputSplitBySubProject.has("dependency-diff-check-client-starter"),
|
|
182
|
+
).toBe(true);
|
|
183
|
+
|
|
184
|
+
const retMap = parseGradleProperties(
|
|
185
|
+
propOutputSplitBySubProject.get("dependency-diff-check"),
|
|
186
|
+
);
|
|
187
|
+
expect(retMap.rootProject).toEqual("dependency-diff-check");
|
|
188
|
+
expect(retMap.projects.length).toEqual(3);
|
|
189
|
+
expect(retMap.metadata.group).toEqual("com.ajmalab");
|
|
190
|
+
expect(retMap.metadata.version).toEqual("0.0.1-SNAPSHOT");
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
test("splits parallel gradle dependencies output correctly", () => {
|
|
194
|
+
const parallelGradleDepOutput = readFileSync(
|
|
195
|
+
"./test/gradle-dep-parallel.out",
|
|
196
|
+
{ encoding: "utf-8" },
|
|
197
|
+
);
|
|
198
|
+
const depOutputSplitBySubProject = splitOutputByGradleProjects(
|
|
199
|
+
parallelGradleDepOutput,
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
expect(depOutputSplitBySubProject.size).toEqual(4);
|
|
203
|
+
expect(depOutputSplitBySubProject.has("dependency-diff-check")).toBe(true);
|
|
204
|
+
expect(depOutputSplitBySubProject.has("dependency-diff-check-service")).toBe(
|
|
205
|
+
true,
|
|
206
|
+
);
|
|
207
|
+
expect(
|
|
208
|
+
depOutputSplitBySubProject.has("dependency-diff-check-common-core"),
|
|
209
|
+
).toBe(true);
|
|
210
|
+
expect(
|
|
211
|
+
depOutputSplitBySubProject.has("dependency-diff-check-client-starter"),
|
|
212
|
+
).toBe(true);
|
|
213
|
+
|
|
214
|
+
const retMap = parseGradleDep(
|
|
215
|
+
depOutputSplitBySubProject.get("dependency-diff-check"),
|
|
216
|
+
);
|
|
217
|
+
expect(retMap.pkgList.length).toEqual(12);
|
|
218
|
+
expect(retMap.dependenciesList.length).toEqual(13);
|
|
219
|
+
});
|
|
220
|
+
|
|
161
221
|
test("parse gradle dependencies", () => {
|
|
162
222
|
expect(parseGradleDep(null)).toEqual({});
|
|
163
223
|
let parsedList = parseGradleDep(
|
|
@@ -3369,6 +3429,23 @@ test("parse requirements.txt", async () => {
|
|
|
3369
3429
|
},
|
|
3370
3430
|
],
|
|
3371
3431
|
});
|
|
3432
|
+
deps = await parseReqFile(
|
|
3433
|
+
readFileSync("./test/data/requirements-lock.linux_py3.txt", {
|
|
3434
|
+
encoding: "utf-8",
|
|
3435
|
+
}),
|
|
3436
|
+
false,
|
|
3437
|
+
);
|
|
3438
|
+
expect(deps.length).toEqual(375);
|
|
3439
|
+
expect(deps[0]).toEqual({
|
|
3440
|
+
name: "adal",
|
|
3441
|
+
scope: undefined,
|
|
3442
|
+
version: "1.2.2",
|
|
3443
|
+
});
|
|
3444
|
+
expect(deps[deps.length - 1]).toEqual({
|
|
3445
|
+
name: "zipp",
|
|
3446
|
+
scope: undefined,
|
|
3447
|
+
version: "0.6.0",
|
|
3448
|
+
});
|
|
3372
3449
|
});
|
|
3373
3450
|
|
|
3374
3451
|
test("parse pyproject.toml", () => {
|
|
@@ -4186,3 +4263,129 @@ test.each([
|
|
|
4186
4263
|
])("isValidIriReference tests: %s", (url, isValid) => {
|
|
4187
4264
|
expect(isValidIriReference(url)).toBe(isValid);
|
|
4188
4265
|
});
|
|
4266
|
+
|
|
4267
|
+
test("hasAnyProjectType tests", () => {
|
|
4268
|
+
expect(
|
|
4269
|
+
hasAnyProjectType(["docker"], {
|
|
4270
|
+
projectType: [],
|
|
4271
|
+
excludeType: ["oci"],
|
|
4272
|
+
}),
|
|
4273
|
+
).toBeFalsy();
|
|
4274
|
+
expect(hasAnyProjectType([], {})).toBeTruthy();
|
|
4275
|
+
expect(hasAnyProjectType(["java"], { projectType: ["java"] })).toBeTruthy();
|
|
4276
|
+
expect(
|
|
4277
|
+
hasAnyProjectType(["java"], { projectType: ["java"], excludeType: [] }),
|
|
4278
|
+
).toBeTruthy();
|
|
4279
|
+
expect(hasAnyProjectType(["java"], { projectType: ["csharp"] })).toBeFalsy();
|
|
4280
|
+
expect(
|
|
4281
|
+
hasAnyProjectType(["java"], { projectType: ["csharp", "rust"] }),
|
|
4282
|
+
).toBeFalsy();
|
|
4283
|
+
expect(
|
|
4284
|
+
hasAnyProjectType(["rust"], { projectType: ["csharp", "rust"] }),
|
|
4285
|
+
).toBeTruthy();
|
|
4286
|
+
expect(
|
|
4287
|
+
hasAnyProjectType(["rust"], {
|
|
4288
|
+
projectType: ["csharp", "rust"],
|
|
4289
|
+
excludeType: [],
|
|
4290
|
+
}),
|
|
4291
|
+
).toBeTruthy();
|
|
4292
|
+
expect(
|
|
4293
|
+
hasAnyProjectType(["rust"], {
|
|
4294
|
+
projectType: ["csharp", "rust"],
|
|
4295
|
+
excludeType: ["rust"],
|
|
4296
|
+
}),
|
|
4297
|
+
).toBeFalsy();
|
|
4298
|
+
expect(
|
|
4299
|
+
hasAnyProjectType(["oci"], {
|
|
4300
|
+
projectType: ["java", "docker"],
|
|
4301
|
+
excludeType: ["dotnet"],
|
|
4302
|
+
}),
|
|
4303
|
+
).toBeTruthy();
|
|
4304
|
+
expect(
|
|
4305
|
+
hasAnyProjectType(["oci"], {
|
|
4306
|
+
projectType: ["docker"],
|
|
4307
|
+
excludeType: undefined,
|
|
4308
|
+
}),
|
|
4309
|
+
).toBeTruthy();
|
|
4310
|
+
expect(
|
|
4311
|
+
hasAnyProjectType(["docker"], {
|
|
4312
|
+
projectType: ["oci"],
|
|
4313
|
+
excludeType: undefined,
|
|
4314
|
+
}),
|
|
4315
|
+
).toBeTruthy();
|
|
4316
|
+
|
|
4317
|
+
expect(
|
|
4318
|
+
hasAnyProjectType(["js"], {
|
|
4319
|
+
projectType: [],
|
|
4320
|
+
excludeType: ["rust"],
|
|
4321
|
+
}),
|
|
4322
|
+
).toBeTruthy();
|
|
4323
|
+
expect(
|
|
4324
|
+
hasAnyProjectType(["js"], {
|
|
4325
|
+
projectType: undefined,
|
|
4326
|
+
excludeType: ["csharp"],
|
|
4327
|
+
}),
|
|
4328
|
+
).toBeTruthy();
|
|
4329
|
+
expect(
|
|
4330
|
+
hasAnyProjectType(["js", "docker"], {
|
|
4331
|
+
projectType: ["universal"],
|
|
4332
|
+
excludeType: ["csharp"],
|
|
4333
|
+
}),
|
|
4334
|
+
).toBeTruthy();
|
|
4335
|
+
expect(
|
|
4336
|
+
hasAnyProjectType(["rust"], {
|
|
4337
|
+
projectType: ["universal"],
|
|
4338
|
+
excludeType: ["docker"],
|
|
4339
|
+
}),
|
|
4340
|
+
).toBeTruthy();
|
|
4341
|
+
expect(
|
|
4342
|
+
hasAnyProjectType(["js", "docker"], {
|
|
4343
|
+
projectType: ["universal"],
|
|
4344
|
+
excludeType: ["csharp", "javascript"],
|
|
4345
|
+
}),
|
|
4346
|
+
).toBeFalsy();
|
|
4347
|
+
expect(
|
|
4348
|
+
hasAnyProjectType(["js", "docker"], {
|
|
4349
|
+
projectType: ["js", "docker"],
|
|
4350
|
+
excludeType: ["js", "docker"],
|
|
4351
|
+
}),
|
|
4352
|
+
).toBeFalsy();
|
|
4353
|
+
expect(
|
|
4354
|
+
hasAnyProjectType(["js"], {
|
|
4355
|
+
projectType: ["js"],
|
|
4356
|
+
excludeType: ["js"],
|
|
4357
|
+
}),
|
|
4358
|
+
).toBeFalsy();
|
|
4359
|
+
expect(
|
|
4360
|
+
hasAnyProjectType(
|
|
4361
|
+
["oci"],
|
|
4362
|
+
{
|
|
4363
|
+
projectType: [],
|
|
4364
|
+
excludeType: [],
|
|
4365
|
+
},
|
|
4366
|
+
false,
|
|
4367
|
+
),
|
|
4368
|
+
).toBeFalsy();
|
|
4369
|
+
expect(
|
|
4370
|
+
hasAnyProjectType(
|
|
4371
|
+
["oci", "docker"],
|
|
4372
|
+
{
|
|
4373
|
+
projectType: undefined,
|
|
4374
|
+
excludeType: undefined,
|
|
4375
|
+
},
|
|
4376
|
+
false,
|
|
4377
|
+
),
|
|
4378
|
+
).toBeFalsy();
|
|
4379
|
+
expect(
|
|
4380
|
+
hasAnyProjectType(["js", "docker"], {
|
|
4381
|
+
projectType: ["universal"],
|
|
4382
|
+
excludeType: [],
|
|
4383
|
+
}),
|
|
4384
|
+
).toBeTruthy();
|
|
4385
|
+
expect(
|
|
4386
|
+
hasAnyProjectType(["js"], {
|
|
4387
|
+
projectType: ["universal"],
|
|
4388
|
+
excludeType: ["js"],
|
|
4389
|
+
}),
|
|
4390
|
+
).toBeFalsy();
|
|
4391
|
+
});
|