@cyclonedx/cdxgen 12.1.5 → 12.2.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/README.md +51 -40
- package/bin/cdxgen.js +194 -97
- package/bin/evinse.js +4 -4
- package/bin/repl.js +1 -1
- package/bin/sign.js +102 -0
- package/bin/validate.js +233 -0
- package/bin/verify.js +69 -28
- package/data/queries.json +1 -1
- package/data/rules/ci-permissions.yaml +186 -0
- package/data/rules/dependency-sources.yaml +123 -0
- package/data/rules/package-integrity.yaml +135 -0
- package/data/rules/vscode-extensions.yaml +228 -0
- package/lib/cli/index.js +449 -429
- package/lib/cli/index.poku.js +117 -0
- package/lib/evinser/db.js +137 -0
- package/lib/{helpers → evinser}/db.poku.js +2 -6
- package/lib/evinser/evinser.js +2 -14
- package/lib/helpers/analyzer.js +606 -3
- package/lib/helpers/analyzer.poku.js +230 -0
- package/lib/helpers/bomSigner.js +312 -0
- package/lib/helpers/bomSigner.poku.js +156 -0
- package/lib/helpers/ciParsers/azurePipelines.js +295 -0
- package/lib/helpers/ciParsers/azurePipelines.poku.js +253 -0
- package/lib/helpers/ciParsers/circleCi.js +286 -0
- package/lib/helpers/ciParsers/circleCi.poku.js +230 -0
- package/lib/helpers/ciParsers/common.js +24 -0
- package/lib/helpers/ciParsers/githubActions.js +636 -0
- package/lib/helpers/ciParsers/githubActions.poku.js +802 -0
- package/lib/helpers/ciParsers/gitlabCi.js +213 -0
- package/lib/helpers/ciParsers/gitlabCi.poku.js +247 -0
- package/lib/helpers/ciParsers/jenkins.js +181 -0
- package/lib/helpers/ciParsers/jenkins.poku.js +197 -0
- package/lib/helpers/depsUtils.js +219 -0
- package/lib/helpers/depsUtils.poku.js +207 -0
- package/lib/helpers/display.js +426 -5
- package/lib/helpers/envcontext.js +18 -3
- package/lib/helpers/formulationParsers.js +351 -0
- package/lib/helpers/logger.js +14 -0
- package/lib/helpers/protobom.js +9 -9
- package/lib/helpers/pythonutils.js +9 -0
- package/lib/helpers/remote/dependency-track.js +84 -0
- package/lib/helpers/remote/dependency-track.poku.js +119 -0
- package/lib/helpers/table.js +384 -0
- package/lib/helpers/table.poku.js +186 -0
- package/lib/helpers/utils.js +865 -416
- package/lib/helpers/utils.poku.js +172 -265
- package/lib/helpers/versutils.js +202 -0
- package/lib/helpers/versutils.poku.js +315 -0
- package/lib/helpers/vsixutils.js +1061 -0
- package/lib/helpers/vsixutils.poku.js +2247 -0
- package/lib/managers/binary.js +19 -19
- package/lib/managers/docker.js +108 -1
- package/lib/managers/oci.js +10 -0
- package/lib/managers/piptree.js +3 -9
- package/lib/parsers/npmrc.js +17 -13
- package/lib/parsers/npmrc.poku.js +41 -5
- package/lib/server/openapi.yaml +34 -1
- package/lib/server/server.js +50 -13
- package/lib/server/server.poku.js +332 -144
- package/lib/stages/postgen/annotator.js +1 -1
- package/lib/stages/postgen/auditBom.js +196 -0
- package/lib/stages/postgen/auditBom.poku.js +378 -0
- package/lib/stages/postgen/postgen.js +54 -1
- package/lib/stages/postgen/postgen.poku.js +90 -1
- package/lib/stages/postgen/ruleEngine.js +369 -0
- package/lib/stages/pregen/envAudit.js +299 -0
- package/lib/stages/pregen/envAudit.poku.js +572 -0
- package/lib/stages/pregen/pregen.js +12 -8
- package/lib/{helpers/validator.js → validator/bomValidator.js} +107 -47
- package/lib/validator/complianceEngine.js +241 -0
- package/lib/validator/complianceEngine.poku.js +168 -0
- package/lib/validator/complianceRules.js +1610 -0
- package/lib/validator/complianceRules.poku.js +328 -0
- package/lib/validator/index.js +222 -0
- package/lib/validator/index.poku.js +144 -0
- package/lib/validator/reporters/annotations.js +121 -0
- package/lib/validator/reporters/console.js +149 -0
- package/lib/validator/reporters/index.js +41 -0
- package/lib/validator/reporters/json.js +37 -0
- package/lib/validator/reporters/sarif.js +184 -0
- package/lib/validator/reporters.poku.js +150 -0
- package/package.json +8 -9
- package/types/bin/sign.d.ts +3 -0
- package/types/bin/sign.d.ts.map +1 -0
- package/types/bin/validate.d.ts +3 -0
- package/types/bin/validate.d.ts.map +1 -0
- package/types/helpers/utils.d.ts +0 -1
- package/types/lib/cli/index.d.ts +49 -52
- package/types/lib/cli/index.d.ts.map +1 -1
- package/types/lib/evinser/db.d.ts +34 -0
- package/types/lib/evinser/db.d.ts.map +1 -0
- package/types/lib/evinser/evinser.d.ts +63 -16
- package/types/lib/evinser/evinser.d.ts.map +1 -1
- package/types/lib/helpers/analyzer.d.ts.map +1 -1
- package/types/lib/helpers/bomSigner.d.ts +27 -0
- package/types/lib/helpers/bomSigner.d.ts.map +1 -0
- package/types/lib/helpers/ciParsers/azurePipelines.d.ts +17 -0
- package/types/lib/helpers/ciParsers/azurePipelines.d.ts.map +1 -0
- package/types/lib/helpers/ciParsers/circleCi.d.ts +17 -0
- package/types/lib/helpers/ciParsers/circleCi.d.ts.map +1 -0
- package/types/lib/helpers/ciParsers/common.d.ts +11 -0
- package/types/lib/helpers/ciParsers/common.d.ts.map +1 -0
- package/types/lib/helpers/ciParsers/githubActions.d.ts +34 -0
- package/types/lib/helpers/ciParsers/githubActions.d.ts.map +1 -0
- package/types/lib/helpers/ciParsers/gitlabCi.d.ts +17 -0
- package/types/lib/helpers/ciParsers/gitlabCi.d.ts.map +1 -0
- package/types/lib/helpers/ciParsers/jenkins.d.ts +17 -0
- package/types/lib/helpers/ciParsers/jenkins.d.ts.map +1 -0
- package/types/lib/helpers/depsUtils.d.ts +21 -0
- package/types/lib/helpers/depsUtils.d.ts.map +1 -0
- package/types/lib/helpers/display.d.ts +111 -11
- package/types/lib/helpers/display.d.ts.map +1 -1
- package/types/lib/helpers/envcontext.d.ts +19 -7
- package/types/lib/helpers/envcontext.d.ts.map +1 -1
- package/types/lib/helpers/formulationParsers.d.ts +50 -0
- package/types/lib/helpers/formulationParsers.d.ts.map +1 -0
- package/types/lib/helpers/logger.d.ts +15 -1
- package/types/lib/helpers/logger.d.ts.map +1 -1
- package/types/lib/helpers/protobom.d.ts +2 -2
- package/types/lib/helpers/pythonutils.d.ts +10 -1
- package/types/lib/helpers/pythonutils.d.ts.map +1 -1
- package/types/lib/helpers/remote/dependency-track.d.ts +16 -0
- package/types/lib/helpers/remote/dependency-track.d.ts.map +1 -0
- package/types/lib/helpers/table.d.ts +6 -0
- package/types/lib/helpers/table.d.ts.map +1 -0
- package/types/lib/helpers/utils.d.ts +533 -128
- package/types/lib/helpers/utils.d.ts.map +1 -1
- package/types/lib/helpers/versutils.d.ts +8 -0
- package/types/lib/helpers/versutils.d.ts.map +1 -0
- package/types/lib/helpers/vsixutils.d.ts +130 -0
- package/types/lib/helpers/vsixutils.d.ts.map +1 -0
- package/types/lib/managers/docker.d.ts +12 -31
- package/types/lib/managers/docker.d.ts.map +1 -1
- package/types/lib/managers/oci.d.ts +11 -1
- package/types/lib/managers/oci.d.ts.map +1 -1
- package/types/lib/managers/piptree.d.ts.map +1 -1
- package/types/lib/parsers/npmrc.d.ts +4 -1
- package/types/lib/parsers/npmrc.d.ts.map +1 -1
- package/types/lib/server/server.d.ts +22 -2
- package/types/lib/server/server.d.ts.map +1 -1
- package/types/lib/stages/postgen/auditBom.d.ts +20 -0
- package/types/lib/stages/postgen/auditBom.d.ts.map +1 -0
- package/types/lib/stages/postgen/postgen.d.ts +8 -1
- package/types/lib/stages/postgen/postgen.d.ts.map +1 -1
- package/types/lib/stages/postgen/ruleEngine.d.ts +18 -0
- package/types/lib/stages/postgen/ruleEngine.d.ts.map +1 -0
- package/types/lib/stages/pregen/envAudit.d.ts +8 -0
- package/types/lib/stages/pregen/envAudit.d.ts.map +1 -0
- package/types/lib/stages/pregen/pregen.d.ts.map +1 -1
- package/types/lib/{helpers/validator.d.ts → validator/bomValidator.d.ts} +1 -1
- package/types/lib/validator/bomValidator.d.ts.map +1 -0
- package/types/lib/validator/complianceEngine.d.ts +66 -0
- package/types/lib/validator/complianceEngine.d.ts.map +1 -0
- package/types/lib/validator/complianceRules.d.ts +70 -0
- package/types/lib/validator/complianceRules.d.ts.map +1 -0
- package/types/lib/validator/index.d.ts +70 -0
- package/types/lib/validator/index.d.ts.map +1 -0
- package/types/lib/validator/reporters/annotations.d.ts +31 -0
- package/types/lib/validator/reporters/annotations.d.ts.map +1 -0
- package/types/lib/validator/reporters/console.d.ts +30 -0
- package/types/lib/validator/reporters/console.d.ts.map +1 -0
- package/types/lib/validator/reporters/index.d.ts +21 -0
- package/types/lib/validator/reporters/index.d.ts.map +1 -0
- package/types/lib/validator/reporters/json.d.ts +11 -0
- package/types/lib/validator/reporters/json.d.ts.map +1 -0
- package/types/lib/validator/reporters/sarif.d.ts +16 -0
- package/types/lib/validator/reporters/sarif.d.ts.map +1 -0
- package/lib/helpers/db.js +0 -162
- package/lib/stages/pregen/env-audit.js +0 -34
- package/lib/stages/pregen/env-audit.poku.js +0 -290
- package/types/helpers/db.d.ts +0 -35
- package/types/helpers/db.d.ts.map +0 -1
- package/types/lib/helpers/db.d.ts +0 -35
- package/types/lib/helpers/db.d.ts.map +0 -1
- package/types/lib/helpers/validator.d.ts.map +0 -1
- package/types/lib/stages/pregen/env-audit.d.ts +0 -2
- package/types/lib/stages/pregen/env-audit.d.ts.map +0 -1
- package/types/managers/binary.d.ts +0 -37
- package/types/managers/binary.d.ts.map +0 -1
- package/types/managers/docker.d.ts +0 -56
- package/types/managers/docker.d.ts.map +0 -1
- package/types/managers/oci.d.ts +0 -2
- package/types/managers/oci.d.ts.map +0 -1
- package/types/managers/piptree.d.ts +0 -2
- package/types/managers/piptree.d.ts.map +0 -1
- package/types/server/server.d.ts +0 -34
- package/types/server/server.d.ts.map +0 -1
- package/types/stages/postgen/annotator.d.ts +0 -27
- package/types/stages/postgen/annotator.d.ts.map +0 -1
- package/types/stages/postgen/postgen.d.ts +0 -51
- package/types/stages/postgen/postgen.d.ts.map +0 -1
- package/types/stages/pregen/pregen.d.ts +0 -59
- package/types/stages/pregen/pregen.d.ts.map +0 -1
package/lib/cli/index.poku.js
CHANGED
|
@@ -120,5 +120,122 @@ describe("CLI tests", () => {
|
|
|
120
120
|
assert.match(options.headers["user-agent"], /@CycloneDX\/cdxgen/);
|
|
121
121
|
assert.deepEqual(options.json, expectedRequestPayload);
|
|
122
122
|
});
|
|
123
|
+
|
|
124
|
+
it("should include parentName and parentVersion when parent project name and version are passed", async () => {
|
|
125
|
+
const fakeGotResponse = {
|
|
126
|
+
json: sinon.stub().resolves({ success: true }),
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const gotStub = sinon.stub().returns(fakeGotResponse);
|
|
130
|
+
gotStub.extend = sinon.stub().returns(gotStub);
|
|
131
|
+
|
|
132
|
+
const { submitBom } = await esmock("./index.js", {
|
|
133
|
+
got: { default: gotStub },
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const serverUrl = "https://dtrack.example.com";
|
|
137
|
+
const projectName = "cdxgen-test-project";
|
|
138
|
+
const projectVersion = "2.0.0";
|
|
139
|
+
const parentProjectName = "parent-project";
|
|
140
|
+
const parentProjectVersion = "1.0.0";
|
|
141
|
+
const bomContent = {
|
|
142
|
+
bom: "test3",
|
|
143
|
+
};
|
|
144
|
+
const apiKey = "TEST_API_KEY";
|
|
145
|
+
const skipDtTlsCheck = false;
|
|
146
|
+
|
|
147
|
+
const expectedRequestPayload = {
|
|
148
|
+
autoCreate: "true",
|
|
149
|
+
bom: "eyJib20iOiJ0ZXN0MyJ9", // stringified and base64 encoded bomContent
|
|
150
|
+
parentName: parentProjectName,
|
|
151
|
+
parentVersion: parentProjectVersion,
|
|
152
|
+
projectName,
|
|
153
|
+
projectVersion,
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
await submitBom(
|
|
157
|
+
{
|
|
158
|
+
serverUrl,
|
|
159
|
+
projectName,
|
|
160
|
+
projectVersion,
|
|
161
|
+
parentProjectName,
|
|
162
|
+
parentProjectVersion,
|
|
163
|
+
apiKey,
|
|
164
|
+
skipDtTlsCheck,
|
|
165
|
+
},
|
|
166
|
+
bomContent,
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
sinon.assert.calledOnce(gotStub);
|
|
170
|
+
const [calledUrl, options] = gotStub.firstCall.args;
|
|
171
|
+
|
|
172
|
+
assert.equal(calledUrl, `${serverUrl}/api/v1/bom`);
|
|
173
|
+
assert.equal(options.method, "PUT");
|
|
174
|
+
assert.equal(options.https.rejectUnauthorized, !skipDtTlsCheck);
|
|
175
|
+
assert.equal(options.headers["X-Api-Key"], apiKey);
|
|
176
|
+
assert.match(options.headers["user-agent"], /@CycloneDX\/cdxgen/);
|
|
177
|
+
assert.deepEqual(options.json, expectedRequestPayload);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it("should include configurable autoCreate and isLatest values in payload", async () => {
|
|
181
|
+
const fakeGotResponse = {
|
|
182
|
+
json: sinon.stub().resolves({ success: true }),
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
const gotStub = sinon.stub().returns(fakeGotResponse);
|
|
186
|
+
gotStub.extend = sinon.stub().returns(gotStub);
|
|
187
|
+
|
|
188
|
+
const { submitBom } = await esmock("./index.js", {
|
|
189
|
+
got: { default: gotStub },
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
const serverUrl = "https://dtrack.example.com";
|
|
193
|
+
const projectName = "cdxgen-test-project";
|
|
194
|
+
const apiKey = "TEST_API_KEY";
|
|
195
|
+
|
|
196
|
+
await submitBom(
|
|
197
|
+
{
|
|
198
|
+
serverUrl,
|
|
199
|
+
projectName,
|
|
200
|
+
apiKey,
|
|
201
|
+
autoCreate: false,
|
|
202
|
+
isLatest: true,
|
|
203
|
+
},
|
|
204
|
+
{ bom: "test4" },
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
sinon.assert.calledOnce(gotStub);
|
|
208
|
+
const [_calledUrl, options] = gotStub.firstCall.args;
|
|
209
|
+
assert.equal(options.json.autoCreate, "false");
|
|
210
|
+
assert.equal(options.json.isLatest, true);
|
|
211
|
+
assert.equal(options.json.projectVersion, "main");
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it("should reject invalid mixed parent modes before making network request", async () => {
|
|
215
|
+
const fakeGotResponse = {
|
|
216
|
+
json: sinon.stub().resolves({ success: true }),
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
const gotStub = sinon.stub().returns(fakeGotResponse);
|
|
220
|
+
gotStub.extend = sinon.stub().returns(gotStub);
|
|
221
|
+
|
|
222
|
+
const { submitBom } = await esmock("./index.js", {
|
|
223
|
+
got: { default: gotStub },
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
const response = await submitBom(
|
|
227
|
+
{
|
|
228
|
+
serverUrl: "https://dtrack.example.com",
|
|
229
|
+
projectName: "cdxgen-test-project",
|
|
230
|
+
parentProjectId: "5103b8b4-4ca3-46ea-8051-036a3b2ab17e",
|
|
231
|
+
parentProjectName: "parent",
|
|
232
|
+
parentProjectVersion: "1.0.0",
|
|
233
|
+
},
|
|
234
|
+
{ bom: "test5" },
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
assert.equal(response, undefined);
|
|
238
|
+
sinon.assert.notCalled(gotStub);
|
|
239
|
+
});
|
|
123
240
|
});
|
|
124
241
|
});
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
class Model {
|
|
2
|
+
constructor(tableName) {
|
|
3
|
+
this.tableName = tableName;
|
|
4
|
+
this.store = new Map();
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
async init() {
|
|
8
|
+
this.store.clear();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async findByPk(purl) {
|
|
12
|
+
if (this.store.has(purl)) {
|
|
13
|
+
const record = this.store.get(purl);
|
|
14
|
+
let parsedData;
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
parsedData = JSON.parse(record.dataStr);
|
|
18
|
+
} catch (_e) {
|
|
19
|
+
parsedData = record.dataStr;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
purl: record.purl,
|
|
24
|
+
data: parsedData,
|
|
25
|
+
createdAt: record.createdAt,
|
|
26
|
+
updatedAt: record.updatedAt,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async findOrCreate(options) {
|
|
34
|
+
const { where, defaults } = options;
|
|
35
|
+
const existing = await this.findByPk(where.purl);
|
|
36
|
+
|
|
37
|
+
if (existing) {
|
|
38
|
+
return [existing, false];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
let dataStr;
|
|
42
|
+
if (typeof defaults.data === "string") {
|
|
43
|
+
dataStr = defaults.data;
|
|
44
|
+
} else {
|
|
45
|
+
dataStr = JSON.stringify(defaults.data);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const now = new Date().toISOString();
|
|
49
|
+
const searchStr = dataStr.toLowerCase();
|
|
50
|
+
|
|
51
|
+
const record = {
|
|
52
|
+
purl: defaults.purl,
|
|
53
|
+
dataStr: dataStr,
|
|
54
|
+
searchStr: searchStr,
|
|
55
|
+
createdAt: now,
|
|
56
|
+
updatedAt: now,
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
this.store.set(defaults.purl, record);
|
|
60
|
+
|
|
61
|
+
let parsedData;
|
|
62
|
+
try {
|
|
63
|
+
parsedData = JSON.parse(record.dataStr);
|
|
64
|
+
} catch (_e) {
|
|
65
|
+
parsedData = record.dataStr;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const instance = {
|
|
69
|
+
purl: record.purl,
|
|
70
|
+
data: parsedData,
|
|
71
|
+
createdAt: record.createdAt,
|
|
72
|
+
updatedAt: record.updatedAt,
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
return [instance, true];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async findAll(options) {
|
|
79
|
+
const results = [];
|
|
80
|
+
let searchTerm = null;
|
|
81
|
+
|
|
82
|
+
if (options?.where?.data?.like) {
|
|
83
|
+
searchTerm = options.where.data.like.replace(/%/g, "").toLowerCase();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
for (const record of this.store.values()) {
|
|
87
|
+
let matches = true;
|
|
88
|
+
|
|
89
|
+
if (searchTerm) {
|
|
90
|
+
if (!record.searchStr.includes(searchTerm)) {
|
|
91
|
+
matches = false;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (matches) {
|
|
96
|
+
let parsedData;
|
|
97
|
+
try {
|
|
98
|
+
parsedData = JSON.parse(record.dataStr);
|
|
99
|
+
} catch (_e) {
|
|
100
|
+
parsedData = record.dataStr;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
results.push({
|
|
104
|
+
purl: record.purl,
|
|
105
|
+
data: parsedData,
|
|
106
|
+
createdAt: record.createdAt,
|
|
107
|
+
updatedAt: record.updatedAt,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return results;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export const createOrLoad = async () => {
|
|
117
|
+
const Namespaces = new Model("Namespaces");
|
|
118
|
+
const Usages = new Model("Usages");
|
|
119
|
+
const DataFlows = new Model("DataFlows");
|
|
120
|
+
|
|
121
|
+
await Namespaces.init();
|
|
122
|
+
await Usages.init();
|
|
123
|
+
await DataFlows.init();
|
|
124
|
+
|
|
125
|
+
const sequelize = {
|
|
126
|
+
close: () => {
|
|
127
|
+
return true;
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
return {
|
|
132
|
+
sequelize,
|
|
133
|
+
Namespaces,
|
|
134
|
+
Usages,
|
|
135
|
+
DataFlows,
|
|
136
|
+
};
|
|
137
|
+
};
|
|
@@ -2,12 +2,8 @@ import { assert, describe, test } from "poku";
|
|
|
2
2
|
|
|
3
3
|
import { createOrLoad } from "./db.js";
|
|
4
4
|
|
|
5
|
-
describe("
|
|
6
|
-
const { sequelize, Namespaces } = await createOrLoad(
|
|
7
|
-
"test.db",
|
|
8
|
-
":memory:",
|
|
9
|
-
false,
|
|
10
|
-
);
|
|
5
|
+
describe("In-Memory DB Helper Tests", async () => {
|
|
6
|
+
const { sequelize, Namespaces } = await createOrLoad();
|
|
11
7
|
|
|
12
8
|
await test("Model Initialization", () => {
|
|
13
9
|
assert.ok(sequelize, "Database instance should exist");
|
package/lib/evinser/evinser.js
CHANGED
|
@@ -5,7 +5,6 @@ import process from "node:process";
|
|
|
5
5
|
import { PackageURL } from "packageurl-js";
|
|
6
6
|
|
|
7
7
|
import { findCryptoAlgos } from "../helpers/cbomutils.js";
|
|
8
|
-
import * as db from "../helpers/db.js";
|
|
9
8
|
import {
|
|
10
9
|
collectGradleDependencies,
|
|
11
10
|
collectMvnDependencies,
|
|
@@ -18,13 +17,12 @@ import {
|
|
|
18
17
|
getTmpDir,
|
|
19
18
|
PROJECT_TYPE_ALIASES,
|
|
20
19
|
safeExistsSync,
|
|
21
|
-
safeMkdirSync,
|
|
22
20
|
} from "../helpers/utils.js";
|
|
23
21
|
import { postProcess } from "../stages/postgen/postgen.js";
|
|
22
|
+
import { createOrLoad } from "./db.js";
|
|
24
23
|
import { findPurlLocations } from "./scalasem.js";
|
|
25
24
|
import { createSemanticsSlices } from "./swiftsem.js";
|
|
26
25
|
|
|
27
|
-
const DB_NAME = "evinser.db";
|
|
28
26
|
const typePurlsCache = {};
|
|
29
27
|
|
|
30
28
|
/**
|
|
@@ -33,13 +31,6 @@ const typePurlsCache = {};
|
|
|
33
31
|
* @param {Object} options Command line options
|
|
34
32
|
*/
|
|
35
33
|
export async function prepareDB(options) {
|
|
36
|
-
if (!options.dbPath.includes("memory") && !safeExistsSync(options.dbPath)) {
|
|
37
|
-
try {
|
|
38
|
-
safeMkdirSync(options.dbPath, { recursive: true });
|
|
39
|
-
} catch (_e) {
|
|
40
|
-
// ignore
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
34
|
const dirPath = options._[0] || ".";
|
|
44
35
|
const bomJsonFile = options.input;
|
|
45
36
|
if (!safeExistsSync(bomJsonFile)) {
|
|
@@ -61,10 +52,7 @@ export async function prepareDB(options) {
|
|
|
61
52
|
process.exit(0);
|
|
62
53
|
}
|
|
63
54
|
const components = bomJson.components || [];
|
|
64
|
-
const { sequelize, Namespaces, Usages, DataFlows } = await
|
|
65
|
-
DB_NAME,
|
|
66
|
-
options.dbPath,
|
|
67
|
-
);
|
|
55
|
+
const { sequelize, Namespaces, Usages, DataFlows } = await createOrLoad();
|
|
68
56
|
let hasMavenPkgs = false;
|
|
69
57
|
// We need to slice only non-maven packages
|
|
70
58
|
const purlsToSlice = {};
|