@cdxgen/cdxgen 13.2.0 → 13.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -14
- package/bin/cdxgen.js +310 -138
- package/bin/evinse.js +22 -0
- package/bin/repl.js +86 -0
- package/bin/sign.js +119 -15
- package/bin/tracebom.js +69 -5
- package/bin/validate.js +107 -19
- package/bin/verify.js +172 -63
- package/data/helpers/init.gradle +46 -21
- package/data/remediations.json +85 -0
- package/data/rules/dependency-sources.yaml +67 -0
- package/data/rules/scala-evidence.yaml +115 -0
- package/lib/audit/index.js +38 -6
- package/lib/cli/bomAssembly.js +105 -15
- package/lib/cli/cliOptions.js +93 -1
- package/lib/cli/index.js +156 -58
- package/lib/cli/jsBom.js +99 -53
- package/lib/cli/jvmBom.js +708 -147
- package/lib/cli/managedBom.js +415 -224
- package/lib/cli/nativeBom.js +264 -44
- package/lib/core/activity.js +12 -0
- package/lib/core/env.js +22 -15
- package/lib/core/fs.js +176 -7
- package/lib/core/httpClient.js +159 -24
- package/lib/core/metadataProperties.js +97 -0
- package/lib/core/pluginRun.js +184 -0
- package/lib/core/processTree.js +100 -0
- package/lib/core/projectConfig.js +31 -4
- package/lib/core/runState.js +39 -0
- package/lib/core/toml.js +72 -0
- package/lib/ecosystems/asarutils.js +4 -2
- package/lib/ecosystems/bunutils.js +274 -108
- package/lib/ecosystems/cargoCache.js +231 -8
- package/lib/ecosystems/caxa.js +434 -2
- package/lib/ecosystems/cmakeResolver.js +76 -21
- package/lib/ecosystems/cppBuildContext.js +631 -0
- package/lib/ecosystems/cppEvidence.js +399 -51
- package/lib/ecosystems/cppIncludeResolver.js +294 -0
- package/lib/ecosystems/denoutils.js +93 -66
- package/lib/ecosystems/ecosystems.js +1983 -793
- package/lib/ecosystems/golem.js +28 -12
- package/lib/ecosystems/gradleutils.js +356 -37
- package/lib/ecosystems/jsEvidence.js +104 -44
- package/lib/ecosystems/kosi.js +31 -7
- package/lib/ecosystems/npmutils.js +174 -9
- package/lib/ecosystems/parsers-dotnet.js +616 -159
- package/lib/ecosystems/parsers-elm.js +46 -28
- package/lib/ecosystems/parsers-gleam.js +3 -4
- package/lib/ecosystems/parsers-go.js +371 -70
- package/lib/ecosystems/parsers-js.js +263 -76
- package/lib/ecosystems/parsers-julia.js +2 -3
- package/lib/ecosystems/parsers-jvm.js +204 -12
- package/lib/ecosystems/parsers-misc.js +929 -216
- package/lib/ecosystems/parsers-python.js +167 -24
- package/lib/ecosystems/parsers-rust.js +28 -22
- package/lib/ecosystems/parsers-terraform.js +1573 -19
- package/lib/ecosystems/pythonutils.js +102 -6
- package/lib/ecosystems/remote/huggingface.js +3 -0
- package/lib/ecosystems/rubyutils.js +1492 -182
- package/lib/ecosystems/rusi.js +54 -10
- package/lib/ecosystems/sbtutils.js +243 -187
- package/lib/ecosystems/scalacliutils.js +342 -0
- package/lib/ecosystems/scalasem.js +2618 -0
- package/lib/ecosystems/terraformRegistry.js +288 -0
- package/lib/ecosystems/utils.js +2 -0
- package/lib/ecosystems/vendoredCode.js +156 -0
- package/lib/evinser/evinser.js +1008 -191
- package/lib/evinser/swiftsem.js +1914 -302
- package/lib/helpers/agenticToolutils.js +2 -2
- package/lib/helpers/bomSigner.js +1101 -222
- package/lib/inventory/aiCollector.js +4 -1
- package/lib/inventory/analyzer.js +110 -127
- package/lib/inventory/atomUtils.js +703 -43
- package/lib/inventory/auditCategories.js +7 -0
- package/lib/inventory/buildToolRateLimit.js +144 -0
- package/lib/inventory/cacheCommands.js +2 -1
- package/lib/inventory/cdxrs.js +103 -12
- package/lib/inventory/cmakeBuildDirs.js +254 -0
- package/lib/inventory/deps.js +501 -124
- package/lib/inventory/depsUtils.js +183 -11
- package/lib/inventory/display.js +4 -5
- package/lib/inventory/dosai.js +798 -57
- package/lib/inventory/dosaiParsers.js +310 -15
- package/lib/inventory/dynamic.js +90 -6
- package/lib/inventory/evidenceUtils.js +166 -113
- package/lib/inventory/fetchBatch.js +690 -55
- package/lib/inventory/fetchDiskCache.js +597 -0
- package/lib/inventory/forgeEnricher.js +14 -5
- package/lib/inventory/jvmLocalRepos.js +917 -0
- package/lib/inventory/mcpConfigParser.js +2 -3
- package/lib/inventory/parentSelection.js +146 -0
- package/lib/inventory/protobom.js +8 -1
- package/lib/inventory/purl.js +152 -3
- package/lib/inventory/rustFormulationParser.js +3 -4
- package/lib/inventory/sbomDocument.js +2 -70
- package/lib/inventory/scalaCoords.js +153 -0
- package/lib/inventory/source.js +45 -27
- package/lib/inventory/spdx.js +101 -0
- package/lib/inventory/traceRunner.js +295 -25
- package/lib/inventory/tracedCrypto.js +294 -0
- package/lib/managers/binary.js +115 -24
- package/lib/managers/docker.js +467 -46
- package/lib/managers/oci.js +63 -3
- package/lib/parsers/cmakeCache.js +69 -0
- package/lib/parsers/cmakeLists.js +466 -0
- package/lib/parsers/cmakePresets.js +400 -0
- package/lib/parsers/compileCommands.js +557 -0
- package/lib/parsers/largeJson.js +454 -0
- package/lib/parsers/npmrc.js +19 -1
- package/lib/parsers/strictJson.js +322 -0
- package/lib/parsers/terraformConfig.js +1073 -0
- package/lib/parsers/terraformSource.js +652 -0
- package/lib/server/server.js +23 -0
- package/lib/stages/postgen/introspection/markers.js +1 -1
- package/lib/stages/postgen/postgen.js +83 -16
- package/lib/stages/postgen/specVersionCompat.js +32 -0
- package/lib/validator/bomValidator.js +6 -16
- package/lib/validator/index.js +64 -11
- package/lib/validator/reporters/console.js +3 -0
- package/lib/validator/reporters/json.js +2 -0
- package/lib/validator/reporters/sarif.js +7 -0
- package/package.json +23 -23
- package/types/lib/audit/index.d.ts.map +1 -1
- package/types/lib/cli/bomAssembly.d.ts +2 -1
- package/types/lib/cli/bomAssembly.d.ts.map +1 -1
- package/types/lib/cli/cliOptions.d.ts +33 -1
- package/types/lib/cli/cliOptions.d.ts.map +1 -1
- package/types/lib/cli/index.d.ts.map +1 -1
- package/types/lib/cli/jsBom.d.ts.map +1 -1
- package/types/lib/cli/jvmBom.d.ts +24 -1
- package/types/lib/cli/jvmBom.d.ts.map +1 -1
- package/types/lib/cli/managedBom.d.ts +7 -4
- package/types/lib/cli/managedBom.d.ts.map +1 -1
- package/types/lib/cli/nativeBom.d.ts +3 -1
- package/types/lib/cli/nativeBom.d.ts.map +1 -1
- package/types/lib/core/activity.d.ts.map +1 -1
- package/types/lib/core/env.d.ts +9 -0
- package/types/lib/core/env.d.ts.map +1 -1
- package/types/lib/core/fs.d.ts +55 -0
- package/types/lib/core/fs.d.ts.map +1 -1
- package/types/lib/core/httpClient.d.ts +13 -8
- package/types/lib/core/httpClient.d.ts.map +1 -1
- package/types/lib/core/metadataProperties.d.ts +39 -0
- package/types/lib/core/metadataProperties.d.ts.map +1 -0
- package/types/lib/core/pluginRun.d.ts +97 -0
- package/types/lib/core/pluginRun.d.ts.map +1 -0
- package/types/lib/core/processTree.d.ts +36 -0
- package/types/lib/core/processTree.d.ts.map +1 -0
- package/types/lib/core/projectConfig.d.ts +6 -2
- package/types/lib/core/projectConfig.d.ts.map +1 -1
- package/types/lib/core/runState.d.ts +29 -0
- package/types/lib/core/runState.d.ts.map +1 -0
- package/types/lib/core/toml.d.ts +20 -0
- package/types/lib/core/toml.d.ts.map +1 -0
- package/types/lib/ecosystems/asarutils.d.ts.map +1 -1
- package/types/lib/ecosystems/bunutils.d.ts +12 -5
- package/types/lib/ecosystems/bunutils.d.ts.map +1 -1
- package/types/lib/ecosystems/cargoCache.d.ts +12 -0
- package/types/lib/ecosystems/cargoCache.d.ts.map +1 -1
- package/types/lib/ecosystems/caxa.d.ts +14 -0
- package/types/lib/ecosystems/caxa.d.ts.map +1 -1
- package/types/lib/ecosystems/cmakeResolver.d.ts +28 -3
- package/types/lib/ecosystems/cmakeResolver.d.ts.map +1 -1
- package/types/lib/ecosystems/cppBuildContext.d.ts +55 -0
- package/types/lib/ecosystems/cppBuildContext.d.ts.map +1 -0
- package/types/lib/ecosystems/cppEvidence.d.ts +17 -1
- package/types/lib/ecosystems/cppEvidence.d.ts.map +1 -1
- package/types/lib/ecosystems/cppIncludeResolver.d.ts +92 -0
- package/types/lib/ecosystems/cppIncludeResolver.d.ts.map +1 -0
- package/types/lib/ecosystems/denoutils.d.ts +9 -3
- package/types/lib/ecosystems/denoutils.d.ts.map +1 -1
- package/types/lib/ecosystems/ecosystems.d.ts +62 -13
- package/types/lib/ecosystems/ecosystems.d.ts.map +1 -1
- package/types/lib/ecosystems/golem.d.ts.map +1 -1
- package/types/lib/ecosystems/gradleutils.d.ts +70 -4
- package/types/lib/ecosystems/gradleutils.d.ts.map +1 -1
- package/types/lib/ecosystems/jsEvidence.d.ts +5 -2
- package/types/lib/ecosystems/jsEvidence.d.ts.map +1 -1
- package/types/lib/ecosystems/kosi.d.ts +13 -0
- package/types/lib/ecosystems/kosi.d.ts.map +1 -1
- package/types/lib/ecosystems/npmutils.d.ts +57 -0
- package/types/lib/ecosystems/npmutils.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-dotnet.d.ts +118 -4
- package/types/lib/ecosystems/parsers-dotnet.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-elm.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-gleam.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-go.d.ts +54 -2
- package/types/lib/ecosystems/parsers-go.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-js.d.ts +16 -5
- package/types/lib/ecosystems/parsers-js.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-julia.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-jvm.d.ts +46 -1
- package/types/lib/ecosystems/parsers-jvm.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-misc.d.ts +70 -4
- package/types/lib/ecosystems/parsers-misc.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-python.d.ts +53 -3
- package/types/lib/ecosystems/parsers-python.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-rust.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-terraform.d.ts +38 -21
- package/types/lib/ecosystems/parsers-terraform.d.ts.map +1 -1
- package/types/lib/ecosystems/pythonutils.d.ts +27 -2
- package/types/lib/ecosystems/pythonutils.d.ts.map +1 -1
- package/types/lib/ecosystems/remote/huggingface.d.ts.map +1 -1
- package/types/lib/ecosystems/rubyutils.d.ts +164 -3
- package/types/lib/ecosystems/rubyutils.d.ts.map +1 -1
- package/types/lib/ecosystems/rusi.d.ts +13 -0
- package/types/lib/ecosystems/rusi.d.ts.map +1 -1
- package/types/lib/ecosystems/sbtutils.d.ts +88 -2
- package/types/lib/ecosystems/sbtutils.d.ts.map +1 -1
- package/types/lib/ecosystems/scalacliutils.d.ts +56 -0
- package/types/lib/ecosystems/scalacliutils.d.ts.map +1 -0
- package/types/lib/ecosystems/scalasem.d.ts +311 -0
- package/types/lib/ecosystems/scalasem.d.ts.map +1 -0
- package/types/lib/ecosystems/terraformRegistry.d.ts +9 -0
- package/types/lib/ecosystems/terraformRegistry.d.ts.map +1 -0
- package/types/lib/ecosystems/utils.d.ts +2 -2
- package/types/lib/ecosystems/utils.d.ts.map +1 -1
- package/types/lib/ecosystems/vendoredCode.d.ts +32 -0
- package/types/lib/ecosystems/vendoredCode.d.ts.map +1 -0
- package/types/lib/evinser/evinser.d.ts +132 -15
- package/types/lib/evinser/evinser.d.ts.map +1 -1
- package/types/lib/evinser/swiftsem.d.ts +280 -15
- package/types/lib/evinser/swiftsem.d.ts.map +1 -1
- package/types/lib/helpers/bomSigner.d.ts +182 -13
- package/types/lib/helpers/bomSigner.d.ts.map +1 -1
- package/types/lib/inventory/aiCollector.d.ts.map +1 -1
- package/types/lib/inventory/analyzer.d.ts.map +1 -1
- package/types/lib/inventory/atomUtils.d.ts +219 -5
- package/types/lib/inventory/atomUtils.d.ts.map +1 -1
- package/types/lib/inventory/auditCategories.d.ts +3 -0
- package/types/lib/inventory/auditCategories.d.ts.map +1 -1
- package/types/lib/inventory/buildToolRateLimit.d.ts +38 -0
- package/types/lib/inventory/buildToolRateLimit.d.ts.map +1 -0
- package/types/lib/inventory/cacheCommands.d.ts +2 -1
- package/types/lib/inventory/cacheCommands.d.ts.map +1 -1
- package/types/lib/inventory/cdxrs.d.ts +8 -3
- package/types/lib/inventory/cdxrs.d.ts.map +1 -1
- package/types/lib/inventory/cmakeBuildDirs.d.ts +58 -0
- package/types/lib/inventory/cmakeBuildDirs.d.ts.map +1 -0
- package/types/lib/inventory/deps.d.ts +59 -1
- package/types/lib/inventory/deps.d.ts.map +1 -1
- package/types/lib/inventory/depsUtils.d.ts +15 -0
- package/types/lib/inventory/depsUtils.d.ts.map +1 -1
- package/types/lib/inventory/display.d.ts.map +1 -1
- package/types/lib/inventory/dosai.d.ts +121 -9
- package/types/lib/inventory/dosai.d.ts.map +1 -1
- package/types/lib/inventory/dosaiParsers.d.ts +53 -7
- package/types/lib/inventory/dosaiParsers.d.ts.map +1 -1
- package/types/lib/inventory/dynamic.d.ts +10 -0
- package/types/lib/inventory/dynamic.d.ts.map +1 -1
- package/types/lib/inventory/evidenceUtils.d.ts +19 -4
- package/types/lib/inventory/evidenceUtils.d.ts.map +1 -1
- package/types/lib/inventory/fetchBatch.d.ts +83 -14
- package/types/lib/inventory/fetchBatch.d.ts.map +1 -1
- package/types/lib/inventory/fetchDiskCache.d.ts +169 -0
- package/types/lib/inventory/fetchDiskCache.d.ts.map +1 -0
- package/types/lib/inventory/forgeEnricher.d.ts.map +1 -1
- package/types/lib/inventory/jvmLocalRepos.d.ts +178 -0
- package/types/lib/inventory/jvmLocalRepos.d.ts.map +1 -0
- package/types/lib/inventory/mcpConfigParser.d.ts.map +1 -1
- package/types/lib/inventory/parentSelection.d.ts +34 -0
- package/types/lib/inventory/parentSelection.d.ts.map +1 -0
- package/types/lib/inventory/plugins.d.ts.map +1 -1
- package/types/lib/inventory/protobom.d.ts.map +1 -1
- package/types/lib/inventory/purl.d.ts +71 -2
- package/types/lib/inventory/purl.d.ts.map +1 -1
- package/types/lib/inventory/rustFormulationParser.d.ts.map +1 -1
- package/types/lib/inventory/sbomDocument.d.ts.map +1 -1
- package/types/lib/inventory/scalaCoords.d.ts +80 -0
- package/types/lib/inventory/scalaCoords.d.ts.map +1 -0
- package/types/lib/inventory/source.d.ts.map +1 -1
- package/types/lib/inventory/spdx.d.ts +9 -0
- package/types/lib/inventory/spdx.d.ts.map +1 -1
- package/types/lib/inventory/traceRunner.d.ts +59 -1
- package/types/lib/inventory/traceRunner.d.ts.map +1 -1
- package/types/lib/inventory/tracedCrypto.d.ts +42 -0
- package/types/lib/inventory/tracedCrypto.d.ts.map +1 -0
- package/types/lib/managers/binary.d.ts +30 -1
- package/types/lib/managers/binary.d.ts.map +1 -1
- package/types/lib/managers/docker.d.ts +29 -0
- package/types/lib/managers/docker.d.ts.map +1 -1
- package/types/lib/managers/oci.d.ts +17 -1
- package/types/lib/managers/oci.d.ts.map +1 -1
- package/types/lib/parsers/cmakeCache.d.ts +16 -0
- package/types/lib/parsers/cmakeCache.d.ts.map +1 -1
- package/types/lib/parsers/cmakeLists.d.ts +77 -0
- package/types/lib/parsers/cmakeLists.d.ts.map +1 -0
- package/types/lib/parsers/cmakePresets.d.ts +78 -0
- package/types/lib/parsers/cmakePresets.d.ts.map +1 -0
- package/types/lib/parsers/compileCommands.d.ts +115 -0
- package/types/lib/parsers/compileCommands.d.ts.map +1 -0
- package/types/lib/parsers/largeJson.d.ts +52 -0
- package/types/lib/parsers/largeJson.d.ts.map +1 -0
- package/types/lib/parsers/npmrc.d.ts +5 -0
- package/types/lib/parsers/npmrc.d.ts.map +1 -1
- package/types/lib/parsers/strictJson.d.ts +46 -0
- package/types/lib/parsers/strictJson.d.ts.map +1 -0
- package/types/lib/parsers/terraformConfig.d.ts +70 -0
- package/types/lib/parsers/terraformConfig.d.ts.map +1 -0
- package/types/lib/parsers/terraformSource.d.ts +66 -0
- package/types/lib/parsers/terraformSource.d.ts.map +1 -0
- package/types/lib/server/server.d.ts.map +1 -1
- package/types/lib/stages/postgen/postgen.d.ts.map +1 -1
- package/types/lib/stages/postgen/specVersionCompat.d.ts.map +1 -1
- package/types/lib/validator/bomValidator.d.ts.map +1 -1
- package/types/lib/validator/index.d.ts +18 -1
- package/types/lib/validator/index.d.ts.map +1 -1
- package/types/lib/validator/reporters/console.d.ts.map +1 -1
- package/types/lib/validator/reporters/json.d.ts.map +1 -1
- package/types/lib/validator/reporters/sarif.d.ts.map +1 -1
- package/lib/third-party/arborist/snapshots/calc-dep-flags.test.cjs +0 -462
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
readEnvironmentVariable,
|
|
19
19
|
} from "../core/activity.js";
|
|
20
20
|
import { PYTHON_CMD, PYTHON_EXCLUDED_COMPONENTS } from "../core/env.js";
|
|
21
|
-
import { safeExistsSync, safeSpawnSync } from "../core/fs.js";
|
|
21
|
+
import { getAllFiles, safeExistsSync, safeSpawnSync } from "../core/fs.js";
|
|
22
22
|
import { thoughtLog } from "../core/logger.js";
|
|
23
23
|
import { isWin } from "../core/paths.js";
|
|
24
24
|
import {
|
|
@@ -331,6 +331,70 @@ export function get_python_command_from_env(env) {
|
|
|
331
331
|
return fallbackCmd;
|
|
332
332
|
}
|
|
333
333
|
|
|
334
|
+
/** Directories that hold installed packages, not the project's own code. */
|
|
335
|
+
const INSTALLED_PACKAGE_DIRS = [
|
|
336
|
+
"**/site-packages/**",
|
|
337
|
+
"**/dist-packages/**",
|
|
338
|
+
"**/.venv/**",
|
|
339
|
+
"**/venv/**",
|
|
340
|
+
"**/.tox/**",
|
|
341
|
+
"**/.nox/**",
|
|
342
|
+
"**/__pypackages__/**",
|
|
343
|
+
"**/node_modules/**",
|
|
344
|
+
];
|
|
345
|
+
|
|
346
|
+
const projectModuleNamesCache = new Map();
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* The top-level packages and modules a project provides, wherever they sit
|
|
350
|
+
* in its tree: each outermost package directory (one with an `__init__.py`
|
|
351
|
+
* whose parent has none), and the module files beside such packages, since
|
|
352
|
+
* their directory is a source root. Directories of installed packages
|
|
353
|
+
* (virtual environments, `site-packages`) are not the project's.
|
|
354
|
+
*
|
|
355
|
+
* @param {string} src Path to the project being analysed
|
|
356
|
+
* @returns {Set<string>} Module names
|
|
357
|
+
*/
|
|
358
|
+
export function projectModuleNames(src) {
|
|
359
|
+
const root = resolve(src);
|
|
360
|
+
if (projectModuleNamesCache.has(root)) {
|
|
361
|
+
return projectModuleNamesCache.get(root);
|
|
362
|
+
}
|
|
363
|
+
const names = new Set();
|
|
364
|
+
const sourceRoots = new Set();
|
|
365
|
+
const inits = getAllFiles(root, "**/__init__.py", {
|
|
366
|
+
exclude: INSTALLED_PACKAGE_DIRS,
|
|
367
|
+
});
|
|
368
|
+
for (const init of inits) {
|
|
369
|
+
let pkgDir = dirname(resolve(init));
|
|
370
|
+
while (
|
|
371
|
+
dirname(pkgDir) !== root &&
|
|
372
|
+
dirname(pkgDir).startsWith(root) &&
|
|
373
|
+
safeExistsSync(join(dirname(pkgDir), "__init__.py"))
|
|
374
|
+
) {
|
|
375
|
+
pkgDir = dirname(pkgDir);
|
|
376
|
+
}
|
|
377
|
+
if (pkgDir === root) {
|
|
378
|
+
continue;
|
|
379
|
+
}
|
|
380
|
+
names.add(basename(pkgDir));
|
|
381
|
+
sourceRoots.add(dirname(pkgDir));
|
|
382
|
+
}
|
|
383
|
+
for (const dir of sourceRoots) {
|
|
384
|
+
try {
|
|
385
|
+
for (const f of readdirSync(dir)) {
|
|
386
|
+
if (f.endsWith(".py") && f !== "__init__.py") {
|
|
387
|
+
names.add(f.slice(0, -3));
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
} catch {
|
|
391
|
+
// an unreadable directory provides nothing
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
projectModuleNamesCache.set(root, names);
|
|
395
|
+
return names;
|
|
396
|
+
}
|
|
397
|
+
|
|
334
398
|
/**
|
|
335
399
|
* Is this import satisfied by a module that lives in the project itself?
|
|
336
400
|
*
|
|
@@ -344,7 +408,9 @@ export function get_python_command_from_env(env) {
|
|
|
344
408
|
* filesystem whether the module is ours answers it exactly.
|
|
345
409
|
*
|
|
346
410
|
* Checks the project root and a `src/` layout for a module file, a package directory,
|
|
347
|
-
* and a PEP 420 namespace package directory
|
|
411
|
+
* and a PEP 420 namespace package directory, then the top-level packages found
|
|
412
|
+
* anywhere in the project and the modules beside them (tool-heavy repositories
|
|
413
|
+
* keep their Python libraries in places such as `dev_tools/pylibs/`).
|
|
348
414
|
*
|
|
349
415
|
* @param {string} src Path to the project being analysed
|
|
350
416
|
* @param {string} name Imported top-level module name
|
|
@@ -354,6 +420,9 @@ export function isFirstPartyModule(src, name) {
|
|
|
354
420
|
if (!src || !name || name.includes("/") || name.includes("\\")) {
|
|
355
421
|
return false;
|
|
356
422
|
}
|
|
423
|
+
if (projectModuleNames(src).has(name)) {
|
|
424
|
+
return true;
|
|
425
|
+
}
|
|
357
426
|
for (const root of [src, join(src, "src")]) {
|
|
358
427
|
if (
|
|
359
428
|
safeExistsSync(join(root, `${name}.py`)) ||
|
|
@@ -378,6 +447,21 @@ export function isFirstPartyModule(src, name) {
|
|
|
378
447
|
return false;
|
|
379
448
|
}
|
|
380
449
|
|
|
450
|
+
/**
|
|
451
|
+
* Whether a directory holds Python sources for atom to parse.
|
|
452
|
+
*
|
|
453
|
+
* The search skips the directories the manifest searches skip, such as
|
|
454
|
+
* node_modules and dot directories, and honours the exclude patterns, so a
|
|
455
|
+
* Python file shipped inside an npm package does not count.
|
|
456
|
+
*
|
|
457
|
+
* @param {string} src directory
|
|
458
|
+
* @param {Object} options CLI options
|
|
459
|
+
* @returns {boolean} true when the directory holds at least one Python file
|
|
460
|
+
*/
|
|
461
|
+
export function hasPythonSources(src, options = {}) {
|
|
462
|
+
return getAllFiles(src, "**/*.py", options).length > 0;
|
|
463
|
+
}
|
|
464
|
+
|
|
381
465
|
/**
|
|
382
466
|
* Method to find python modules by parsing the imports and then checking with PyPI to obtain the latest version
|
|
383
467
|
*
|
|
@@ -390,9 +474,11 @@ export async function getPyModules(src, epkgList, options) {
|
|
|
390
474
|
const allImports = {};
|
|
391
475
|
const dependenciesList = [];
|
|
392
476
|
let modList = [];
|
|
393
|
-
const
|
|
394
|
-
options.depsSlicesFile || options.usagesSlicesFile
|
|
395
|
-
|
|
477
|
+
const requestedSlicesFile =
|
|
478
|
+
options.depsSlicesFile || options.usagesSlicesFile;
|
|
479
|
+
let slicesFile = requestedSlicesFile
|
|
480
|
+
? resolve(requestedSlicesFile)
|
|
481
|
+
: undefined;
|
|
396
482
|
// Issue: 615 fix. Reuse existing slices file
|
|
397
483
|
if (slicesFile && safeExistsSync(slicesFile)) {
|
|
398
484
|
const slicesData = JSON.parse(readFileSync(slicesFile, "utf-8"));
|
|
@@ -401,8 +487,18 @@ export async function getPyModules(src, epkgList, options) {
|
|
|
401
487
|
} else {
|
|
402
488
|
modList = slicesData;
|
|
403
489
|
}
|
|
404
|
-
} else {
|
|
490
|
+
} else if (hasPythonSources(src, options)) {
|
|
491
|
+
// A new slices file is kept where it was asked for only when the evidence
|
|
492
|
+
// step will read it again; otherwise atom writes it to a temporary
|
|
493
|
+
// directory instead of the working directory.
|
|
494
|
+
if (!options.evidence) {
|
|
495
|
+
slicesFile = undefined;
|
|
496
|
+
}
|
|
405
497
|
modList = findAppModules(src, "python", "parsedeps", slicesFile, options);
|
|
498
|
+
} else {
|
|
499
|
+
thoughtLog(
|
|
500
|
+
`There are no Python sources at '${src}', so atom parsedeps has nothing to read.`,
|
|
501
|
+
);
|
|
406
502
|
}
|
|
407
503
|
const pyDefaultModules = new Set(PYTHON_STD_MODULES);
|
|
408
504
|
modList = modList.filter(
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
recordActivity,
|
|
6
6
|
} from "../../core/activity.js";
|
|
7
7
|
import { sanitizeStructuredValueForBom } from "../../core/propertySanitizer.js";
|
|
8
|
+
import { registerRunReset } from "../../core/runState.js";
|
|
8
9
|
import {
|
|
9
10
|
detectAiModelVariants,
|
|
10
11
|
normalizeDetectedVariants,
|
|
@@ -167,6 +168,8 @@ export function resetHuggingFaceRemoteCaches() {
|
|
|
167
168
|
payloadCache.clear();
|
|
168
169
|
}
|
|
169
170
|
|
|
171
|
+
registerRunReset("huggingface:responses", resetHuggingFaceRemoteCaches);
|
|
172
|
+
|
|
170
173
|
const normalizeLicenseFilePath = (licensePath) =>
|
|
171
174
|
String(licensePath || "")
|
|
172
175
|
.trim()
|