@socketsecurity/cli-with-sentry 1.17.0 → 1.18.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/CHANGELOG.md +12 -0
- package/README.md +5 -5
- package/dist/.config/tsconfig.dts.tsbuildinfo +1 -1
- package/dist/cli.js +426 -257
- package/dist/cli.js.map +1 -1
- package/dist/constants.js +4 -4
- package/dist/constants.js.map +1 -1
- package/dist/types/commands/fix/generated-socket-facts.d.mts +3 -2
- package/dist/types/commands/manifest/build-root-config.d.mts +18 -1
- package/dist/types/commands/manifest/generate-recursive-manifests.d.mts +3 -1
- package/dist/types/commands/manifest/run-manifest-facts.d.mts +4 -0
- package/dist/types/commands/manifest/scripts/build-tool.d.mts +0 -4
- package/dist/types/commands/manifest/setup-manifest-config.d.mts +9 -1
- package/dist/types/constants.d.mts +1 -1
- package/dist/types/utils/coana.d.mts +0 -2
- package/dist/types/utils/socket-json.d.mts +38 -0
- package/dist/utils.js +201 -29
- package/dist/utils.js.map +1 -1
- package/package.json +1 -3
- package/dist/manifest-scripts/dotnet-tool/Microsoft.Build.Locator.dll +0 -0
- package/dist/manifest-scripts/dotnet-tool/socket-facts-dotnet.deps.json +0 -42
- package/dist/manifest-scripts/dotnet-tool/socket-facts-dotnet.dll +0 -0
- package/dist/manifest-scripts/dotnet-tool/socket-facts-dotnet.dll.config +0 -623
- package/dist/manifest-scripts/dotnet-tool/socket-facts-dotnet.runtimeconfig.json +0 -15
- package/dist/manifest-scripts/maven-extension/coana-maven-extension.jar +0 -0
- package/dist/manifest-scripts/socket-facts.init.gradle +0 -832
- package/dist/manifest-scripts/socket-facts.plugin.scala +0 -1018
- package/dist/manifest-scripts/socket-workspaces.init.gradle +0 -123
- package/dist/manifest-scripts/socket-workspaces.plugin.scala +0 -147
- package/dist/types/commands/manifest/scripts/assemble.d.mts +0 -14
- package/dist/types/commands/manifest/scripts/exclude-paths-glob.d.mts +0 -8
- package/dist/types/commands/manifest/scripts/facts.d.mts +0 -111
- package/dist/types/commands/manifest/scripts/records.d.mts +0 -124
- package/dist/types/commands/manifest/scripts/resolution-report-gradle.d.mts +0 -10
- package/dist/types/commands/manifest/scripts/resolution-report-ivy.d.mts +0 -6
- package/dist/types/commands/manifest/scripts/resolution-report-maven.d.mts +0 -7
- package/dist/types/commands/manifest/scripts/resolution-report-nuget.d.mts +0 -6
- package/dist/types/commands/manifest/scripts/resolution-report-render.d.mts +0 -63
- package/dist/types/commands/manifest/scripts/resolution-report.d.mts +0 -28
- package/dist/types/commands/manifest/scripts/run.d.mts +0 -67
- package/dist/types/commands/manifest/scripts/sidecar.d.mts +0 -60
- package/dist/types/commands/manifest/scripts/test/assemble-records.d.mts +0 -1
package/dist/cli.js
CHANGED
|
@@ -1948,143 +1948,6 @@ async function performReachabilityAnalysis(options) {
|
|
|
1948
1948
|
}
|
|
1949
1949
|
}
|
|
1950
1950
|
|
|
1951
|
-
// The purl type of the packages each tool resolves; exhaustive, so a new tool
|
|
1952
|
-
// cannot silently produce another ecosystem's purls.
|
|
1953
|
-
const PURL_TYPE_BY_TOOL = {
|
|
1954
|
-
__proto__: null,
|
|
1955
|
-
dotnet: 'nuget',
|
|
1956
|
-
gradle: 'maven',
|
|
1957
|
-
maven: 'maven',
|
|
1958
|
-
sbt: 'maven'
|
|
1959
|
-
};
|
|
1960
|
-
const BUILD_TOOLS = Object.keys(PURL_TYPE_BY_TOOL);
|
|
1961
|
-
const ECOSYSTEM_LABELS = {
|
|
1962
|
-
__proto__: null,
|
|
1963
|
-
dotnet: '.NET',
|
|
1964
|
-
gradle: 'Gradle',
|
|
1965
|
-
maven: 'Maven',
|
|
1966
|
-
sbt: 'sbt'
|
|
1967
|
-
};
|
|
1968
|
-
const FACTS_PURL_TYPES = [...new Set(Object.values(PURL_TYPE_BY_TOOL))].sort();
|
|
1969
|
-
function buildRootPath(root) {
|
|
1970
|
-
return path.join(root.dir, root.entryFile ?? '');
|
|
1971
|
-
}
|
|
1972
|
-
function buildToolsFor(purlTypes) {
|
|
1973
|
-
return BUILD_TOOLS.filter(tool => purlTypes.includes(PURL_TYPE_BY_TOOL[tool]));
|
|
1974
|
-
}
|
|
1975
|
-
function buildToolLabelsFor(purlTypes) {
|
|
1976
|
-
return buildToolsFor(purlTypes).map(tool => ECOSYSTEM_LABELS[tool]);
|
|
1977
|
-
}
|
|
1978
|
-
const BUILD_TOOL_PATH_ENV = {
|
|
1979
|
-
__proto__: null,
|
|
1980
|
-
gradle: 'SOCKET_CLI_GRADLE_PATH',
|
|
1981
|
-
maven: 'SOCKET_CLI_MAVEN_PATH',
|
|
1982
|
-
sbt: 'SOCKET_CLI_SBT_PATH'
|
|
1983
|
-
};
|
|
1984
|
-
function validatedEnvBuildToolPath(tool, projectDir) {
|
|
1985
|
-
const envName = BUILD_TOOL_PATH_ENV[tool];
|
|
1986
|
-
const selected = process.env[envName];
|
|
1987
|
-
if (!selected) {
|
|
1988
|
-
throw new Error(`Standalone Socket does not support ${tool} manifest execution without ${envName}: JVM runtime and toolchain assets are not bundled.`);
|
|
1989
|
-
}
|
|
1990
|
-
const executable = path.resolve(projectDir, selected);
|
|
1991
|
-
return validateExecutablePath(envName, selected, executable);
|
|
1992
|
-
}
|
|
1993
|
-
function validateExecutablePath(envName, selected, executable) {
|
|
1994
|
-
try {
|
|
1995
|
-
if (!u.statSync(executable).isFile()) {
|
|
1996
|
-
throw new Error('not a regular file');
|
|
1997
|
-
}
|
|
1998
|
-
u.accessSync(executable, u.constants.X_OK);
|
|
1999
|
-
return executable;
|
|
2000
|
-
} catch {
|
|
2001
|
-
throw new Error(`${envName} must point to a regular executable file; received '${selected}'.`);
|
|
2002
|
-
}
|
|
2003
|
-
}
|
|
2004
|
-
|
|
2005
|
-
// PATH fallback when no `bin` and no project wrapper.
|
|
2006
|
-
const DEFAULT_BUILD_TOOL_BIN = {
|
|
2007
|
-
__proto__: null,
|
|
2008
|
-
dotnet: 'dotnet',
|
|
2009
|
-
gradle: 'gradle',
|
|
2010
|
-
maven: 'mvn',
|
|
2011
|
-
sbt: 'sbt'
|
|
2012
|
-
};
|
|
2013
|
-
|
|
2014
|
-
// Project-local wrapper, preferred because it pins the expected build-tool
|
|
2015
|
-
// version. sbt has no wrapper convention. POSIX names only (no win32 target).
|
|
2016
|
-
const BUILD_TOOL_WRAPPER = {
|
|
2017
|
-
__proto__: null,
|
|
2018
|
-
gradle: 'gradlew',
|
|
2019
|
-
maven: 'mvnw'
|
|
2020
|
-
};
|
|
2021
|
-
|
|
2022
|
-
// Maven (`mvn --file`) and dotnet (`dotnet restore <file>`) build by file, so
|
|
2023
|
-
// a directory can hold several builds, matched case-insensitively. `walkGlob`
|
|
2024
|
-
// is a case-sensitive superset of `nocaseGlob`, for the walk.
|
|
2025
|
-
|
|
2026
|
-
// `settings.gradle(.kts)` covers Kotlin-DSL roots that have no root
|
|
2027
|
-
// `build.gradle`.
|
|
2028
|
-
const BUILD_FILES = {
|
|
2029
|
-
__proto__: null,
|
|
2030
|
-
// Solutions, and the project types the .NET SDK builds. A solution filter
|
|
2031
|
-
// (.slnf) narrows a solution, so it is only built when named explicitly.
|
|
2032
|
-
dotnet: {
|
|
2033
|
-
byFile: true,
|
|
2034
|
-
nocaseGlob: '*.{sln,slnx,csproj,fsproj,vbproj}',
|
|
2035
|
-
walkGlob: '*.{[sS][lL][nN],[sS][lL][nN][xX],[cCfFvV][sSbB][pP][rR][oO][jJ]}',
|
|
2036
|
-
// A solution covers the projects it lists.
|
|
2037
|
-
entryRank: file => isDotnetSolution(file) ? 0 : 1
|
|
2038
|
-
},
|
|
2039
|
-
gradle: {
|
|
2040
|
-
byFile: false,
|
|
2041
|
-
names: ['build.gradle', 'build.gradle.kts', 'settings.gradle', 'settings.gradle.kts'],
|
|
2042
|
-
rootMarkers: ['settings.gradle', 'settings.gradle.kts'],
|
|
2043
|
-
// Gradle builds `buildSrc` on its own.
|
|
2044
|
-
loadsAncestorBuild: {
|
|
2045
|
-
except: ['buildSrc']
|
|
2046
|
-
}
|
|
2047
|
-
},
|
|
2048
|
-
maven: {
|
|
2049
|
-
byFile: true,
|
|
2050
|
-
nocaseGlob: '{*-*.,}pom{.xml,}',
|
|
2051
|
-
walkGlob: '*[pP][oO][mM]*'
|
|
2052
|
-
},
|
|
2053
|
-
// A subproject's own `project/` is ignored by the build that includes it.
|
|
2054
|
-
sbt: {
|
|
2055
|
-
byFile: false,
|
|
2056
|
-
names: ['build.sbt'],
|
|
2057
|
-
rootMarkers: ['project']
|
|
2058
|
-
}
|
|
2059
|
-
};
|
|
2060
|
-
|
|
2061
|
-
// sbt happily runs in any directory, synthesizing a default project from its
|
|
2062
|
-
// name, so an sbt run outside a build yields a plausible but bogus SBOM. Maven
|
|
2063
|
-
// and Gradle refuse such a directory themselves.
|
|
2064
|
-
function looksLikeSbtBuild(projectDir) {
|
|
2065
|
-
return u.existsSync(path.resolve(projectDir, 'build.sbt')) || u.existsSync(path.resolve(projectDir, 'project'));
|
|
2066
|
-
}
|
|
2067
|
-
function resolveBuildToolBin(tool, projectDir, bin, standalone = false) {
|
|
2068
|
-
if (standalone) {
|
|
2069
|
-
return validatedEnvBuildToolPath(tool, projectDir);
|
|
2070
|
-
}
|
|
2071
|
-
const envOverride = process.env[BUILD_TOOL_PATH_ENV[tool]];
|
|
2072
|
-
if (envOverride) {
|
|
2073
|
-
return validateExecutablePath(BUILD_TOOL_PATH_ENV[tool], envOverride, path.resolve(projectDir, envOverride));
|
|
2074
|
-
}
|
|
2075
|
-
if (bin) {
|
|
2076
|
-
return bin;
|
|
2077
|
-
}
|
|
2078
|
-
const wrapperName = BUILD_TOOL_WRAPPER[tool];
|
|
2079
|
-
if (wrapperName && u.existsSync(path.resolve(projectDir, wrapperName))) {
|
|
2080
|
-
return `./${wrapperName}`;
|
|
2081
|
-
}
|
|
2082
|
-
return DEFAULT_BUILD_TOOL_BIN[tool];
|
|
2083
|
-
}
|
|
2084
|
-
function isDotnetSolution(file) {
|
|
2085
|
-
return /\.slnx?$/i.test(file);
|
|
2086
|
-
}
|
|
2087
|
-
|
|
2088
1951
|
// Where the invoking command lets the user set each build option, so a remedy
|
|
2089
1952
|
// in Coana's failure report names something they can actually set.
|
|
2090
1953
|
|
|
@@ -2134,6 +1997,11 @@ function purposeOf({
|
|
|
2134
1997
|
function coanaReadsFacts(context) {
|
|
2135
1998
|
return purposeOf(context) !== 'upload';
|
|
2136
1999
|
}
|
|
2000
|
+
|
|
2001
|
+
// Only a reachability scan reads the builds' socket.json reachability settings.
|
|
2002
|
+
function readsReachabilitySettings(context) {
|
|
2003
|
+
return context !== undefined && purposeOf(context) === 'reachability';
|
|
2004
|
+
}
|
|
2137
2005
|
async function readResult(resultFile) {
|
|
2138
2006
|
if (!u.existsSync(resultFile)) {
|
|
2139
2007
|
return {
|
|
@@ -2190,11 +2058,12 @@ function toSocketFactsRequest({
|
|
|
2190
2058
|
ignoreUnresolved = false,
|
|
2191
2059
|
includeConfigs,
|
|
2192
2060
|
javaHome,
|
|
2061
|
+
reachability,
|
|
2193
2062
|
verbose = false
|
|
2194
2063
|
}, context) {
|
|
2195
2064
|
let resolvedBin;
|
|
2196
2065
|
try {
|
|
2197
|
-
resolvedBin = resolveBuildToolBin(ecosystem, cwd, bin || undefined, ecosystem !== 'dotnet' && utils.isSea());
|
|
2066
|
+
resolvedBin = utils.resolveBuildToolBin(ecosystem, cwd, bin || undefined, ecosystem !== 'dotnet' && utils.isSea());
|
|
2198
2067
|
} catch (e) {
|
|
2199
2068
|
return {
|
|
2200
2069
|
ok: false,
|
|
@@ -2219,6 +2088,9 @@ function toSocketFactsRequest({
|
|
|
2219
2088
|
...(javaHome && ecosystem !== 'dotnet' ? {
|
|
2220
2089
|
javaHome
|
|
2221
2090
|
} : {}),
|
|
2091
|
+
...(reachability ? {
|
|
2092
|
+
reachability
|
|
2093
|
+
} : {}),
|
|
2222
2094
|
verbose
|
|
2223
2095
|
},
|
|
2224
2096
|
excludeBase: path.resolve(excludeBase ?? cwd),
|
|
@@ -2320,7 +2192,7 @@ async function listBuildProjects({
|
|
|
2320
2192
|
result
|
|
2321
2193
|
} = await runGenerateSocketFacts(request.data, ['--list-projects'], context);
|
|
2322
2194
|
if (!result) {
|
|
2323
|
-
utils.logger.fail(`Could not list the projects of the ${ecosystem} build at \`${buildRootPath({
|
|
2195
|
+
utils.logger.fail(`Could not list the projects of the ${ecosystem} build at \`${utils.buildRootPath({
|
|
2324
2196
|
dir: cwd,
|
|
2325
2197
|
entryFile
|
|
2326
2198
|
})}\`${message ? `: ${message}` : '.'}`);
|
|
@@ -2341,7 +2213,7 @@ async function runManifestFacts({
|
|
|
2341
2213
|
ecosystem,
|
|
2342
2214
|
entryFile
|
|
2343
2215
|
} = options;
|
|
2344
|
-
if (ecosystem === 'sbt' && !looksLikeSbtBuild(cwd)) {
|
|
2216
|
+
if (ecosystem === 'sbt' && !utils.looksLikeSbtBuild(cwd)) {
|
|
2345
2217
|
process.exitCode = 1;
|
|
2346
2218
|
utils.logger.fail(`No sbt build found at \`${cwd}\` (expected a build.sbt file or a project directory).`);
|
|
2347
2219
|
return null;
|
|
@@ -2362,7 +2234,7 @@ async function runManifestFacts({
|
|
|
2362
2234
|
if (!result || result.status === 'failed') {
|
|
2363
2235
|
process.exitCode = 1;
|
|
2364
2236
|
if (!result) {
|
|
2365
|
-
utils.logger.fail(`Could not generate Socket facts for the ${ecosystem} project at \`${buildRootPath({
|
|
2237
|
+
utils.logger.fail(`Could not generate Socket facts for the ${ecosystem} project at \`${utils.buildRootPath({
|
|
2366
2238
|
dir: cwd,
|
|
2367
2239
|
entryFile
|
|
2368
2240
|
})}\`${message ? `: ${message}` : '.'}`);
|
|
@@ -2394,8 +2266,8 @@ function socketFactsSidecar(workDir) {
|
|
|
2394
2266
|
return [...workDir.entries.values()];
|
|
2395
2267
|
}
|
|
2396
2268
|
|
|
2397
|
-
const BUILD_FILE_MATCHERS = new Map(BUILD_TOOLS.map(tool => {
|
|
2398
|
-
const files = BUILD_FILES[tool];
|
|
2269
|
+
const BUILD_FILE_MATCHERS = new Map(utils.BUILD_TOOLS.map(tool => {
|
|
2270
|
+
const files = utils.BUILD_FILES[tool];
|
|
2399
2271
|
return [tool, files.byFile ? vendor.micromatchExports.matcher(files.nocaseGlob, {
|
|
2400
2272
|
dot: true,
|
|
2401
2273
|
nocase: true
|
|
@@ -2424,7 +2296,7 @@ function buildFileTool(tools, basename) {
|
|
|
2424
2296
|
return tools.find(tool => isBuildFile(tool, basename));
|
|
2425
2297
|
}
|
|
2426
2298
|
function compareEntryFiles(tool, a, b) {
|
|
2427
|
-
const files = BUILD_FILES[tool];
|
|
2299
|
+
const files = utils.BUILD_FILES[tool];
|
|
2428
2300
|
const rank = files.byFile ? files.entryRank : undefined;
|
|
2429
2301
|
return (rank ? rank(a) - rank(b) : 0) || compareStrings(a, b);
|
|
2430
2302
|
}
|
|
@@ -2442,7 +2314,7 @@ function withoutDisabledFlags(sockJson) {
|
|
|
2442
2314
|
const stripped = {
|
|
2443
2315
|
...manifest
|
|
2444
2316
|
};
|
|
2445
|
-
for (const tool of BUILD_TOOLS) {
|
|
2317
|
+
for (const tool of utils.BUILD_TOOLS) {
|
|
2446
2318
|
const section = manifest[tool];
|
|
2447
2319
|
if (section?.disabled) {
|
|
2448
2320
|
stripped[tool] = {
|
|
@@ -2519,7 +2391,7 @@ async function membershipOf(projects, scanRoot) {
|
|
|
2519
2391
|
}
|
|
2520
2392
|
const rootMarkerByDir = new Map();
|
|
2521
2393
|
function hasRootMarker(tool, root) {
|
|
2522
|
-
const files = BUILD_FILES[tool];
|
|
2394
|
+
const files = utils.BUILD_FILES[tool];
|
|
2523
2395
|
if (files.byFile) {
|
|
2524
2396
|
return false;
|
|
2525
2397
|
}
|
|
@@ -2530,9 +2402,9 @@ function hasRootMarker(tool, root) {
|
|
|
2530
2402
|
// hasRootMarker) is more than that project. `root.dir` must be
|
|
2531
2403
|
// realpath-resolved, as findBuildToolCandidates returns it.
|
|
2532
2404
|
function isBuildRootCovered(covered, tool, root) {
|
|
2533
|
-
const files = BUILD_FILES[tool];
|
|
2405
|
+
const files = utils.BUILD_FILES[tool];
|
|
2534
2406
|
if (files.byFile) {
|
|
2535
|
-
return !!root.entryFile && containsPath(covered.files, buildRootPath(root));
|
|
2407
|
+
return !!root.entryFile && containsPath(covered.files, utils.buildRootPath(root));
|
|
2536
2408
|
}
|
|
2537
2409
|
return containsPath(covered.dirs, root.dir) || files.names.some(name => containsPath(covered.files, path.join(root.dir, name)));
|
|
2538
2410
|
}
|
|
@@ -2543,7 +2415,7 @@ async function isSolutionCovered(covered, root, opts, listMembers = listDotnetSo
|
|
|
2543
2415
|
const {
|
|
2544
2416
|
entryFile
|
|
2545
2417
|
} = root;
|
|
2546
|
-
if (!entryFile || !isDotnetSolution(entryFile)) {
|
|
2418
|
+
if (!entryFile || !utils.isDotnetSolution(entryFile)) {
|
|
2547
2419
|
return false;
|
|
2548
2420
|
}
|
|
2549
2421
|
const twin = entryFile.replace(/\.slnx?$/i, ext => ext.toLowerCase() === '.sln' ? '.slnx' : '.sln');
|
|
@@ -2562,7 +2434,7 @@ async function isSolutionCovered(covered, root, opts, listMembers = listDotnetSo
|
|
|
2562
2434
|
if (!hasTwin || !(await list(twin))) {
|
|
2563
2435
|
return false;
|
|
2564
2436
|
}
|
|
2565
|
-
utils.logger.warn(`Skipping ${buildRootPath(root)}: the .NET SDK could not read it; ${twin} beside it is built instead.`);
|
|
2437
|
+
utils.logger.warn(`Skipping ${utils.buildRootPath(root)}: the .NET SDK could not read it; ${twin} beside it is built instead.`);
|
|
2566
2438
|
return true;
|
|
2567
2439
|
}
|
|
2568
2440
|
const members = await realMembers(listed);
|
|
@@ -2592,7 +2464,7 @@ async function isBuildCovered(covered, tool, root, opts, own) {
|
|
|
2592
2464
|
if (!hasRootMarker(tool, root)) {
|
|
2593
2465
|
return await isRootCovered(covered, tool, root, opts);
|
|
2594
2466
|
}
|
|
2595
|
-
const pick = membership => BUILD_FILES[tool].byFile ? membership.files : membership.dirs;
|
|
2467
|
+
const pick = membership => utils.BUILD_FILES[tool].byFile ? membership.files : membership.dirs;
|
|
2596
2468
|
const members = own ? pick(own) : new Set();
|
|
2597
2469
|
const loaded = pick(covered);
|
|
2598
2470
|
return !!members.size && [...members].every(member => loaded.has(member));
|
|
@@ -2617,11 +2489,11 @@ function sortByDepthThenPath(roots, cwd, tool) {
|
|
|
2617
2489
|
async function findBuildToolCandidates({
|
|
2618
2490
|
cwd,
|
|
2619
2491
|
excludePaths,
|
|
2620
|
-
purlTypes = FACTS_PURL_TYPES,
|
|
2492
|
+
purlTypes = utils.FACTS_PURL_TYPES,
|
|
2621
2493
|
sockJson,
|
|
2622
2494
|
socketConfig
|
|
2623
2495
|
}) {
|
|
2624
|
-
const enabledTools = buildToolsFor(purlTypes).filter(tool => !sockJson.defaults?.manifest?.[tool]?.disabled);
|
|
2496
|
+
const enabledTools = utils.buildToolsFor(purlTypes).filter(tool => !sockJson.defaults?.manifest?.[tool]?.disabled);
|
|
2625
2497
|
const result = new Map();
|
|
2626
2498
|
if (!enabledTools.length) {
|
|
2627
2499
|
return result;
|
|
@@ -2630,7 +2502,7 @@ async function findBuildToolCandidates({
|
|
|
2630
2502
|
// Build files are matched after the walk, as a scan matches them after its
|
|
2631
2503
|
// ignores, so --exclude-paths and .gitignore stay case-sensitive.
|
|
2632
2504
|
const hits = await utils.globWithGitIgnore(enabledTools.flatMap(tool => {
|
|
2633
|
-
const files = BUILD_FILES[tool];
|
|
2505
|
+
const files = utils.BUILD_FILES[tool];
|
|
2634
2506
|
return (files.byFile ? [files.walkGlob] : files.names).map(glob => `**/${glob}`);
|
|
2635
2507
|
}), {
|
|
2636
2508
|
absolute: true,
|
|
@@ -2655,7 +2527,7 @@ async function findBuildToolCandidates({
|
|
|
2655
2527
|
}) => ({
|
|
2656
2528
|
root: {
|
|
2657
2529
|
dir: await utils.realpathOrResolved(path.dirname(hit)),
|
|
2658
|
-
entryFile: BUILD_FILES[tool].byFile ? basename : undefined
|
|
2530
|
+
entryFile: utils.BUILD_FILES[tool].byFile ? basename : undefined
|
|
2659
2531
|
},
|
|
2660
2532
|
tool
|
|
2661
2533
|
})));
|
|
@@ -2663,7 +2535,7 @@ async function findBuildToolCandidates({
|
|
|
2663
2535
|
root,
|
|
2664
2536
|
tool
|
|
2665
2537
|
} of roots) {
|
|
2666
|
-
rootsByTool.get(tool)?.set(buildRootPath(root), root);
|
|
2538
|
+
rootsByTool.get(tool)?.set(utils.buildRootPath(root), root);
|
|
2667
2539
|
}
|
|
2668
2540
|
const realCwd = await utils.realpathOrResolved(cwd);
|
|
2669
2541
|
for (const tool of enabledTools) {
|
|
@@ -2674,10 +2546,58 @@ async function findBuildToolCandidates({
|
|
|
2674
2546
|
|
|
2675
2547
|
// The setting that makes the effective `disabled` true.
|
|
2676
2548
|
|
|
2549
|
+
// major.minor, or major.minor.patch[-prerelease] as `RuntimeFrameworkVersion`
|
|
2550
|
+
// takes a .NET runtime, written as SemVer 2.0.0 items 2 and 9 say.
|
|
2551
|
+
const NUMBER = '(?:0|[1-9][0-9]*)';
|
|
2552
|
+
const PRERELEASE_IDENTIFIER = `(?:${NUMBER}|[0-9]*[A-Za-z-][0-9A-Za-z-]*)`;
|
|
2553
|
+
const DOTNET_RUNTIME_VERSION = new RegExp(`^${NUMBER}\\.${NUMBER}(?:\\.${NUMBER}(?:-${PRERELEASE_IDENTIFIER}(?:\\.${PRERELEASE_IDENTIFIER})*)?)?$`);
|
|
2554
|
+
const DOTNET_RUNTIME_VERSION_FORMAT = 'major.minor, such as "8.0", for its latest installed patch, or major.minor.patch[-prerelease], such as "8.0.11", for exactly that runtime';
|
|
2555
|
+
const REACHABILITY_FIELDS = {
|
|
2556
|
+
__proto__: null,
|
|
2557
|
+
build: {
|
|
2558
|
+
expected: utils.joinOr(utils.REACHABILITY_BUILDS.map(b => `"${b}"`)),
|
|
2559
|
+
takes: value => utils.REACHABILITY_BUILDS.includes(value)
|
|
2560
|
+
},
|
|
2561
|
+
javaHome: {
|
|
2562
|
+
expected: 'a JDK path',
|
|
2563
|
+
takes: utils.isNonEmptyString
|
|
2564
|
+
},
|
|
2565
|
+
runtimeVersion: {
|
|
2566
|
+
expected: `a .NET runtime version: ${DOTNET_RUNTIME_VERSION_FORMAT}`,
|
|
2567
|
+
takes: value => typeof value === 'string' && DOTNET_RUNTIME_VERSION.test(value)
|
|
2568
|
+
}
|
|
2569
|
+
};
|
|
2570
|
+
function checkReachability(tool, value, setting, socketJson) {
|
|
2571
|
+
const {
|
|
2572
|
+
problems: {
|
|
2573
|
+
0: first
|
|
2574
|
+
}
|
|
2575
|
+
} = parseReachability(tool, value);
|
|
2576
|
+
if (first) {
|
|
2577
|
+
const key = first.field === undefined ? setting : `${setting}.${first.field}`;
|
|
2578
|
+
throw new utils.InputError(`\`${key}\` in ${socketJson} ${first.problem}`);
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
|
|
2582
|
+
// An invalid setting raises an InputError naming the file. Checks each
|
|
2583
|
+
// socket.json once per `checked`.
|
|
2584
|
+
function checkChainReachability(tool, chain, checked) {
|
|
2585
|
+
for (const {
|
|
2586
|
+
dir,
|
|
2587
|
+
sockJson
|
|
2588
|
+
} of chain) {
|
|
2589
|
+
const key = `${tool}\0${dir}`;
|
|
2590
|
+
if (!checked.has(key)) {
|
|
2591
|
+
checkReachability(tool, sockJson.defaults?.manifest?.[tool]?.reachability, `defaults.manifest.${tool}.reachability`, socketJsonPath(dir));
|
|
2592
|
+
checked.add(key);
|
|
2593
|
+
}
|
|
2594
|
+
}
|
|
2595
|
+
}
|
|
2596
|
+
|
|
2677
2597
|
// Gradle and sbt name a build by any build file of its directory.
|
|
2678
2598
|
function namesBuildFile(key) {
|
|
2679
|
-
return BUILD_TOOLS.some(tool => {
|
|
2680
|
-
const files = BUILD_FILES[tool];
|
|
2599
|
+
return utils.BUILD_TOOLS.some(tool => {
|
|
2600
|
+
const files = utils.BUILD_FILES[tool];
|
|
2681
2601
|
return files.byFile ? isBuildFile(tool, key) : files.names.includes(key);
|
|
2682
2602
|
});
|
|
2683
2603
|
}
|
|
@@ -2685,12 +2605,20 @@ function namesBuildFile(key) {
|
|
|
2685
2605
|
// The `builds` keys naming an existing build file of `tool`'s build in `dir`:
|
|
2686
2606
|
// its entry file, or any of a Gradle or sbt directory's build files.
|
|
2687
2607
|
function ownEntryKeys(tool, dir, builds, entryFile) {
|
|
2688
|
-
const files = BUILD_FILES[tool];
|
|
2608
|
+
const files = utils.BUILD_FILES[tool];
|
|
2689
2609
|
if (files.byFile) {
|
|
2690
2610
|
return entryFile && Object.hasOwn(builds, entryFile) ? [entryFile] : [];
|
|
2691
2611
|
}
|
|
2692
2612
|
return files.names.filter(name => Object.hasOwn(builds, name) && u.existsSync(path.join(dir, name)));
|
|
2693
2613
|
}
|
|
2614
|
+
|
|
2615
|
+
// Without the fields a socket.json cleared with null.
|
|
2616
|
+
function settingsInEffect(settings) {
|
|
2617
|
+
const entries = Object.entries(settings).filter(({
|
|
2618
|
+
1: setting
|
|
2619
|
+
}) => setting !== null && setting !== undefined);
|
|
2620
|
+
return entries.length ? Object.fromEntries(entries) : undefined;
|
|
2621
|
+
}
|
|
2694
2622
|
function validateBuilds({
|
|
2695
2623
|
dir,
|
|
2696
2624
|
sockJson
|
|
@@ -2717,7 +2645,7 @@ function validateBuilds({
|
|
|
2717
2645
|
throw new utils.InputError(`${buildsSetting(key)}.disabled in ${file} must be true or false.`);
|
|
2718
2646
|
}
|
|
2719
2647
|
}
|
|
2720
|
-
for (const tool of BUILD_TOOLS) {
|
|
2648
|
+
for (const tool of utils.BUILD_TOOLS) {
|
|
2721
2649
|
const keys = ownEntryKeys(tool, dir, builds);
|
|
2722
2650
|
if (keys.length > 1) {
|
|
2723
2651
|
throw new utils.InputError(`${keys.map(buildsSetting).join(' and ')} in ${file} configure the same ${tool} build. Keep one of them.`);
|
|
@@ -2747,6 +2675,7 @@ function createBuildRootSettingsResolver(readChain = utils.readSocketJsonChain,
|
|
|
2747
2675
|
const chains = new Map();
|
|
2748
2676
|
const resolved = new Map();
|
|
2749
2677
|
const validated = new Set();
|
|
2678
|
+
const reachabilityChecked = new Set();
|
|
2750
2679
|
const chainFor = dir => {
|
|
2751
2680
|
let chain = chains.get(dir);
|
|
2752
2681
|
if (!chain) {
|
|
@@ -2765,7 +2694,7 @@ function createBuildRootSettingsResolver(readChain = utils.readSocketJsonChain,
|
|
|
2765
2694
|
const resolve = (tool, root) => {
|
|
2766
2695
|
const chain = chainFor(root.dir);
|
|
2767
2696
|
const merged = utils.mergeSocketJsonChain(chain);
|
|
2768
|
-
|
|
2697
|
+
let section = {
|
|
2769
2698
|
...merged.defaults?.manifest?.[tool]
|
|
2770
2699
|
};
|
|
2771
2700
|
let sectionDisabledBy;
|
|
@@ -2785,9 +2714,9 @@ function createBuildRootSettingsResolver(readChain = utils.readSocketJsonChain,
|
|
|
2785
2714
|
// Validation leaves at most one.
|
|
2786
2715
|
const entryKey = builds ? ownEntryKeys(tool, root.dir, builds, root.entryFile)[0] : undefined;
|
|
2787
2716
|
let entryDisabledBy;
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2717
|
+
const entry = entryKey ? builds?.[entryKey] : undefined;
|
|
2718
|
+
if (entry) {
|
|
2719
|
+
section = utils.mergeBuildToolDefaults(section, entry);
|
|
2791
2720
|
if (entry.disabled !== undefined) {
|
|
2792
2721
|
entryDisabledBy = {
|
|
2793
2722
|
dir: root.dir,
|
|
@@ -2802,9 +2731,22 @@ function createBuildRootSettingsResolver(readChain = utils.readSocketJsonChain,
|
|
|
2802
2731
|
if (section['disabled']) {
|
|
2803
2732
|
disabledBy = directorySkip ? sectionDisabledBy : entryDisabledBy;
|
|
2804
2733
|
}
|
|
2734
|
+
let cached;
|
|
2805
2735
|
return {
|
|
2806
2736
|
disabledBy,
|
|
2807
2737
|
entryKey,
|
|
2738
|
+
reachability: () => {
|
|
2739
|
+
if (!cached) {
|
|
2740
|
+
checkChainReachability(tool, chain, reachabilityChecked);
|
|
2741
|
+
if (entryKey && entry) {
|
|
2742
|
+
checkReachability(tool, entry['reachability'], `${buildsSetting(entryKey)}.reachability`, socketJsonPath(root.dir));
|
|
2743
|
+
}
|
|
2744
|
+
cached = {
|
|
2745
|
+
settings: settingsInEffect(parseReachability(tool, section['reachability']).settings)
|
|
2746
|
+
};
|
|
2747
|
+
}
|
|
2748
|
+
return cached.settings;
|
|
2749
|
+
},
|
|
2808
2750
|
sockJson: {
|
|
2809
2751
|
...merged,
|
|
2810
2752
|
defaults: {
|
|
@@ -2817,7 +2759,7 @@ function createBuildRootSettingsResolver(readChain = utils.readSocketJsonChain,
|
|
|
2817
2759
|
}
|
|
2818
2760
|
};
|
|
2819
2761
|
};
|
|
2820
|
-
return (tool, root) => utils.getOrInsert(resolved, `${tool}\0${buildRootPath(root)}`, () => resolve(tool, root));
|
|
2762
|
+
return (tool, root) => utils.getOrInsert(resolved, `${tool}\0${utils.buildRootPath(root)}`, () => resolve(tool, root));
|
|
2821
2763
|
}
|
|
2822
2764
|
|
|
2823
2765
|
// The setting that skips builds, as `<socket.json> sets <setting>`.
|
|
@@ -2834,6 +2776,59 @@ function displayPath(file) {
|
|
|
2834
2776
|
const rel = path.relative(process.cwd(), file);
|
|
2835
2777
|
return rel.startsWith('..') || path.isAbsolute(rel) ? file : rel || '.';
|
|
2836
2778
|
}
|
|
2779
|
+
|
|
2780
|
+
// The valid fields of `value`, nulls kept, and the problem with each other one.
|
|
2781
|
+
function parseReachability(tool, value) {
|
|
2782
|
+
const settings = {};
|
|
2783
|
+
if (value === undefined) {
|
|
2784
|
+
return {
|
|
2785
|
+
problems: [],
|
|
2786
|
+
settings
|
|
2787
|
+
};
|
|
2788
|
+
}
|
|
2789
|
+
if (!utils.isRecord(value)) {
|
|
2790
|
+
return {
|
|
2791
|
+
problems: [{
|
|
2792
|
+
field: undefined,
|
|
2793
|
+
problem: `is ${JSON.stringify(value)}; set it to an object, or remove it.`,
|
|
2794
|
+
value
|
|
2795
|
+
}],
|
|
2796
|
+
settings
|
|
2797
|
+
};
|
|
2798
|
+
}
|
|
2799
|
+
const fields = reachabilityFieldsOf(tool);
|
|
2800
|
+
const problems = [];
|
|
2801
|
+
for (const {
|
|
2802
|
+
0: name,
|
|
2803
|
+
1: fieldValue
|
|
2804
|
+
} of Object.entries(value)) {
|
|
2805
|
+
const field = fields.find(f => f === name);
|
|
2806
|
+
if (!field) {
|
|
2807
|
+
problems.push({
|
|
2808
|
+
field: name,
|
|
2809
|
+
problem: `is not a reachability setting of ${tool} builds, which take ${utils.joinAnd(fields)}; remove it.`,
|
|
2810
|
+
value: fieldValue
|
|
2811
|
+
});
|
|
2812
|
+
} else if (fieldValue === null || REACHABILITY_FIELDS[field].takes(fieldValue)) {
|
|
2813
|
+
Object.assign(settings, {
|
|
2814
|
+
[field]: fieldValue
|
|
2815
|
+
});
|
|
2816
|
+
} else {
|
|
2817
|
+
problems.push({
|
|
2818
|
+
field,
|
|
2819
|
+
problem: `is ${JSON.stringify(fieldValue)}; set it to ${REACHABILITY_FIELDS[field].expected}, to null to clear an inherited value, or remove it.`,
|
|
2820
|
+
value: fieldValue
|
|
2821
|
+
});
|
|
2822
|
+
}
|
|
2823
|
+
}
|
|
2824
|
+
return {
|
|
2825
|
+
problems,
|
|
2826
|
+
settings
|
|
2827
|
+
};
|
|
2828
|
+
}
|
|
2829
|
+
function reachabilityFieldsOf(tool) {
|
|
2830
|
+
return utils.REACHABILITY_FIELDS_BY_TOOL[tool];
|
|
2831
|
+
}
|
|
2837
2832
|
function socketJsonPath(dir) {
|
|
2838
2833
|
return displayPath(path.join(dir, constants.SOCKET_JSON));
|
|
2839
2834
|
}
|
|
@@ -2915,16 +2910,21 @@ function normalizePathKey(value) {
|
|
|
2915
2910
|
// root here, on top of its existing root-only ecosystem-wide meaning for
|
|
2916
2911
|
// auto/gradle/etc. facts:false has no pom-mode equivalent here (facts-only),
|
|
2917
2912
|
// so it skips too.
|
|
2918
|
-
function getSkipReason(ecosystem,
|
|
2919
|
-
if (disabled) {
|
|
2913
|
+
function getSkipReason(ecosystem, section) {
|
|
2914
|
+
if (section?.disabled) {
|
|
2920
2915
|
return `defaults.manifest.${ecosystem}.disabled is true`;
|
|
2921
2916
|
}
|
|
2922
|
-
if (facts === false) {
|
|
2917
|
+
if ((ecosystem === 'gradle' || ecosystem === 'sbt') && section?.facts === false) {
|
|
2923
2918
|
return `defaults.manifest.${ecosystem}.facts is false (pom mode)`;
|
|
2924
2919
|
}
|
|
2925
2920
|
return undefined;
|
|
2926
2921
|
}
|
|
2927
2922
|
|
|
2923
|
+
// What a build reads: its settings on a reachability scan, unless skipped.
|
|
2924
|
+
function reachabilityOf(context, tool, settings) {
|
|
2925
|
+
return readsReachabilitySettings(context) && !getSkipReason(tool, settings.sockJson.defaults?.manifest?.[tool]) ? settings.reachability() : undefined;
|
|
2926
|
+
}
|
|
2927
|
+
|
|
2928
2928
|
// A build skipped by its own `builds` entry, loaded to skip what it loads.
|
|
2929
2929
|
|
|
2930
2930
|
// What loads a build another build covers, for messages.
|
|
@@ -2964,6 +2964,7 @@ function socketFactsRunOptions(ecosystem, root, config, {
|
|
|
2964
2964
|
ignoreUnresolved: config.ignoreUnresolved,
|
|
2965
2965
|
includeConfigs: config.includeConfigs,
|
|
2966
2966
|
javaHome: config.javaHome,
|
|
2967
|
+
reachability: config.reachability,
|
|
2967
2968
|
verbose: config.verbose
|
|
2968
2969
|
};
|
|
2969
2970
|
}
|
|
@@ -2979,7 +2980,7 @@ async function everyAsync(items, test) {
|
|
|
2979
2980
|
|
|
2980
2981
|
// Order-independent: a run that a later build turns out to load is dropped.
|
|
2981
2982
|
async function walkTool(ctx, ecosystem, roots) {
|
|
2982
|
-
const buildFiles = BUILD_FILES[ecosystem];
|
|
2983
|
+
const buildFiles = utils.BUILD_FILES[ecosystem];
|
|
2983
2984
|
const candidates = roots.map((root, index) => ({
|
|
2984
2985
|
index,
|
|
2985
2986
|
marker: hasRootMarker(ecosystem, root),
|
|
@@ -3004,15 +3005,15 @@ async function walkTool(ctx, ecosystem, roots) {
|
|
|
3004
3005
|
}) => ctx.resolveSettings(ecosystem, root);
|
|
3005
3006
|
const configs = new Map();
|
|
3006
3007
|
const configFor = candidate => {
|
|
3007
|
-
const
|
|
3008
|
-
entryKey,
|
|
3009
|
-
sockJson
|
|
3010
|
-
} = resolvedFor(candidate);
|
|
3008
|
+
const resolved = resolvedFor(candidate);
|
|
3011
3009
|
const {
|
|
3012
3010
|
dir
|
|
3013
3011
|
} = candidate.root;
|
|
3014
3012
|
// Builds sharing a directory and its settings resolve them once.
|
|
3015
|
-
return utils.getOrInsert(configs, `${dir}\0${entryKey ?? ''}`, () =>
|
|
3013
|
+
return utils.getOrInsert(configs, `${dir}\0${resolved.entryKey ?? ''}`, () => ({
|
|
3014
|
+
...resolveEcosystemConfig(ecosystem, dir, resolved.sockJson),
|
|
3015
|
+
reachability: reachabilityOf(ctx.context, ecosystem, resolved)
|
|
3016
|
+
}));
|
|
3016
3017
|
};
|
|
3017
3018
|
|
|
3018
3019
|
// 'load' when the build's own entry skips it, 'skip' when a directory
|
|
@@ -3038,7 +3039,7 @@ async function walkTool(ctx, ecosystem, roots) {
|
|
|
3038
3039
|
}
|
|
3039
3040
|
if (skipReason) {
|
|
3040
3041
|
// One line per setting, not per build root it skips.
|
|
3041
|
-
warnOnce(disabledBy ? `Skipping ${ecosystem} builds in and beneath ${displayPath(disabledBy.dir)}: ${describeDisabledBy(ecosystem, disabledBy)}.` : `Skipping ${buildRootPath(candidate.root)} (${ecosystem}): ${skipReason}.`);
|
|
3042
|
+
warnOnce(disabledBy ? `Skipping ${ecosystem} builds in and beneath ${displayPath(disabledBy.dir)}: ${describeDisabledBy(ecosystem, disabledBy)}.` : `Skipping ${utils.buildRootPath(candidate.root)} (${ecosystem}): ${skipReason}.`);
|
|
3042
3043
|
return 'skip';
|
|
3043
3044
|
}
|
|
3044
3045
|
return ancestor && skipOf(ancestor) ? 'skip' : undefined;
|
|
@@ -3077,7 +3078,7 @@ async function walkTool(ctx, ecosystem, roots) {
|
|
|
3077
3078
|
};
|
|
3078
3079
|
const loadedByOthers = (run, key) => (loaders.get(normalizePathKey(key)) ?? 0) - ([...run.membership.dirs, ...run.membership.files].some(candidate => normalizePathKey(candidate) === normalizePathKey(key)) ? 1 : 0) > 0;
|
|
3079
3080
|
// Covering a run takes another loading its root or something it loads.
|
|
3080
|
-
const mayBeCovered = run => [buildRootPath(run.root), ...(buildFiles.byFile ? [] : buildFiles.names.map(name => path.join(run.root.dir, name))), run.root.dir, ...run.membership.dirs, ...run.membership.files].some(key => loadedByOthers(run, key));
|
|
3081
|
+
const mayBeCovered = run => [utils.buildRootPath(run.root), ...(buildFiles.byFile ? [] : buildFiles.names.map(name => path.join(run.root.dir, name))), run.root.dir, ...run.membership.dirs, ...run.membership.files].some(key => loadedByOthers(run, key));
|
|
3081
3082
|
for (const membership of [...skipped, ...ordered.map(r => r.membership)]) {
|
|
3082
3083
|
count(membership, 1);
|
|
3083
3084
|
}
|
|
@@ -3160,7 +3161,7 @@ async function walkTool(ctx, ecosystem, roots) {
|
|
|
3160
3161
|
unsettled = true;
|
|
3161
3162
|
} else {
|
|
3162
3163
|
failures.push(next);
|
|
3163
|
-
utils.logger.fail(`Could not load ${buildRootPath(next.root)} to tell which builds to skip with it (${why}). Fix its settings, or skip its whole directory instead, with \`${DSI_SETUP_COMMAND}\`.`);
|
|
3164
|
+
utils.logger.fail(`Could not load ${utils.buildRootPath(next.root)} to tell which builds to skip with it (${why}). Fix its settings, or skip its whole directory instead, with \`${DSI_SETUP_COMMAND}\`.`);
|
|
3164
3165
|
}
|
|
3165
3166
|
continue;
|
|
3166
3167
|
}
|
|
@@ -3189,7 +3190,7 @@ async function walkTool(ctx, ecosystem, roots) {
|
|
|
3189
3190
|
// eslint-disable-next-line no-await-in-loop
|
|
3190
3191
|
await (ownRun ? isRunCovered(loader.membership, ownRun) : isLoadedBy(loader.membership, candidate))) {
|
|
3191
3192
|
return {
|
|
3192
|
-
path: buildRootPath(loader.root),
|
|
3193
|
+
path: utils.buildRootPath(loader.root),
|
|
3193
3194
|
skipped: loader.skipped
|
|
3194
3195
|
};
|
|
3195
3196
|
}
|
|
@@ -3226,7 +3227,7 @@ async function walkTool(ctx, ecosystem, roots) {
|
|
|
3226
3227
|
// eslint-disable-next-line no-await-in-loop
|
|
3227
3228
|
const loader = await loaderOf(candidate);
|
|
3228
3229
|
if (run.result) {
|
|
3229
|
-
utils.logger.info(`Dropping the Socket facts of ${buildRootPath(root)}: ${describeLoader(loader)}.`);
|
|
3230
|
+
utils.logger.info(`Dropping the Socket facts of ${utils.buildRootPath(root)}: ${describeLoader(loader)}.`);
|
|
3230
3231
|
if (!keptTargets.has(run.result.targetPath)) {
|
|
3231
3232
|
discardedFactsPath = run.result.targetPath;
|
|
3232
3233
|
}
|
|
@@ -3238,7 +3239,7 @@ async function walkTool(ctx, ecosystem, roots) {
|
|
|
3238
3239
|
status = 'skippedCovered';
|
|
3239
3240
|
} else {
|
|
3240
3241
|
status = 'skippedDisabled';
|
|
3241
|
-
utils.logger.warn(`Skipping ${withModules(buildRootPath(root), loads.get(index).modules)}: ${describeDisabledBy(ecosystem, resolvedFor(candidate).disabledBy)}.`);
|
|
3242
|
+
utils.logger.warn(`Skipping ${withModules(utils.buildRootPath(root), loads.get(index).modules)}: ${describeDisabledBy(ecosystem, resolvedFor(candidate).disabledBy)}.`);
|
|
3242
3243
|
}
|
|
3243
3244
|
} else if (failures.includes(candidate)) {
|
|
3244
3245
|
if (uncoveredFailures.includes(candidate)) {
|
|
@@ -3247,7 +3248,7 @@ async function walkTool(ctx, ecosystem, roots) {
|
|
|
3247
3248
|
// eslint-disable-next-line no-await-in-loop
|
|
3248
3249
|
const loader = await loaderOf(candidate);
|
|
3249
3250
|
if (skipOf(candidate) !== 'load') {
|
|
3250
|
-
utils.logger.info(`${buildRootPath(root)} failed to generate Socket facts on its own, but ${describeLoader(loader)}, so its failure is ignored.`);
|
|
3251
|
+
utils.logger.info(`${utils.buildRootPath(root)} failed to generate Socket facts on its own, but ${describeLoader(loader)}, so its failure is ignored.`);
|
|
3251
3252
|
}
|
|
3252
3253
|
status = statusOf(loader);
|
|
3253
3254
|
}
|
|
@@ -3281,7 +3282,7 @@ async function walkTool(ctx, ecosystem, roots) {
|
|
|
3281
3282
|
for (const failure of uncoveredFailures) {
|
|
3282
3283
|
const aborted = candidates.filter(candidate => isAborted(candidate) && !failures.includes(candidate) && isPathInside$1(failure.root.dir, candidate.root.dir));
|
|
3283
3284
|
if (aborted.length) {
|
|
3284
|
-
utils.logger.warn(`Not building ${aborted.length} ${ecosystem} build root(s) in or under ${displayPath(failure.root.dir)}: ${buildRootPath(failure.root)} failed, and without it they cannot be told apart from its modules.`);
|
|
3285
|
+
utils.logger.warn(`Not building ${aborted.length} ${ecosystem} build root(s) in or under ${displayPath(failure.root.dir)}: ${utils.buildRootPath(failure.root)} failed, and without it they cannot be told apart from its modules.`);
|
|
3285
3286
|
}
|
|
3286
3287
|
}
|
|
3287
3288
|
return outcomes;
|
|
@@ -3294,7 +3295,7 @@ async function warnUnappliedEntry(candidate, entryKey, loaderOf) {
|
|
|
3294
3295
|
return;
|
|
3295
3296
|
}
|
|
3296
3297
|
const loader = await loaderOf();
|
|
3297
|
-
utils.logger.warn(`${buildsSetting(entryKey)} in ${socketJsonPath(candidate.root.dir)} does not apply: ${loader?.path ?? 'another build'} builds ${buildRootPath(candidate.root)} with its own settings.`);
|
|
3298
|
+
utils.logger.warn(`${buildsSetting(entryKey)} in ${socketJsonPath(candidate.root.dir)} does not apply: ${loader?.path ?? 'another build'} builds ${utils.buildRootPath(candidate.root)} with its own settings.`);
|
|
3298
3299
|
}
|
|
3299
3300
|
|
|
3300
3301
|
// Shared by listing and generation, so both run the same Coana, org and hints.
|
|
@@ -3394,7 +3395,7 @@ async function generateRecursiveManifests({
|
|
|
3394
3395
|
1: roots
|
|
3395
3396
|
} of candidatesByTool) {
|
|
3396
3397
|
for (const root of roots) {
|
|
3397
|
-
resolveSettings(tool, root);
|
|
3398
|
+
reachabilityOf(context, tool, resolveSettings(tool, root));
|
|
3398
3399
|
}
|
|
3399
3400
|
}
|
|
3400
3401
|
// A failure another build excuses leaves the exit code it set.
|
|
@@ -3439,13 +3440,13 @@ function resolveEcosystemConfig(ecosystem, dir, sockJson) {
|
|
|
3439
3440
|
if (ecosystem === 'dotnet') {
|
|
3440
3441
|
const config = sockJson.defaults?.manifest?.dotnet;
|
|
3441
3442
|
return {
|
|
3442
|
-
bin: config?.bin || resolveBuildToolBin('dotnet', dir),
|
|
3443
|
+
bin: config?.bin || utils.resolveBuildToolBin('dotnet', dir),
|
|
3443
3444
|
buildOpts: parseBuildToolOpts(config?.dotnetOpts ?? undefined),
|
|
3444
3445
|
excludeConfigs: config?.excludeConfigs ?? '',
|
|
3445
3446
|
ignoreUnresolved: Boolean(config?.ignoreUnresolved),
|
|
3446
3447
|
includeConfigs: config?.includeConfigs ?? '',
|
|
3447
3448
|
javaHome: undefined,
|
|
3448
|
-
skipReason: getSkipReason(ecosystem, config
|
|
3449
|
+
skipReason: getSkipReason(ecosystem, config),
|
|
3449
3450
|
verbose: Boolean(config?.verbose)
|
|
3450
3451
|
};
|
|
3451
3452
|
}
|
|
@@ -3459,7 +3460,7 @@ function resolveEcosystemConfig(ecosystem, dir, sockJson) {
|
|
|
3459
3460
|
ignoreUnresolved: Boolean(config?.ignoreUnresolved),
|
|
3460
3461
|
includeConfigs: config?.includeConfigs ?? '',
|
|
3461
3462
|
javaHome: config?.javaHome ?? undefined,
|
|
3462
|
-
skipReason: getSkipReason(ecosystem, config
|
|
3463
|
+
skipReason: getSkipReason(ecosystem, config),
|
|
3463
3464
|
verbose: Boolean(config?.verbose)
|
|
3464
3465
|
};
|
|
3465
3466
|
}
|
|
@@ -3467,26 +3468,26 @@ function resolveEcosystemConfig(ecosystem, dir, sockJson) {
|
|
|
3467
3468
|
const config = sockJson.defaults?.manifest?.gradle;
|
|
3468
3469
|
const bin = config?.bin ?? undefined;
|
|
3469
3470
|
return {
|
|
3470
|
-
bin: bin ? path.resolve(dir, bin) : resolveBuildToolBin('gradle', dir),
|
|
3471
|
+
bin: bin ? path.resolve(dir, bin) : utils.resolveBuildToolBin('gradle', dir),
|
|
3471
3472
|
buildOpts: parseBuildToolOpts(config?.gradleOpts ?? undefined),
|
|
3472
3473
|
excludeConfigs: config?.excludeConfigs ?? '',
|
|
3473
3474
|
ignoreUnresolved: Boolean(config?.ignoreUnresolved),
|
|
3474
3475
|
includeConfigs: config?.includeConfigs ?? '',
|
|
3475
3476
|
javaHome: config?.javaHome ?? undefined,
|
|
3476
|
-
skipReason: getSkipReason(ecosystem, config
|
|
3477
|
+
skipReason: getSkipReason(ecosystem, config),
|
|
3477
3478
|
verbose: Boolean(config?.verbose)
|
|
3478
3479
|
};
|
|
3479
3480
|
}
|
|
3480
3481
|
const config = sockJson.defaults?.manifest?.maven;
|
|
3481
3482
|
const bin = config?.bin ?? undefined;
|
|
3482
3483
|
return {
|
|
3483
|
-
bin: bin ?? resolveBuildToolBin('maven', dir),
|
|
3484
|
+
bin: bin ?? utils.resolveBuildToolBin('maven', dir),
|
|
3484
3485
|
buildOpts: parseBuildToolOpts(config?.mavenOpts ?? undefined),
|
|
3485
3486
|
excludeConfigs: config?.excludeConfigs ?? '',
|
|
3486
3487
|
ignoreUnresolved: Boolean(config?.ignoreUnresolved),
|
|
3487
3488
|
includeConfigs: config?.includeConfigs ?? '',
|
|
3488
3489
|
javaHome: config?.javaHome ?? undefined,
|
|
3489
|
-
skipReason: getSkipReason(ecosystem, config
|
|
3490
|
+
skipReason: getSkipReason(ecosystem, config),
|
|
3490
3491
|
verbose: Boolean(config?.verbose)
|
|
3491
3492
|
};
|
|
3492
3493
|
}
|
|
@@ -3523,12 +3524,12 @@ async function runDynamicSbomInference({
|
|
|
3523
3524
|
purlTypes,
|
|
3524
3525
|
verbose: false
|
|
3525
3526
|
});
|
|
3526
|
-
const factsOnlyTypes = [...new Set(outcomes.map(o => PURL_TYPE_BY_TOOL[o.ecosystem]))];
|
|
3527
|
+
const factsOnlyTypes = [...new Set(outcomes.map(o => utils.PURL_TYPE_BY_TOOL[o.ecosystem]))];
|
|
3527
3528
|
// No candidates discovered at all (distinct from candidates that were found
|
|
3528
3529
|
// but produced no generated facts - empty/skippedDisabled are already warned
|
|
3529
3530
|
// about elsewhere and are not this kind of mistake).
|
|
3530
3531
|
if (!utils.isFactsOnlyTypes(factsOnlyTypes)) {
|
|
3531
|
-
throw new utils.InputError([`No ${utils.joinOr(buildToolLabelsFor(purlTypes))} build root was found.`, '', '- Select other ecosystems with --dynamic-sbom-inference-ecosystems, or remove --dynamic-sbom-inference.', '- Make sure to run it from the correct dir (use --cwd to target another dir).'].join('\n'));
|
|
3532
|
+
throw new utils.InputError([`No ${utils.joinOr(utils.buildToolLabelsFor(purlTypes))} build root was found.`, '', '- Select other ecosystems with --dynamic-sbom-inference-ecosystems, or remove --dynamic-sbom-inference.', '- Make sure to run it from the correct dir (use --cwd to target another dir).'].join('\n'));
|
|
3532
3533
|
}
|
|
3533
3534
|
// Fail loud rather than silently proceed with a partial multi-root result:
|
|
3534
3535
|
// matches handleManifestDynamicSbomInference's own check.
|
|
@@ -6467,7 +6468,7 @@ async function convertGradleToMaven({
|
|
|
6467
6468
|
|
|
6468
6469
|
let selectedBin;
|
|
6469
6470
|
try {
|
|
6470
|
-
selectedBin = resolveBuildToolBin('gradle', cwd, bin, utils.isSea());
|
|
6471
|
+
selectedBin = utils.resolveBuildToolBin('gradle', cwd, bin, utils.isSea());
|
|
6471
6472
|
} catch (error) {
|
|
6472
6473
|
process.exitCode = 1;
|
|
6473
6474
|
utils.logger.fail(error instanceof Error ? error.message : String(error));
|
|
@@ -6618,7 +6619,7 @@ async function convertSbtToMaven({
|
|
|
6618
6619
|
|
|
6619
6620
|
let selectedBin;
|
|
6620
6621
|
try {
|
|
6621
|
-
selectedBin = resolveBuildToolBin('sbt', cwd, bin, utils.isSea());
|
|
6622
|
+
selectedBin = utils.resolveBuildToolBin('sbt', cwd, bin, utils.isSea());
|
|
6622
6623
|
} catch (error) {
|
|
6623
6624
|
process.exitCode = 1;
|
|
6624
6625
|
utils.logger.fail(error instanceof Error ? error.message : String(error));
|
|
@@ -7191,7 +7192,7 @@ async function createNewScan({
|
|
|
7191
7192
|
if (reach.dynamicSbomInference) {
|
|
7192
7193
|
// Already generated recursively above; resolving cwd's own build
|
|
7193
7194
|
// root a second time would race on the same facts file.
|
|
7194
|
-
for (const tool of buildToolsFor(reach.dynamicSbomInference)) {
|
|
7195
|
+
for (const tool of utils.buildToolsFor(reach.dynamicSbomInference)) {
|
|
7195
7196
|
detected[tool] = false;
|
|
7196
7197
|
}
|
|
7197
7198
|
}
|
|
@@ -8855,17 +8856,13 @@ async function generateSocketFactsForFix({
|
|
|
8855
8856
|
})));
|
|
8856
8857
|
await restoreAll(originals);
|
|
8857
8858
|
};
|
|
8858
|
-
let artifactsFlags;
|
|
8859
8859
|
let discardedPaths;
|
|
8860
|
+
let factsOnlyTypes;
|
|
8860
8861
|
let paths;
|
|
8861
8862
|
const sidecarFile = path.join(tmpDir, 'sidecar.json');
|
|
8862
8863
|
const workDir = await createSocketFactsWorkDir(path.join(tmpDir, 'work'), 'fix');
|
|
8863
8864
|
try {
|
|
8864
|
-
const {
|
|
8865
|
-
discardedFactsPaths,
|
|
8866
|
-
factsOnlyTypes,
|
|
8867
|
-
factsPaths
|
|
8868
|
-
} = await runDynamicSbomInference({
|
|
8865
|
+
const inferred = await runDynamicSbomInference({
|
|
8869
8866
|
context: {
|
|
8870
8867
|
...context,
|
|
8871
8868
|
workDir
|
|
@@ -8875,9 +8872,9 @@ async function generateSocketFactsForFix({
|
|
|
8875
8872
|
hints: EXCLUDE_PATHS_HINTS,
|
|
8876
8873
|
purlTypes
|
|
8877
8874
|
});
|
|
8878
|
-
|
|
8879
|
-
|
|
8880
|
-
paths = factsPaths.map(p => path.resolve(cwd, p));
|
|
8875
|
+
discardedPaths = inferred.discardedFactsPaths;
|
|
8876
|
+
factsOnlyTypes = inferred.factsOnlyTypes;
|
|
8877
|
+
paths = inferred.factsPaths.map(p => path.resolve(cwd, p));
|
|
8881
8878
|
// Written even when empty, as for reach; applying fixes looks each facts
|
|
8882
8879
|
// file up in it, so an empty one is the same as none.
|
|
8883
8880
|
await fs.writeFile(sidecarFile, JSON.stringify(socketFactsSidecar(workDir)));
|
|
@@ -8891,8 +8888,8 @@ async function generateSocketFactsForFix({
|
|
|
8891
8888
|
source
|
|
8892
8889
|
}) => !generated.has(source)), ...(await backUp(paths, path.join(tmpDir, 'generated')))];
|
|
8893
8890
|
return {
|
|
8894
|
-
artifactsFlags,
|
|
8895
8891
|
discardedPaths,
|
|
8892
|
+
factsOnlyTypes,
|
|
8896
8893
|
paths,
|
|
8897
8894
|
sidecarFile,
|
|
8898
8895
|
remove: () => reset(paths),
|
|
@@ -9144,7 +9141,7 @@ async function coanaFixWithFacts(fixConfig, factsSlot) {
|
|
|
9144
9141
|
const sidecarFile = factsSlot?.generated?.sidecarFile;
|
|
9145
9142
|
// Discovery reads the artifacts resolved by the facts files.
|
|
9146
9143
|
// Applying a fix also reads the saved state for each build root.
|
|
9147
|
-
const discoveryFlags = factsSlot?.generated
|
|
9144
|
+
const discoveryFlags = factsSlot?.generated ? utils.useOnlySocketFactsArtifactsFlags(factsSlot.generated.factsOnlyTypes) : [];
|
|
9148
9145
|
const factsFlags = [...discoveryFlags, ...(sidecarFile ? ['--socket-facts-sidecar', sidecarFile] : [])];
|
|
9149
9146
|
const uploadCResult = await utils.handleApiCall(sockSdk.uploadManifestFiles(orgSlug, scanFilepaths, {
|
|
9150
9147
|
pathsRelativeTo: cwd
|
|
@@ -9769,7 +9766,7 @@ const dynamicSbomInferenceEcosystemsFlags = {
|
|
|
9769
9766
|
dynamicSbomInferenceEcosystems: {
|
|
9770
9767
|
type: 'string',
|
|
9771
9768
|
isMultiple: true,
|
|
9772
|
-
description: `With --dynamic-sbom-inference: generate Socket facts only for these ecosystems, as either a comma separated value or as multiple flags; the others keep their manifest files as they are. Supported: ${utils.joinAnd(FACTS_PURL_TYPES.map(t => `${t} (${utils.joinAnd(buildToolLabelsFor([t]))})`))}. Defaults to all of them.`
|
|
9769
|
+
description: `With --dynamic-sbom-inference: generate Socket facts only for these ecosystems, as either a comma separated value or as multiple flags; the others keep their manifest files as they are. Supported: ${utils.joinAnd(utils.FACTS_PURL_TYPES.map(t => `${t} (${utils.joinAnd(utils.buildToolLabelsFor([t]))})`))}. Defaults to all of them.`
|
|
9773
9770
|
}
|
|
9774
9771
|
};
|
|
9775
9772
|
function parseDynamicSbomInferenceFlags(flags) {
|
|
@@ -9780,8 +9777,8 @@ function parseDynamicSbomInferenceFlags(flags) {
|
|
|
9780
9777
|
}
|
|
9781
9778
|
return undefined;
|
|
9782
9779
|
}
|
|
9783
|
-
const selected = utils.parseEcosystemChoices(raw, FACTS_PURL_TYPES);
|
|
9784
|
-
return utils.isFactsOnlyTypes(selected) ? selected : FACTS_PURL_TYPES;
|
|
9780
|
+
const selected = utils.parseEcosystemChoices(raw, utils.FACTS_PURL_TYPES);
|
|
9781
|
+
return utils.isFactsOnlyTypes(selected) ? selected : utils.FACTS_PURL_TYPES;
|
|
9785
9782
|
}
|
|
9786
9783
|
const reachabilityFlags = {
|
|
9787
9784
|
reachVersion: {
|
|
@@ -13549,7 +13546,7 @@ async function run$F(argv, importMeta, {
|
|
|
13549
13546
|
|
|
13550
13547
|
function renderTable(outcomes) {
|
|
13551
13548
|
// A covered reactor member is implied by its parent's line above it.
|
|
13552
|
-
return outcomes.filter(o => o.status !== 'skippedCovered').map(o => `- ${buildRootPath(o)} (${o.ecosystem}): ${o.status}${o.factsPath ? ` -> ${o.factsPath}` : ''}`).join('\n');
|
|
13549
|
+
return outcomes.filter(o => o.status !== 'skippedCovered').map(o => `- ${utils.buildRootPath(o)} (${o.ecosystem}): ${o.status}${o.factsPath ? ` -> ${o.factsPath}` : ''}`).join('\n');
|
|
13553
13550
|
}
|
|
13554
13551
|
function summarize(outcomes) {
|
|
13555
13552
|
const generated = outcomes.filter(o => o.status === 'generated').length;
|
|
@@ -13847,7 +13844,7 @@ async function run$D(argv, importMeta, {
|
|
|
13847
13844
|
utils.logger.info(`Using default --bin from ${constants.SOCKET_JSON}:`, bin);
|
|
13848
13845
|
} else {
|
|
13849
13846
|
// Prefer the project's ./gradlew wrapper, else `gradle` on PATH.
|
|
13850
|
-
bin = resolveBuildToolBin('gradle', cwd);
|
|
13847
|
+
bin = utils.resolveBuildToolBin('gradle', cwd);
|
|
13851
13848
|
}
|
|
13852
13849
|
}
|
|
13853
13850
|
if (!gradleOpts) {
|
|
@@ -14102,7 +14099,7 @@ async function run$C(argv, importMeta, {
|
|
|
14102
14099
|
utils.logger.info(`Using default --bin from ${constants.SOCKET_JSON}:`, bin);
|
|
14103
14100
|
} else {
|
|
14104
14101
|
// Prefer the project's ./gradlew wrapper, else `gradle` on PATH.
|
|
14105
|
-
bin = resolveBuildToolBin('gradle', cwd);
|
|
14102
|
+
bin = utils.resolveBuildToolBin('gradle', cwd);
|
|
14106
14103
|
}
|
|
14107
14104
|
}
|
|
14108
14105
|
if (!gradleOpts) {
|
|
@@ -14333,7 +14330,7 @@ async function run$B(argv, importMeta, {
|
|
|
14333
14330
|
utils.logger.info(`Using default --bin from ${constants.SOCKET_JSON}:`, bin);
|
|
14334
14331
|
} else {
|
|
14335
14332
|
// Prefer the project's ./mvnw wrapper, else `mvn` on PATH.
|
|
14336
|
-
bin = resolveBuildToolBin('maven', cwd);
|
|
14333
|
+
bin = utils.resolveBuildToolBin('maven', cwd);
|
|
14337
14334
|
}
|
|
14338
14335
|
}
|
|
14339
14336
|
if (!mavenOpts) {
|
|
@@ -14726,6 +14723,24 @@ async function outputManifestSetup(result) {
|
|
|
14726
14723
|
utils.logger.success('Setup complete');
|
|
14727
14724
|
}
|
|
14728
14725
|
|
|
14726
|
+
const REACHABILITY_VALUE_PROMPTS = {
|
|
14727
|
+
__proto__: null,
|
|
14728
|
+
javaHome: {
|
|
14729
|
+
ask: current => askForJavaHome(current, 'What JDK should reachability analysis use?'),
|
|
14730
|
+
change: 'Use a different Java for reachability analysis?',
|
|
14731
|
+
keep: 'as the JDK for reachability analysis',
|
|
14732
|
+
set: 'Set the JDK reachability analysis uses',
|
|
14733
|
+
unset: 'Leave the JDK for reachability analysis unset'
|
|
14734
|
+
},
|
|
14735
|
+
runtimeVersion: {
|
|
14736
|
+
ask: askForRuntimeVersion,
|
|
14737
|
+
change: 'Start the reachability analysis of a framework-dependent .NET build on a given runtime?',
|
|
14738
|
+
keep: 'as the .NET runtime',
|
|
14739
|
+
set: 'Set the runtime the analysis starts on',
|
|
14740
|
+
unset: "Let the analysis take the runtime the build's dotnet rolls forward to"
|
|
14741
|
+
}
|
|
14742
|
+
};
|
|
14743
|
+
|
|
14729
14744
|
// Whether the prompt was canceled. A blank answer clears a value set before
|
|
14730
14745
|
// with null rather than deleting the key, so it doesn't silently start
|
|
14731
14746
|
// inheriting an ancestor's value again.
|
|
@@ -15189,13 +15204,23 @@ async function askForBin(defaultName = '', fallbackHint = '') {
|
|
|
15189
15204
|
// validate: async string => bool
|
|
15190
15205
|
});
|
|
15191
15206
|
}
|
|
15192
|
-
async function askForJavaHome(defaultName = '') {
|
|
15207
|
+
async function askForJavaHome(defaultName = '', question = 'What JDK should this build tool use? Leave blank to use the JDK already on PATH/JAVA_HOME.') {
|
|
15193
15208
|
return await utils.input({
|
|
15194
|
-
message:
|
|
15209
|
+
message: `${question} Supports $VAR/\${VAR}.` + (defaultName ? ' (Backspace to leave default)' : ''),
|
|
15195
15210
|
default: defaultName,
|
|
15196
15211
|
required: false
|
|
15197
15212
|
});
|
|
15198
15213
|
}
|
|
15214
|
+
async function askForRuntimeVersion(current) {
|
|
15215
|
+
return await utils.input({
|
|
15216
|
+
message: `Which .NET runtime? Enter ${DOTNET_RUNTIME_VERSION_FORMAT}.` + (current ? ' (Backspace to leave default)' : ''),
|
|
15217
|
+
default: current,
|
|
15218
|
+
required: false,
|
|
15219
|
+
validate: value => !value || !parseReachability('dotnet', {
|
|
15220
|
+
runtimeVersion: value
|
|
15221
|
+
}).problems.length || `Enter ${DOTNET_RUNTIME_VERSION_FORMAT}.`
|
|
15222
|
+
});
|
|
15223
|
+
}
|
|
15199
15224
|
async function askForVerboseFlag(current) {
|
|
15200
15225
|
return await utils.select({
|
|
15201
15226
|
message: '(--verbose) Should this run in verbose mode by default?',
|
|
@@ -15254,6 +15279,121 @@ async function askForIgnoreUnresolvedFlag(current) {
|
|
|
15254
15279
|
});
|
|
15255
15280
|
}
|
|
15256
15281
|
|
|
15282
|
+
// The wizard replaces invalid values with the answers, except one the build
|
|
15283
|
+
// inherits: that one needs fixing in the socket.json that sets it.
|
|
15284
|
+
function warnInvalidReachability(tool, problems, inherited) {
|
|
15285
|
+
for (const {
|
|
15286
|
+
field,
|
|
15287
|
+
value
|
|
15288
|
+
} of problems) {
|
|
15289
|
+
let parent;
|
|
15290
|
+
let setting;
|
|
15291
|
+
let reason;
|
|
15292
|
+
if (field === undefined) {
|
|
15293
|
+
parent = inherited;
|
|
15294
|
+
setting = 'reachability';
|
|
15295
|
+
reason = 'is not an object';
|
|
15296
|
+
} else {
|
|
15297
|
+
parent = utils.isRecord(inherited) ? inherited[field] : undefined;
|
|
15298
|
+
setting = `reachability.${field}`;
|
|
15299
|
+
reason = `is not a value ${tool} builds take`;
|
|
15300
|
+
}
|
|
15301
|
+
const shown = `\`${setting}\` (${JSON.stringify(value)})`;
|
|
15302
|
+
utils.logger.warn(require$$1.isDeepStrictEqual(value, parent) ? `${shown}, which this build inherits, ${reason}; fix it in the socket.json that sets it, or reachability scans fail.` : `Replacing ${shown}, which ${reason}.`);
|
|
15303
|
+
}
|
|
15304
|
+
}
|
|
15305
|
+
|
|
15306
|
+
// Answering no keeps the value in effect; "none" overrides an inherited
|
|
15307
|
+
// "compile".
|
|
15308
|
+
async function setupReachability(tool, config, inheritedReachability) {
|
|
15309
|
+
const {
|
|
15310
|
+
problems,
|
|
15311
|
+
settings: reachability
|
|
15312
|
+
} = parseReachability(tool, config.reachability);
|
|
15313
|
+
warnInvalidReachability(tool, problems, inheritedReachability);
|
|
15314
|
+
const {
|
|
15315
|
+
settings: inherited
|
|
15316
|
+
} = parseReachability(tool, inheritedReachability);
|
|
15317
|
+
// An invalid value of its own leaves the inherited one in effect.
|
|
15318
|
+
const effective = {
|
|
15319
|
+
...inherited,
|
|
15320
|
+
...reachability
|
|
15321
|
+
};
|
|
15322
|
+
const wantsBuild = await utils.select({
|
|
15323
|
+
message: 'Build project before reachability analysis? Note: A failed build fails the scan.',
|
|
15324
|
+
choices: [{
|
|
15325
|
+
name: 'no',
|
|
15326
|
+
value: false,
|
|
15327
|
+
description: 'Analyze the project without building it'
|
|
15328
|
+
}, {
|
|
15329
|
+
name: 'yes',
|
|
15330
|
+
value: true,
|
|
15331
|
+
description: 'Compile the project before reachability analysis'
|
|
15332
|
+
}],
|
|
15333
|
+
default: effective.build === 'compile'
|
|
15334
|
+
});
|
|
15335
|
+
if (wantsBuild === undefined) {
|
|
15336
|
+
return canceledByUser$2();
|
|
15337
|
+
}
|
|
15338
|
+
if (wantsBuild) {
|
|
15339
|
+
reachability.build = 'compile';
|
|
15340
|
+
} else if (inherited.build === 'compile') {
|
|
15341
|
+
reachability.build = 'none';
|
|
15342
|
+
} else {
|
|
15343
|
+
delete reachability.build;
|
|
15344
|
+
}
|
|
15345
|
+
|
|
15346
|
+
// Whether the prompt was canceled.
|
|
15347
|
+
const askValue = async field => {
|
|
15348
|
+
const prompts = REACHABILITY_VALUE_PROMPTS[field];
|
|
15349
|
+
const current = effective[field];
|
|
15350
|
+
const wantsValue = await utils.select({
|
|
15351
|
+
message: prompts.change,
|
|
15352
|
+
choices: [{
|
|
15353
|
+
name: 'no',
|
|
15354
|
+
value: false,
|
|
15355
|
+
description: current ? `Keep ${current} ${prompts.keep}${current === inherited[field] ? ', which it inherits' : ''}` : prompts.unset
|
|
15356
|
+
}, {
|
|
15357
|
+
name: 'yes',
|
|
15358
|
+
value: true,
|
|
15359
|
+
description: prompts.set
|
|
15360
|
+
}],
|
|
15361
|
+
default: !!current
|
|
15362
|
+
});
|
|
15363
|
+
if (wantsValue === undefined) {
|
|
15364
|
+
return true;
|
|
15365
|
+
}
|
|
15366
|
+
if (!wantsValue) {
|
|
15367
|
+
return false;
|
|
15368
|
+
}
|
|
15369
|
+
const answer = await prompts.ask(current || '');
|
|
15370
|
+
if (answer === undefined) {
|
|
15371
|
+
return true;
|
|
15372
|
+
}
|
|
15373
|
+
if (answer) {
|
|
15374
|
+
reachability[field] = answer;
|
|
15375
|
+
} else if (inherited[field]) {
|
|
15376
|
+
// Clears the value rather than inheriting it again.
|
|
15377
|
+
reachability[field] = null;
|
|
15378
|
+
} else {
|
|
15379
|
+
delete reachability[field];
|
|
15380
|
+
}
|
|
15381
|
+
return false;
|
|
15382
|
+
};
|
|
15383
|
+
for (const field of reachabilityFieldsOf(tool)) {
|
|
15384
|
+
// eslint-disable-next-line no-await-in-loop
|
|
15385
|
+
if (field !== 'build' && (await askValue(field))) {
|
|
15386
|
+
return canceledByUser$2();
|
|
15387
|
+
}
|
|
15388
|
+
}
|
|
15389
|
+
if (Object.keys(reachability).length) {
|
|
15390
|
+
config.reachability = reachability;
|
|
15391
|
+
} else {
|
|
15392
|
+
delete config.reachability;
|
|
15393
|
+
}
|
|
15394
|
+
return notCanceled$2();
|
|
15395
|
+
}
|
|
15396
|
+
|
|
15257
15397
|
// Prompts for the facts-only options every facts generator shares: the config
|
|
15258
15398
|
// include/exclude filters and --ignore-unresolved. Mutates `config` in place.
|
|
15259
15399
|
async function setupFactsOptions(config, configNoun = 'config-name') {
|
|
@@ -15322,6 +15462,25 @@ function notCanceled$1() {
|
|
|
15322
15462
|
}
|
|
15323
15463
|
};
|
|
15324
15464
|
}
|
|
15465
|
+
|
|
15466
|
+
// A nested section (`reachability`) compares field by field, as the cascade
|
|
15467
|
+
// merges it.
|
|
15468
|
+
function changedFields(seed, inherited) {
|
|
15469
|
+
const changed = {};
|
|
15470
|
+
for (const key of Object.keys(seed)) {
|
|
15471
|
+
const value = seed[key];
|
|
15472
|
+
const base = inherited[key];
|
|
15473
|
+
if (utils.isRecord(value) && utils.isRecord(base)) {
|
|
15474
|
+
const nested = changedFields(value, base);
|
|
15475
|
+
if (Object.keys(nested).length) {
|
|
15476
|
+
changed[key] = nested;
|
|
15477
|
+
}
|
|
15478
|
+
} else if (value !== base) {
|
|
15479
|
+
changed[key] = value;
|
|
15480
|
+
}
|
|
15481
|
+
}
|
|
15482
|
+
return changed;
|
|
15483
|
+
}
|
|
15325
15484
|
function getEcosystemSection(sockJson, ecosystem) {
|
|
15326
15485
|
return sockJson.defaults?.manifest?.[ecosystem] ?? {};
|
|
15327
15486
|
}
|
|
@@ -15385,7 +15544,7 @@ async function discoverBuildRoots({
|
|
|
15385
15544
|
const ignorePatterns = (excludePaths ?? []).flatMap(excludePathToScanIgnores);
|
|
15386
15545
|
const ecosystemsByRoot = new Map();
|
|
15387
15546
|
for (const [ecosystem, fullRoots] of fullByTool) {
|
|
15388
|
-
const includedPaths = new Set((includedByTool.get(ecosystem) ?? []).map(buildRootPath));
|
|
15547
|
+
const includedPaths = new Set((includedByTool.get(ecosystem) ?? []).map(utils.buildRootPath));
|
|
15389
15548
|
const rootsByDir = new Map();
|
|
15390
15549
|
for (const root of fullRoots) {
|
|
15391
15550
|
if (root.dir === realCwd) {
|
|
@@ -15406,7 +15565,7 @@ async function discoverBuildRoots({
|
|
|
15406
15565
|
const includedRoots = [];
|
|
15407
15566
|
const excludedRoots = [];
|
|
15408
15567
|
for (const root of roots) {
|
|
15409
|
-
if (includedPaths.has(buildRootPath(root))) {
|
|
15568
|
+
if (includedPaths.has(utils.buildRootPath(root))) {
|
|
15410
15569
|
includedRoots.push(root);
|
|
15411
15570
|
} else {
|
|
15412
15571
|
excludedRoots.push(root);
|
|
@@ -15506,6 +15665,12 @@ function draftChain(draft, dir) {
|
|
|
15506
15665
|
function draftCascade(draft, dir) {
|
|
15507
15666
|
return utils.mergeSocketJsonChain(draftChain(draft, dir));
|
|
15508
15667
|
}
|
|
15668
|
+
|
|
15669
|
+
// What `dir`'s own socket.json inherits.
|
|
15670
|
+
function draftParentCascade(draft, dir) {
|
|
15671
|
+
const own = path.resolve(dir);
|
|
15672
|
+
return utils.mergeSocketJsonChain(draftChain(draft, dir).filter(file => file.dir !== own));
|
|
15673
|
+
}
|
|
15509
15674
|
function resolveDraftSettings(draft, ecosystem, root) {
|
|
15510
15675
|
draft.resolver ??= createBuildRootSettingsResolver(dir => draftChain(draft, dir), draft.warned);
|
|
15511
15676
|
return draft.resolver(ecosystem, root);
|
|
@@ -15526,14 +15691,14 @@ function buildKey({
|
|
|
15526
15691
|
ecosystem,
|
|
15527
15692
|
root
|
|
15528
15693
|
}) {
|
|
15529
|
-
return `${ecosystem}\0${buildRootPath(root)}`;
|
|
15694
|
+
return `${ecosystem}\0${utils.buildRootPath(root)}`;
|
|
15530
15695
|
}
|
|
15531
15696
|
function buildLabel(cwd, {
|
|
15532
15697
|
ecosystem,
|
|
15533
15698
|
root,
|
|
15534
15699
|
sharesDir
|
|
15535
15700
|
}) {
|
|
15536
|
-
const where = sharesDir ? relPath(cwd, buildRootPath(root)) : root.dir === cwd ? 'This project' : relPath(cwd, root.dir);
|
|
15701
|
+
const where = sharesDir ? relPath(cwd, utils.buildRootPath(root)) : root.dir === cwd ? 'This project' : relPath(cwd, root.dir);
|
|
15537
15702
|
return `${where} (${ecosystem})`;
|
|
15538
15703
|
}
|
|
15539
15704
|
|
|
@@ -15543,7 +15708,7 @@ function buildsKeyOf(draft, {
|
|
|
15543
15708
|
ecosystem,
|
|
15544
15709
|
root
|
|
15545
15710
|
}) {
|
|
15546
|
-
const files = BUILD_FILES[ecosystem];
|
|
15711
|
+
const files = utils.BUILD_FILES[ecosystem];
|
|
15547
15712
|
if (files.byFile) {
|
|
15548
15713
|
return root.entryFile ?? '';
|
|
15549
15714
|
}
|
|
@@ -15595,22 +15760,23 @@ async function configureBuild(draft, cwd, build) {
|
|
|
15595
15760
|
} : {
|
|
15596
15761
|
...getEcosystemSection(own, ecosystem)
|
|
15597
15762
|
};
|
|
15598
|
-
const inherited = getEcosystemSection(draftCascade(draft,
|
|
15763
|
+
const inherited = getEcosystemSection(intoEntry ? draftCascade(draft, root.dir) : draftParentCascade(draft, root.dir), ecosystem);
|
|
15599
15764
|
const seed = {
|
|
15600
15765
|
...getEcosystemSection(resolveDraftSettings(draft, ecosystem, root).sockJson, ecosystem)
|
|
15601
15766
|
};
|
|
15602
15767
|
const seeded = Object.keys(seed);
|
|
15603
|
-
const result = await runEcosystemWizard(ecosystem, seed);
|
|
15768
|
+
const result = await runEcosystemWizard(ecosystem, seed, inherited['reachability']);
|
|
15604
15769
|
if (!result.ok || result.data.canceled) {
|
|
15605
15770
|
return result;
|
|
15606
15771
|
}
|
|
15607
15772
|
const before = JSON.stringify(target);
|
|
15773
|
+
const changed = changedFields(seed, inherited);
|
|
15608
15774
|
// An answer the wizard removed leaves the field to inheritance.
|
|
15609
15775
|
for (const field of new Set([...seeded, ...Object.keys(seed)])) {
|
|
15610
|
-
if (
|
|
15611
|
-
|
|
15776
|
+
if (Object.hasOwn(changed, field)) {
|
|
15777
|
+
target[field] = changed[field];
|
|
15612
15778
|
} else {
|
|
15613
|
-
target[field]
|
|
15779
|
+
delete target[field];
|
|
15614
15780
|
}
|
|
15615
15781
|
}
|
|
15616
15782
|
const label = buildLabel(cwd, build);
|
|
@@ -15712,7 +15878,7 @@ async function askCantLoad(walk, build, allowDirectory) {
|
|
|
15712
15878
|
const label = buildLabel(walk.cwd, build);
|
|
15713
15879
|
const relDir = relPath(walk.cwd, build.root.dir);
|
|
15714
15880
|
const beneath = walk.builds.filter(other => other !== build && isPathInside$1(build.root.dir, other.root.dir) && !walk.decided.has(buildKey(other))).length;
|
|
15715
|
-
const skipNotes = [...(beneath ? [`Also skips the ${otherBuilds(beneath)} in and beneath ${relDir}/. To build one of them, run \`${DSI_SETUP_COMMAND}\` in its directory.`] : []), `Modules of ${relPath(walk.cwd, buildRootPath(build.root))} outside ${relDir}/ can't be found without loading it, so they are asked about separately.`];
|
|
15881
|
+
const skipNotes = [...(beneath ? [`Also skips the ${otherBuilds(beneath)} in and beneath ${relDir}/. To build one of them, run \`${DSI_SETUP_COMMAND}\` in its directory.`] : []), `Modules of ${relPath(walk.cwd, utils.buildRootPath(build.root))} outside ${relDir}/ can't be found without loading it, so they are asked about separately.`];
|
|
15716
15882
|
return await utils.select({
|
|
15717
15883
|
message: `Socket could not load ${label} (see above). Builds Socket can load are built once with all their modules, and can be skipped without skipping the builds next to them. What should happen with it?`,
|
|
15718
15884
|
choices: [{
|
|
@@ -15812,7 +15978,7 @@ async function loadInto(walk, build, into, {
|
|
|
15812
15978
|
disableBuild(walk.draft, build);
|
|
15813
15979
|
walk.counts.skipped += 1;
|
|
15814
15980
|
if (announce) {
|
|
15815
|
-
utils.logger.success(`Skipped ${withModules(relPath(walk.cwd, buildRootPath(build.root)), loaded.modules)}.`);
|
|
15981
|
+
utils.logger.success(`Skipped ${withModules(relPath(walk.cwd, utils.buildRootPath(build.root)), loaded.modules)}.`);
|
|
15816
15982
|
}
|
|
15817
15983
|
}
|
|
15818
15984
|
}
|
|
@@ -15907,32 +16073,27 @@ async function reviewBuild(walk, build) {
|
|
|
15907
16073
|
// just skips a project resolved to `facts: false` (see
|
|
15908
16074
|
// generateRecursiveManifests' skipReason), so offering that choice here
|
|
15909
16075
|
// would be misleading.
|
|
15910
|
-
|
|
16076
|
+
// `config` is the section in effect, `inheritedReachability` the
|
|
16077
|
+
// `reachability` it inherits.
|
|
16078
|
+
async function runEcosystemWizard(ecosystem, config, inheritedReachability) {
|
|
16079
|
+
let result;
|
|
15911
16080
|
if (ecosystem === 'dotnet') {
|
|
15912
|
-
|
|
15913
|
-
}
|
|
15914
|
-
|
|
15915
|
-
|
|
16081
|
+
result = await setupDotnet(config);
|
|
16082
|
+
} else if (ecosystem === 'gradle') {
|
|
16083
|
+
result = await setupGradle(config, {
|
|
16084
|
+
factsOnly: true
|
|
16085
|
+
});
|
|
16086
|
+
} else if (ecosystem === 'maven') {
|
|
16087
|
+
result = await setupMaven(config);
|
|
16088
|
+
} else {
|
|
16089
|
+
result = await setupSbt(config, {
|
|
15916
16090
|
factsOnly: true
|
|
15917
16091
|
});
|
|
15918
16092
|
}
|
|
15919
|
-
if (
|
|
15920
|
-
return
|
|
15921
|
-
}
|
|
15922
|
-
return await setupSbt(config, {
|
|
15923
|
-
factsOnly: true
|
|
15924
|
-
});
|
|
15925
|
-
}
|
|
15926
|
-
|
|
15927
|
-
// Accepting every prompt's default leaves an ecosystem's section empty (see
|
|
15928
|
-
// askForBin in setup-manifest-config.mts); an empty one changes nothing.
|
|
15929
|
-
function dropIfEmpty(manifest, ecosystem) {
|
|
15930
|
-
const section = manifest[ecosystem];
|
|
15931
|
-
if (section && Object.keys(section).length) {
|
|
15932
|
-
return true;
|
|
16093
|
+
if (!result.ok || result.data.canceled) {
|
|
16094
|
+
return result;
|
|
15933
16095
|
}
|
|
15934
|
-
|
|
15935
|
-
return false;
|
|
16096
|
+
return await setupReachability(ecosystem, config, inheritedReachability);
|
|
15936
16097
|
}
|
|
15937
16098
|
async function askYesNo(message) {
|
|
15938
16099
|
return await utils.select({
|
|
@@ -15952,7 +16113,7 @@ async function askYesNo(message) {
|
|
|
15952
16113
|
// only build at cwd, without an entry of its own, sets them from its prompt.
|
|
15953
16114
|
async function setupRootDefaults(draft, cwd, ecosystems, buildsAtCwd) {
|
|
15954
16115
|
for (const ecosystem of ecosystems) {
|
|
15955
|
-
const label = ECOSYSTEM_LABELS[ecosystem];
|
|
16116
|
+
const label = utils.ECOSYSTEM_LABELS[ecosystem];
|
|
15956
16117
|
const {
|
|
15957
16118
|
disabledBy
|
|
15958
16119
|
} = resolveDraftSettings(draft, ecosystem, {
|
|
@@ -15995,18 +16156,26 @@ async function setupRootDefaults(draft, cwd, ecosystems, buildsAtCwd) {
|
|
|
15995
16156
|
}
|
|
15996
16157
|
const own = draftSettings(draft, cwd);
|
|
15997
16158
|
const manifest = manifestOf(own);
|
|
16159
|
+
const before = getEcosystemSection(own, ecosystem);
|
|
15998
16160
|
const section = {
|
|
15999
|
-
...getEcosystemSection(
|
|
16161
|
+
...getEcosystemSection(draftCascade(draft, cwd), ecosystem)
|
|
16000
16162
|
};
|
|
16001
|
-
|
|
16163
|
+
const inherited = getEcosystemSection(draftParentCascade(draft, cwd), ecosystem);
|
|
16002
16164
|
// eslint-disable-next-line no-await-in-loop
|
|
16003
|
-
const result = await runEcosystemWizard(ecosystem, section);
|
|
16165
|
+
const result = await runEcosystemWizard(ecosystem, section, inherited['reachability']);
|
|
16004
16166
|
if (!result.ok || result.data.canceled) {
|
|
16005
16167
|
return result;
|
|
16006
16168
|
}
|
|
16007
|
-
|
|
16008
|
-
|
|
16169
|
+
const changed = changedFields(section, inherited);
|
|
16170
|
+
if (require$$1.isDeepStrictEqual(changed, before)) {
|
|
16171
|
+
continue;
|
|
16172
|
+
}
|
|
16173
|
+
if (Object.keys(changed).length) {
|
|
16174
|
+
manifest[ecosystem] = changed;
|
|
16175
|
+
} else {
|
|
16176
|
+
delete manifest[ecosystem];
|
|
16009
16177
|
}
|
|
16178
|
+
stageSettings(draft, cwd, own, `configure ${label} defaults`);
|
|
16010
16179
|
}
|
|
16011
16180
|
return notCanceled$1();
|
|
16012
16181
|
}
|
|
@@ -16068,7 +16237,7 @@ async function setupRecursiveManifestConfig(cwd, defaultOnReadError, excludePath
|
|
|
16068
16237
|
// excludes isn't offered.
|
|
16069
16238
|
const detectedEcosystems = ROOT_ECOSYSTEMS.filter(ecosystem => (includedByTool.get(ecosystem)?.length ?? 0) > 0);
|
|
16070
16239
|
if (detectedEcosystems.length) {
|
|
16071
|
-
utils.logger.log(`Detected: ${detectedEcosystems.map(ecosystem => ECOSYSTEM_LABELS[ecosystem]).join(', ')}.`);
|
|
16240
|
+
utils.logger.log(`Detected: ${detectedEcosystems.map(ecosystem => utils.ECOSYSTEM_LABELS[ecosystem]).join(', ')}.`);
|
|
16072
16241
|
} else {
|
|
16073
16242
|
utils.logger.log(`No Gradle, Maven, sbt or .NET build roots found beneath ${cwd}.`);
|
|
16074
16243
|
// Builds that --exclude-paths excludes are a choice, not an absence.
|
|
@@ -25620,5 +25789,5 @@ process.on('unhandledRejection', async (reason, promise) => {
|
|
|
25620
25789
|
// eslint-disable-next-line n/no-process-exit
|
|
25621
25790
|
process.exit(1);
|
|
25622
25791
|
});
|
|
25623
|
-
//# debugId=
|
|
25792
|
+
//# debugId=275cd37a-181e-42a9-b535-f40285f44c57
|
|
25624
25793
|
//# sourceMappingURL=cli.js.map
|