@dxworks/depinder 0.1.5 → 0.2.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/dist/commands/extractFrameworkVersion.d.ts +2 -0
- package/dist/commands/extractFrameworkVersion.js +238 -0
- package/dist/commands/extractFrameworkVersion.js.map +1 -0
- package/dist/commands/transformBlackDuckReports.d.ts +11 -0
- package/dist/commands/transformBlackDuckReports.js +481 -0
- package/dist/commands/transformBlackDuckReports.js.map +1 -0
- package/dist/depinder.js +5 -1
- package/dist/depinder.js.map +1 -1
- package/dist/plugins/javascript/index.js +108 -15
- package/dist/plugins/javascript/index.js.map +1 -1
- package/dist/utils/npm.d.ts +1 -0
- package/dist/utils/projectMapping.d.ts +41 -0
- package/dist/utils/projectMapping.js +301 -0
- package/dist/utils/projectMapping.js.map +1 -0
- package/package.json +5 -6
|
@@ -64,7 +64,7 @@ function getParentLockFile(packageFile, maxDepth = 5) {
|
|
|
64
64
|
const parser = {
|
|
65
65
|
parseDependencyTree: parseLockFile,
|
|
66
66
|
};
|
|
67
|
-
function
|
|
67
|
+
function recursivelyTransformTreeDeps(tree, result) {
|
|
68
68
|
var _a;
|
|
69
69
|
const rootId = `${tree.name}@${tree.version}`;
|
|
70
70
|
Object.values((_a = tree.dependencies) !== null && _a !== void 0 ? _a : {}).forEach(dep => {
|
|
@@ -89,28 +89,121 @@ function recursivelyTransformDeps(tree, result) {
|
|
|
89
89
|
logging_1.log.warn(`Invalid version! ${e}`);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
|
|
92
|
+
recursivelyTransformTreeDeps(dep, result);
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
|
-
function
|
|
95
|
+
function transformGraphDepsFlat(rootId, dependencies, result) {
|
|
96
|
+
dependencies.forEach(dependency => {
|
|
97
|
+
const lastAt = dependency.nodeId.lastIndexOf('@');
|
|
98
|
+
const name = dependency.nodeId.slice(0, lastAt);
|
|
99
|
+
const version = dependency.nodeId.slice(lastAt + 1);
|
|
100
|
+
const id = `${name}@${version}`;
|
|
101
|
+
const cachedVersion = result.get(id);
|
|
102
|
+
if (cachedVersion) {
|
|
103
|
+
cachedVersion.requestedBy = [rootId, ...cachedVersion.requestedBy];
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
try {
|
|
107
|
+
const semver = new semver_1.SemVer(version !== null && version !== void 0 ? version : '', true);
|
|
108
|
+
result.set(id, {
|
|
109
|
+
id,
|
|
110
|
+
version: version,
|
|
111
|
+
name: name,
|
|
112
|
+
semver: semver,
|
|
113
|
+
requestedBy: [rootId],
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
catch (e) {
|
|
117
|
+
logging_1.log.warn(`Invalid version! ${e}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
dependency.deps.forEach((transitiveDep) => {
|
|
121
|
+
const lastAt = transitiveDep.nodeId.lastIndexOf('@');
|
|
122
|
+
const name = transitiveDep.nodeId.slice(0, lastAt);
|
|
123
|
+
const version = transitiveDep.nodeId.slice(lastAt + 1);
|
|
124
|
+
const id = `${name}@${version}`;
|
|
125
|
+
const cachedVersion = result.get(id);
|
|
126
|
+
if (cachedVersion) {
|
|
127
|
+
cachedVersion.requestedBy = [dependency.nodeId, ...cachedVersion.requestedBy];
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
try {
|
|
131
|
+
const semver = new semver_1.SemVer(version !== null && version !== void 0 ? version : '', true);
|
|
132
|
+
result.set(id, {
|
|
133
|
+
id,
|
|
134
|
+
version: version,
|
|
135
|
+
name: name,
|
|
136
|
+
semver: semver,
|
|
137
|
+
requestedBy: [dependency.nodeId],
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
catch (e) {
|
|
141
|
+
logging_1.log.warn(`Invalid version! ${e}`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
function transformTreeDeps(tree, root) {
|
|
96
148
|
logging_1.log.info(`Starting recursive transformation for ${root}`);
|
|
97
149
|
const result = new Map();
|
|
98
|
-
|
|
150
|
+
recursivelyTransformTreeDeps(tree, result);
|
|
151
|
+
logging_1.log.info(`End recursive transformation for ${root}.`);
|
|
152
|
+
return result;
|
|
153
|
+
}
|
|
154
|
+
function transformGraphDeps(depGraphNodes, root) {
|
|
155
|
+
logging_1.log.info(`Starting recursive transformation for ${root}`);
|
|
156
|
+
const result = new Map();
|
|
157
|
+
transformGraphDepsFlat(depGraphNodes[0].pkgId, depGraphNodes, result);
|
|
99
158
|
logging_1.log.info(`End recursive transformation for ${root}.`);
|
|
100
159
|
return result;
|
|
101
160
|
}
|
|
102
161
|
async function parseLockFile({ root, manifestFile, lockFile }) {
|
|
103
|
-
var _a, _b;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
162
|
+
var _a, _b, _c, _d;
|
|
163
|
+
const manifestFilePath = path_1.default.resolve(root, manifestFile !== null && manifestFile !== void 0 ? manifestFile : 'package.json');
|
|
164
|
+
const lockFilePath = path_1.default.resolve(root, lockFile);
|
|
165
|
+
const lockFileVersion = (0, snyk_nodejs_lockfile_parser_1.getLockfileVersionFromFile)(lockFilePath);
|
|
166
|
+
switch (lockFileVersion) {
|
|
167
|
+
case snyk_nodejs_lockfile_parser_1.NodeLockfileVersion.YarnLockV1:
|
|
168
|
+
case snyk_nodejs_lockfile_parser_1.NodeLockfileVersion.YarnLockV2:
|
|
169
|
+
case snyk_nodejs_lockfile_parser_1.NodeLockfileVersion.NpmLockV1: {
|
|
170
|
+
const result = await (0, snyk_nodejs_lockfile_parser_1.buildDepTreeFromFiles)(root, manifestFile !== null && manifestFile !== void 0 ? manifestFile : 'package.json', lockFile !== null && lockFile !== void 0 ? lockFile : '', true, false);
|
|
171
|
+
const manifestJSON = JSON.parse(fs_1.default.readFileSync(manifestFilePath, 'utf8'));
|
|
172
|
+
return {
|
|
173
|
+
path: manifestFilePath,
|
|
174
|
+
name: (_a = result.name) !== null && _a !== void 0 ? _a : manifestJSON.name,
|
|
175
|
+
version: (_b = result.version) !== null && _b !== void 0 ? _b : manifestJSON.version,
|
|
176
|
+
dependencies: Object.fromEntries(transformTreeDeps(result, root)),
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
case snyk_nodejs_lockfile_parser_1.NodeLockfileVersion.NpmLockV2:
|
|
180
|
+
case snyk_nodejs_lockfile_parser_1.NodeLockfileVersion.NpmLockV3: {
|
|
181
|
+
// const oldResult = await buildDepTreeFromFiles(root, manifestFile ?? 'package.json', lockFile ?? '', true, false)
|
|
182
|
+
const manifestFileContent = fs_1.default.readFileSync(manifestFilePath, 'utf8');
|
|
183
|
+
const lockFileContent = fs_1.default.readFileSync(lockFilePath, 'utf8');
|
|
184
|
+
const result = await (0, snyk_nodejs_lockfile_parser_1.parseNpmLockV2Project)(manifestFileContent, lockFileContent, {
|
|
185
|
+
includeDevDeps: true,
|
|
186
|
+
strictOutOfSync: false,
|
|
187
|
+
includeOptionalDeps: false,
|
|
188
|
+
pruneCycles: true,
|
|
189
|
+
includePeerDeps: false,
|
|
190
|
+
pruneNpmStrictOutOfSync: false
|
|
191
|
+
});
|
|
192
|
+
const manifestJSON = JSON.parse(fs_1.default.readFileSync(manifestFilePath, 'utf8'));
|
|
193
|
+
return {
|
|
194
|
+
path: manifestFilePath,
|
|
195
|
+
name: (_c = result.rootPkg.name) !== null && _c !== void 0 ? _c : manifestJSON.name,
|
|
196
|
+
version: (_d = result.rootPkg.version) !== null && _d !== void 0 ? _d : manifestJSON.version,
|
|
197
|
+
dependencies: Object.fromEntries(transformGraphDeps(result.toJSON().graph.nodes, root)),
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
case snyk_nodejs_lockfile_parser_1.NodeLockfileVersion.PnpmLockV5:
|
|
201
|
+
case snyk_nodejs_lockfile_parser_1.NodeLockfileVersion.PnpmLockV6:
|
|
202
|
+
case snyk_nodejs_lockfile_parser_1.NodeLockfileVersion.PnpmLockV9:
|
|
203
|
+
default: {
|
|
204
|
+
throw new Error(`Lockfile version ${lockFileVersion} is not supported by Depinder. Please use npm v1 / v2 / v3 or yarn v1 / v2`);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
114
207
|
}
|
|
115
208
|
async function retrieveFromNpm(libraryName) {
|
|
116
209
|
const response = await (0, npm_registry_fetch_1.json)(libraryName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/javascript/index.ts"],"names":[],"mappings":";;;;;;AAOA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/javascript/index.ts"],"names":[],"mappings":";;;;;;AAOA,6EAKoC;AACpC,gDAAuB;AACvB,mCAA6B;AAG7B,2DAAuC;AAGvC,yCAAmC;AACnC,4CAAmB;AACnB,iDAAuC;AAGvC,MAAM,SAAS,GAAc;IACzB,KAAK,EAAE,CAAC,cAAc,EAAE,mBAAmB,EAAE,WAAW,CAAC;IACzD,cAAc,EAAE,KAAK,CAAC,EAAE;QACpB,MAAM,gBAAgB,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YACjH,IAAI,EAAE,cAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YACtB,QAAQ,EAAE,cAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC3B,YAAY,EAAE,cAAc;SACL,CAAA,CAAC,CAAA;QAE5B,MAAM,2BAA2B,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,cAAc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apping configuration
|
|
3
|
+
*/
|
|
4
|
+
export interface PathMapping {
|
|
5
|
+
extractedPath: string;
|
|
6
|
+
actualPath: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Map of extracted paths to actual paths
|
|
10
|
+
*/
|
|
11
|
+
export type PathMappings = Map<string, string>;
|
|
12
|
+
/**
|
|
13
|
+
* Interface representing a parsed project path
|
|
14
|
+
*/
|
|
15
|
+
export interface ProjectPathInfo {
|
|
16
|
+
projectPath: string;
|
|
17
|
+
verifiedPath: string;
|
|
18
|
+
projectPathExists?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Create path mappings from mapping data
|
|
22
|
+
* @param mappings Array of path mapping objects
|
|
23
|
+
* @returns Map of extracted paths to actual paths
|
|
24
|
+
*/
|
|
25
|
+
export declare function createPathMappings(mappings: PathMapping[]): PathMappings;
|
|
26
|
+
/**
|
|
27
|
+
* Verify if a project path exists on the file system
|
|
28
|
+
* @param projectPath The extracted project path
|
|
29
|
+
* @param basePath Base directory to check against
|
|
30
|
+
* @param pathMappings Optional path mappings to use for verification
|
|
31
|
+
* @returns Verified path information
|
|
32
|
+
*/
|
|
33
|
+
export declare function verifyProjectPath(projectPath: string, basePath: string, pathMappings?: PathMappings): ProjectPathInfo;
|
|
34
|
+
/**
|
|
35
|
+
* Extract project information from a dependency path based on origin type
|
|
36
|
+
* @param dependencyPath The path from the Black Duck report
|
|
37
|
+
* @param originName The origin name (e.g., npmjs, maven, nuget, pypi, sbt)
|
|
38
|
+
* @param basePath Optional base path to verify against
|
|
39
|
+
* @returns Object containing project path and verified path information
|
|
40
|
+
*/
|
|
41
|
+
export declare function extractProjectInfo(dependencyPath: string, originName: string, basePath?: string, pathMappings?: PathMappings): ProjectPathInfo;
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.extractProjectInfo = exports.verifyProjectPath = exports.createPathMappings = void 0;
|
|
27
|
+
/**
|
|
28
|
+
* Project mapping utilities for extracting project information from dependency paths
|
|
29
|
+
*/
|
|
30
|
+
const fs = __importStar(require("fs"));
|
|
31
|
+
const path = __importStar(require("path"));
|
|
32
|
+
const END_DELIMITERS = [
|
|
33
|
+
'-yarn',
|
|
34
|
+
'-npm',
|
|
35
|
+
'node_modules',
|
|
36
|
+
'-pip',
|
|
37
|
+
'-maven',
|
|
38
|
+
'-gradle',
|
|
39
|
+
'-nuget',
|
|
40
|
+
'-sbt',
|
|
41
|
+
'-cargo',
|
|
42
|
+
'-rubygems',
|
|
43
|
+
'-packagist',
|
|
44
|
+
'-cocoapods',
|
|
45
|
+
'-swift',
|
|
46
|
+
'-xcode',
|
|
47
|
+
'-go_mod',
|
|
48
|
+
'-setuptools',
|
|
49
|
+
'-pnpm',
|
|
50
|
+
'-uv'
|
|
51
|
+
];
|
|
52
|
+
// Special case pattern for monorepo
|
|
53
|
+
const MONOREPO_PATTERN = /packages[\\/]([^\\/]+)[\\/]local[\\/]([^\\/]+)[\\/]-yarn/;
|
|
54
|
+
/**
|
|
55
|
+
* Check if a segment contains a version-like pattern
|
|
56
|
+
* @param segment Path segment to check
|
|
57
|
+
* @returns True if the segment looks like a version
|
|
58
|
+
*/
|
|
59
|
+
function isVersionSegment(segment) {
|
|
60
|
+
return /^\d+\.\d+\.\d+(?:[-.][A-Za-z0-9]+)*-?$/i.test(segment) ||
|
|
61
|
+
/^REPLACE_BY_CI$/i.test(segment) ||
|
|
62
|
+
segment.toLowerCase() === 'unspecified';
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Check if a segment contains a file that should be excluded
|
|
66
|
+
* @param segment Path segment to check
|
|
67
|
+
* @returns True if the segment contains a file to exclude
|
|
68
|
+
*/
|
|
69
|
+
function isFileSegment(segment) {
|
|
70
|
+
return segment.toLowerCase().endsWith('.csproj') ||
|
|
71
|
+
segment.toLowerCase().endsWith('.props') ||
|
|
72
|
+
segment.toLowerCase() === 'pom.xml';
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Check if a segment is an organization/company prefix that should be skipped
|
|
76
|
+
* @param segment Path segment to check
|
|
77
|
+
* @returns True if the segment looks like an organization prefix
|
|
78
|
+
*/
|
|
79
|
+
function isOrganizationPrefix(segment) {
|
|
80
|
+
// Common organization prefixes like com.company, org.apache, etc.
|
|
81
|
+
return /^(com|org|net|edu|gov)\.[a-zA-Z0-9.-]+$/.test(segment);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Resolves a path with relative segments (.., .)
|
|
85
|
+
* @param pathSegments Array of path segments to resolve
|
|
86
|
+
* @returns Array of resolved path segments
|
|
87
|
+
*/
|
|
88
|
+
function resolveRelativePath(pathSegments) {
|
|
89
|
+
const result = [];
|
|
90
|
+
let skipCount = 0;
|
|
91
|
+
for (const segment of pathSegments) {
|
|
92
|
+
if (segment === '..') {
|
|
93
|
+
skipCount++;
|
|
94
|
+
}
|
|
95
|
+
else if (segment !== '.' && segment !== '') {
|
|
96
|
+
if (skipCount > 0) {
|
|
97
|
+
// This segment is skipped because of a '..'
|
|
98
|
+
skipCount--;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
result.push(segment);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Standardizes a path by normalizing slashes, colons, and removing leading/trailing slashes
|
|
109
|
+
* @param inputPath Path to standardize
|
|
110
|
+
* @returns Standardized path
|
|
111
|
+
*/
|
|
112
|
+
function standardizePath(inputPath) {
|
|
113
|
+
if (!inputPath) {
|
|
114
|
+
return '';
|
|
115
|
+
}
|
|
116
|
+
let normalizedPath = inputPath.replace(/\\/g, '/');
|
|
117
|
+
normalizedPath = normalizedPath.replace(/:/g, '/');
|
|
118
|
+
if (normalizedPath.startsWith('/')) {
|
|
119
|
+
normalizedPath = normalizedPath.substring(1);
|
|
120
|
+
}
|
|
121
|
+
if (normalizedPath.endsWith('/')) {
|
|
122
|
+
normalizedPath = normalizedPath.substring(0, normalizedPath.length - 1);
|
|
123
|
+
}
|
|
124
|
+
return normalizedPath;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Check if a path matches the monorepo pattern and extract the project path
|
|
128
|
+
* @param path Normalized path to check
|
|
129
|
+
* @returns Project path if monorepo pattern matches, null otherwise
|
|
130
|
+
*/
|
|
131
|
+
function handleMonorepoPattern(path) {
|
|
132
|
+
const matches = path.match(MONOREPO_PATTERN);
|
|
133
|
+
if (matches) {
|
|
134
|
+
return `${matches[2]}/packages/${matches[1]}`;
|
|
135
|
+
}
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Parse project path from dependency path
|
|
140
|
+
* @param dependencyPath The path from the Black Duck report
|
|
141
|
+
* @returns Extracted project path
|
|
142
|
+
*/
|
|
143
|
+
function parseProjectPath(dependencyPath) {
|
|
144
|
+
if (!dependencyPath) {
|
|
145
|
+
return '';
|
|
146
|
+
}
|
|
147
|
+
try {
|
|
148
|
+
const normalizedPath = standardizePath(dependencyPath);
|
|
149
|
+
const monorepoPath = handleMonorepoPattern(normalizedPath);
|
|
150
|
+
if (monorepoPath) {
|
|
151
|
+
return monorepoPath;
|
|
152
|
+
}
|
|
153
|
+
const segments = normalizedPath.split('/');
|
|
154
|
+
let endDelimiterIndex = getEndDelimiterIndex(segments);
|
|
155
|
+
if (endDelimiterIndex === -1) {
|
|
156
|
+
throw new Error(`No end delimiter found in path: ${normalizedPath}`);
|
|
157
|
+
}
|
|
158
|
+
let projectSegments = segments.slice(0, endDelimiterIndex);
|
|
159
|
+
if (projectSegments.length > 0 && isVersionSegment(projectSegments[projectSegments.length - 1])) {
|
|
160
|
+
projectSegments.pop(); // Remove the version segment
|
|
161
|
+
}
|
|
162
|
+
if (projectSegments.length > 0 && isFileSegment(projectSegments[projectSegments.length - 1])) {
|
|
163
|
+
projectSegments.pop(); // Remove the last segment if it's a file segment
|
|
164
|
+
}
|
|
165
|
+
let startIndex = getStartDelimiterIndex(projectSegments);
|
|
166
|
+
if (startIndex !== -1) {
|
|
167
|
+
projectSegments = projectSegments.slice(startIndex + 1);
|
|
168
|
+
}
|
|
169
|
+
const resolvedSegments = resolveRelativePath(projectSegments);
|
|
170
|
+
return resolvedSegments.join('/');
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
console.error(`Error parsing path: ${error}`);
|
|
174
|
+
throw error;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function getStartDelimiterIndex(projectSegments) {
|
|
178
|
+
let startIndex = -1;
|
|
179
|
+
for (let i = 0; i < projectSegments.length; i++) {
|
|
180
|
+
if (isVersionSegment(projectSegments[i])) {
|
|
181
|
+
startIndex = i;
|
|
182
|
+
break; // Stop after finding a version segment
|
|
183
|
+
}
|
|
184
|
+
else if (isOrganizationPrefix(projectSegments[i])) {
|
|
185
|
+
startIndex = i;
|
|
186
|
+
// Continue looking for version segments after organization prefix
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return startIndex;
|
|
190
|
+
}
|
|
191
|
+
function getEndDelimiterIndex(segments) {
|
|
192
|
+
let endDelimiterIndex = -1;
|
|
193
|
+
for (let i = 0; i < segments.length; i++) {
|
|
194
|
+
const lowerSegment = segments[i].toLowerCase();
|
|
195
|
+
if (END_DELIMITERS.some(delimiter => lowerSegment === delimiter)) {
|
|
196
|
+
endDelimiterIndex = i;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return endDelimiterIndex;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Create path mappings from mapping data
|
|
204
|
+
* @param mappings Array of path mapping objects
|
|
205
|
+
* @returns Map of extracted paths to actual paths
|
|
206
|
+
*/
|
|
207
|
+
function createPathMappings(mappings) {
|
|
208
|
+
const pathMappings = new Map();
|
|
209
|
+
for (const mapping of mappings) {
|
|
210
|
+
if (mapping.extractedPath && mapping.actualPath) {
|
|
211
|
+
pathMappings.set(mapping.extractedPath, mapping.actualPath);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return pathMappings;
|
|
215
|
+
}
|
|
216
|
+
exports.createPathMappings = createPathMappings;
|
|
217
|
+
/**
|
|
218
|
+
* Verify if a project path exists on the file system
|
|
219
|
+
* @param projectPath The extracted project path
|
|
220
|
+
* @param basePath Base directory to check against
|
|
221
|
+
* @param pathMappings Optional path mappings to use for verification
|
|
222
|
+
* @returns Verified path information
|
|
223
|
+
*/
|
|
224
|
+
function verifyProjectPath(projectPath, basePath, pathMappings) {
|
|
225
|
+
if (!projectPath || !basePath) {
|
|
226
|
+
return { projectPath, verifiedPath: '', projectPathExists: false };
|
|
227
|
+
}
|
|
228
|
+
try {
|
|
229
|
+
const fullPath = path.join(basePath, projectPath);
|
|
230
|
+
const originalExists = fs.existsSync(fullPath);
|
|
231
|
+
if (originalExists) {
|
|
232
|
+
return {
|
|
233
|
+
projectPath,
|
|
234
|
+
verifiedPath: projectPath,
|
|
235
|
+
projectPathExists: true
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
if (pathMappings && pathMappings.has(projectPath)) {
|
|
239
|
+
const mappedPath = pathMappings.get(projectPath);
|
|
240
|
+
const mappedFullPath = path.join(basePath, mappedPath);
|
|
241
|
+
const mappedExists = fs.existsSync(mappedFullPath);
|
|
242
|
+
return {
|
|
243
|
+
projectPath,
|
|
244
|
+
verifiedPath: mappedExists ? mappedPath : '',
|
|
245
|
+
projectPathExists: originalExists
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
// Try without the first path segment
|
|
249
|
+
const segments = projectPath.split('/');
|
|
250
|
+
if (segments.length > 1) {
|
|
251
|
+
const pathWithoutFirstSegment = segments.slice(1).join('/');
|
|
252
|
+
const modifiedFullPath = path.join(basePath, pathWithoutFirstSegment);
|
|
253
|
+
const modifiedExists = fs.existsSync(modifiedFullPath);
|
|
254
|
+
if (modifiedExists) {
|
|
255
|
+
return {
|
|
256
|
+
projectPath,
|
|
257
|
+
verifiedPath: pathWithoutFirstSegment,
|
|
258
|
+
projectPathExists: false
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
// No mapping found or modified path doesn't exist
|
|
263
|
+
return {
|
|
264
|
+
projectPath,
|
|
265
|
+
verifiedPath: '',
|
|
266
|
+
projectPathExists: false
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
catch (error) {
|
|
270
|
+
console.error(`Error verifying project path: ${error}`);
|
|
271
|
+
return { projectPath, verifiedPath: '', projectPathExists: false };
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
exports.verifyProjectPath = verifyProjectPath;
|
|
275
|
+
/**
|
|
276
|
+
* Extract project information from a dependency path based on origin type
|
|
277
|
+
* @param dependencyPath The path from the Black Duck report
|
|
278
|
+
* @param originName The origin name (e.g., npmjs, maven, nuget, pypi, sbt)
|
|
279
|
+
* @param basePath Optional base path to verify against
|
|
280
|
+
* @returns Object containing project path and verified path information
|
|
281
|
+
*/
|
|
282
|
+
function extractProjectInfo(dependencyPath, originName, basePath, pathMappings) {
|
|
283
|
+
if (!dependencyPath) {
|
|
284
|
+
return { projectPath: '', verifiedPath: '', projectPathExists: false };
|
|
285
|
+
}
|
|
286
|
+
try {
|
|
287
|
+
const projectPath = parseProjectPath(dependencyPath);
|
|
288
|
+
// Verify the path if basePath is provided
|
|
289
|
+
if (basePath) {
|
|
290
|
+
return verifyProjectPath(projectPath, basePath, pathMappings);
|
|
291
|
+
}
|
|
292
|
+
// Otherwise return unverified path with empty verifiedPath
|
|
293
|
+
return { projectPath, verifiedPath: '', projectPathExists: undefined };
|
|
294
|
+
}
|
|
295
|
+
catch (error) {
|
|
296
|
+
console.error(`Error extracting project info: ${error}`);
|
|
297
|
+
throw error;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
exports.extractProjectInfo = extractProjectInfo;
|
|
301
|
+
//# sourceMappingURL=projectMapping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projectMapping.js","sourceRoot":"","sources":["../../src/utils/projectMapping.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,uCAAyB;AACzB,2CAA6B;AAe7B,MAAM,cAAc,GAAG;IACrB,OAAO;IACP,MAAM;IACN,cAAc;IACd,MAAM;IACN,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,WAAW;IACX,YAAY;IACZ,YAAY;IACZ,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,aAAa;IACb,OAAO;IACP,KA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,KAAK,EAAE,CAAC,CAAC;QACxD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,EAAE,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAAC;KACpE;AACH,CAAC;AAvDD,8CAuDC;AAED;;;;;;GAMG;AACH,SAAgB,kBAAkB,CAAC,cAAsB,EAAE,UAAkB,EAAE,QAAiB,EAAE,YAA2B;IAC3H,IAAI,CAAC,cAAc,EAAE;QACnB,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAAC;KACxE;IAED,IAAI;QACF,MAAM,WAAW,GAAG,gBAAgB,CAAC,cAAc,CAAC,CAAC;QAErD,0CAA0C;QAC1C,IAAI,QAAQ,EAAE;YACZ,OAAO,iBAAiB,CAAC,WAAW,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;SAC/D;QAED,2DAA2D;QAC3D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,EAAE,EAAE,iBAAiB,EAAE,SAAS,EAAE,CAAC;KACxE;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,kCAAkC,KAAK,EAAE,CAAC,CAAC;QACzD,MAAM,KAAK,CAAC;KACb;AACH,CAAC;AAnBD,gDAmBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxworks/depinder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dxworks",
|
|
@@ -59,12 +59,13 @@
|
|
|
59
59
|
"puppeteer": "18.0.1",
|
|
60
60
|
"semver": "^7.3.5",
|
|
61
61
|
"snyk-gradle-plugin": "^3.25.2",
|
|
62
|
-
"snyk-nodejs-lockfile-parser": "^1.
|
|
62
|
+
"snyk-nodejs-lockfile-parser": "^1.60.1",
|
|
63
63
|
"spdx-correct": "^3.1.1",
|
|
64
64
|
"spdx-license-ids": "^3.0.10",
|
|
65
65
|
"tmp": "^0.2.1",
|
|
66
66
|
"toml": "^3.0.0",
|
|
67
|
-
"winston": "^3.11.0"
|
|
67
|
+
"winston": "^3.11.0",
|
|
68
|
+
"xml2js": "^0.6.2"
|
|
68
69
|
},
|
|
69
70
|
"devDependencies": {
|
|
70
71
|
"@types/cli-progress": "^3.9.2",
|
|
@@ -80,6 +81,7 @@
|
|
|
80
81
|
"@types/string-template": "^1.0.2",
|
|
81
82
|
"@types/tmp": "^0.2.3",
|
|
82
83
|
"@types/ws": "^8.5.4",
|
|
84
|
+
"@types/xml2js": "^0.4.14",
|
|
83
85
|
"@typescript-eslint/eslint-plugin": "^4.32.0",
|
|
84
86
|
"@typescript-eslint/parser": "^4.32.0",
|
|
85
87
|
"copyfiles": "^2.4.1",
|
|
@@ -94,9 +96,6 @@
|
|
|
94
96
|
"ts-node": "^10.2.1",
|
|
95
97
|
"typescript": "^4.4.3"
|
|
96
98
|
},
|
|
97
|
-
"publishConfig": {
|
|
98
|
-
"registry": "https://npm.pkg.github.com"
|
|
99
|
-
},
|
|
100
99
|
"dxw": {
|
|
101
100
|
"commands": [
|
|
102
101
|
{
|