@cyclonedx/cdxgen 9.9.1 → 9.9.3

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/evinser.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  collectMvnDependencies
8
8
  } from "./utils.js";
9
9
  import { tmpdir } from "node:os";
10
- import path, { basename } from "node:path";
10
+ import path from "node:path";
11
11
  import fs from "node:fs";
12
12
  import * as db from "./db.js";
13
13
  import { PackageURL } from "packageurl-js";
@@ -94,15 +94,30 @@ export const catalogMavenDeps = async (
94
94
  Namespaces,
95
95
  options = {}
96
96
  ) => {
97
- console.log("About to collect jar dependencies for the path", dirPath);
98
- const mavenCmd = getMavenCommand(dirPath, dirPath);
99
- // collect all jars including from the cache if data-flow mode is enabled
100
- const jarNSMapping = collectMvnDependencies(
101
- mavenCmd,
102
- dirPath,
103
- false,
104
- options.withDeepJarCollector
105
- );
97
+ let jarNSMapping = undefined;
98
+ if (fs.existsSync(path.join(dirPath, "bom.json.map"))) {
99
+ try {
100
+ const mapData = JSON.parse(
101
+ fs.readFileSync(path.join(dirPath, "bom.json.map"))
102
+ );
103
+ if (mapData && Object.keys(mapData).length) {
104
+ jarNSMapping = mapData;
105
+ }
106
+ } catch (err) {
107
+ // ignore
108
+ }
109
+ }
110
+ if (!jarNSMapping) {
111
+ console.log("About to collect jar dependencies for the path", dirPath);
112
+ const mavenCmd = getMavenCommand(dirPath, dirPath);
113
+ // collect all jars including from the cache if data-flow mode is enabled
114
+ jarNSMapping = collectMvnDependencies(
115
+ mavenCmd,
116
+ dirPath,
117
+ false,
118
+ options.withDeepJarCollector
119
+ );
120
+ }
106
121
  if (jarNSMapping) {
107
122
  for (const purl of Object.keys(jarNSMapping)) {
108
123
  purlsJars[purl] = jarNSMapping[purl].jarFile;
@@ -317,9 +332,6 @@ export const analyzeProject = async (dbObjMap, options) => {
317
332
  if (retMap && retMap.slicesFile && fs.existsSync(retMap.slicesFile)) {
318
333
  usageSlice = JSON.parse(fs.readFileSync(retMap.slicesFile, "utf-8"));
319
334
  usagesSlicesFile = retMap.slicesFile;
320
- console.log(
321
- `To speed up this step, cache ${usagesSlicesFile} and invoke evinse with the --usages-slices-file argument.`
322
- );
323
335
  }
324
336
  }
325
337
  if (usageSlice && Object.keys(usageSlice).length) {
@@ -349,9 +361,6 @@ export const analyzeProject = async (dbObjMap, options) => {
349
361
  if (retMap && retMap.slicesFile && fs.existsSync(retMap.slicesFile)) {
350
362
  dataFlowSlicesFile = retMap.slicesFile;
351
363
  dataFlowSlice = JSON.parse(fs.readFileSync(retMap.slicesFile, "utf-8"));
352
- console.log(
353
- `To speed up this step, cache ${dataFlowSlicesFile} and invoke evinse with the --data-flow-slices-file argument.`
354
- );
355
364
  }
356
365
  }
357
366
  }
@@ -381,9 +390,6 @@ export const analyzeProject = async (dbObjMap, options) => {
381
390
  reachablesSlice = JSON.parse(
382
391
  fs.readFileSync(retMap.slicesFile, "utf-8")
383
392
  );
384
- console.log(
385
- `To speed up this step, cache ${reachablesSlicesFile} and invoke evinse with the --reachables-slices-file argument.`
386
- );
387
393
  }
388
394
  }
389
395
  }
@@ -783,7 +789,7 @@ export const detectServicesFromUDT = (
783
789
  const endpoints = extractEndpoints(language, fields[0].name);
784
790
  let serviceName = "service";
785
791
  if (audt.fileName) {
786
- serviceName = `${basename(
792
+ serviceName = `${path.basename(
787
793
  audt.fileName.replace(".py", "")
788
794
  )}-service`;
789
795
  }