snyk 1.1244.0 → 1.1245.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/245.index.js +39 -80
- package/dist/cli/245.index.js.map +1 -1
- package/dist/cli/thirdPartyNotice.json +2 -2
- package/help/cli-commands/code-test.md +7 -7
- package/help/cli-commands/container-monitor.md +7 -3
- package/help/cli-commands/container-sbom.md +1 -1
- package/help/cli-commands/iac-test.md +1 -1
- package/help/cli-commands/log4shell.md +1 -1
- package/help/cli-commands/monitor.md +11 -3
- package/help/cli-commands/sbom.md +3 -1
- package/help/cli-commands/test.md +1 -1
- package/package.json +1 -1
- package/src/generated/sha256sums.txt +8 -8
- package/src/generated/version +1 -1
- package/wrapper_dist/generated/sha256sums.txt +8 -8
- package/wrapper_dist/generated/version +1 -1
package/dist/cli/245.index.js
CHANGED
|
@@ -231577,6 +231577,8 @@ const debugModule = __webpack_require__(15158);
|
|
|
231577
231577
|
const errors_1 = __webpack_require__(62153);
|
|
231578
231578
|
const path = __webpack_require__(71017);
|
|
231579
231579
|
const subprocess = __webpack_require__(24862);
|
|
231580
|
+
const fs = __webpack_require__(57147);
|
|
231581
|
+
const os = __webpack_require__(22037);
|
|
231580
231582
|
const debug = debugModule('snyk');
|
|
231581
231583
|
async function handle(operation, command, args) {
|
|
231582
231584
|
debug(`running dotnet command: ${operation}: ${command}`);
|
|
@@ -231621,59 +231623,28 @@ async function run(projectPath, options) {
|
|
|
231621
231623
|
}
|
|
231622
231624
|
exports.run = run;
|
|
231623
231625
|
async function publish(projectPath, targetFramework) {
|
|
231624
|
-
var _a;
|
|
231625
231626
|
const command = 'dotnet';
|
|
231626
231627
|
const args = ['publish', '--nologo'];
|
|
231627
231628
|
// Self-contained: Create all required .dlls for version investigation, don't rely on the environment.
|
|
231628
231629
|
args.push('--sc');
|
|
231630
|
+
// Use the current runtime of whatever platform we are on.
|
|
231631
|
+
// This ensures that .dlls will be packaged containing the runtime assembly versions.
|
|
231632
|
+
// TODO: (OSM-521) if/when we allow this to be dynamic based on user input, remember to change this.
|
|
231633
|
+
args.push('--use-current-runtime');
|
|
231629
231634
|
// If your .csproj file contains multiple <TargetFramework> references, you need to supply which one you want to publish.
|
|
231630
231635
|
if (targetFramework) {
|
|
231631
231636
|
args.push('--framework');
|
|
231632
231637
|
args.push(targetFramework);
|
|
231633
231638
|
}
|
|
231639
|
+
// Define a temporary output dir to use for detecting .dlls to use for runtime version assembly detection.
|
|
231640
|
+
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), `snyk-nuget-plugin-publish-csharp-`));
|
|
231641
|
+
args.push('--output');
|
|
231642
|
+
args.push(tempDir);
|
|
231634
231643
|
// The path that contains either some form of project file, or a .sln one.
|
|
231635
231644
|
// See: https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-publish#arguments
|
|
231636
231645
|
args.push(projectPath);
|
|
231637
|
-
|
|
231638
|
-
|
|
231639
|
-
// for a self-contained executable. Specifically determining an output folder with --output is deprecated,
|
|
231640
|
-
// as it leads to unpredictable results for multiple target frameworks and runtimes, so we have to cherry-pick
|
|
231641
|
-
// the folders.
|
|
231642
|
-
// See: https://learn.microsoft.com/en-us/dotnet/core/compatibility/sdk/7.0/solution-level-output-no-longer-valid.
|
|
231643
|
-
// FIXME: As we're not supporting multiple frameworks all over the place, we have to just take the first one.
|
|
231644
|
-
// It's probably safe, as runtime dll versions most likely don't differ much across *most* dependencies, but
|
|
231645
|
-
// OS-specific ones (e.g. crypto) might.
|
|
231646
|
-
// Looking for something like <project_name> -> /path/to/<project_name>/bin/Debug/<target_framework>/publish/ on Unix.
|
|
231647
|
-
// We could also just hope Microsoft never changes their naming convention, but I think this is less error-prone,
|
|
231648
|
-
// and will potentially also support multiple target frameworks.
|
|
231649
|
-
const publishDirLine = response.stdout
|
|
231650
|
-
.split(/[\r\n]+/)
|
|
231651
|
-
// Projects that are referring to other local projects in their PackageReference item groups will also be restored
|
|
231652
|
-
// in a chained operation. The project we're interested in will be shown last, thus we reverse it.
|
|
231653
|
-
.reverse()
|
|
231654
|
-
// TODO: For multiple target frameworks, replace `find` with a map or something of that kind to return more than the first.
|
|
231655
|
-
// The first thing to get published ought to be the project's own .dll or .exe file, depending on the architecture.
|
|
231656
|
-
// E.g., something like:
|
|
231657
|
-
// dotnet_6 -> /foo/bar/project/bin/Debug/net6.0/osx-arm64/project_name.dll
|
|
231658
|
-
// Either way, since we're forcing a publish of a self-contained project, all .dlls should be placed there.
|
|
231659
|
-
// PRs are welcome!
|
|
231660
|
-
.find((line) => line.endsWith('.dll') || line.endsWith('.exe'));
|
|
231661
|
-
if (!publishDirLine) {
|
|
231662
|
-
const err = `Could not find a valid publish path while reading stdout: ${response.stdout}`;
|
|
231663
|
-
debug(err);
|
|
231664
|
-
throw new errors_1.CliCommandError(`Unable to find a publish dir: ${err}`);
|
|
231665
|
-
}
|
|
231666
|
-
// dotnet_6 -> /foo/bar/project/bin/Debug/net6.0/osx-arm64/project_name.dll will then have the first part removed:
|
|
231667
|
-
const [, publishedDllPath] = (_a = publishDirLine.split('->')) !== null && _a !== void 0 ? _a : [];
|
|
231668
|
-
if (!publishedDllPath) {
|
|
231669
|
-
const err = `Could not find a valid publish dir while splitting the line: ${publishDirLine}`;
|
|
231670
|
-
debug(err);
|
|
231671
|
-
throw new errors_1.CliCommandError(`Unable to find a publish dir: ${err}`);
|
|
231672
|
-
}
|
|
231673
|
-
// /foo/bar/project/bin/Debug/net6.0/osx-arm64/project_name.dll will then need to be stripped from a file name,
|
|
231674
|
-
// in order to return just the so-called "publish dir":
|
|
231675
|
-
const dirName = path.dirname(publishedDllPath.trim());
|
|
231676
|
-
return dirName;
|
|
231646
|
+
await handle('publish', command, args);
|
|
231647
|
+
return tempDir;
|
|
231677
231648
|
}
|
|
231678
231649
|
exports.publish = publish;
|
|
231679
231650
|
//# sourceMappingURL=dotnet.js.map
|
|
@@ -232522,7 +232493,9 @@ function buildGraph(projectName, projectAssets, runtimeAssembly, targetFramework
|
|
|
232522
232493
|
return { ...acc, [nameWithVersion]: pkg };
|
|
232523
232494
|
}, {});
|
|
232524
232495
|
const topLevelDepPackages = topLevelDeps.reduce((acc, topLevelDepName) => {
|
|
232525
|
-
const nameWithVersion = Object.keys(targetDeps).find((targetDep) =>
|
|
232496
|
+
const nameWithVersion = Object.keys(targetDeps).find((targetDep) =>
|
|
232497
|
+
// Lowercase the comparison, as .csproj <PackageReference>s are not case-sensitive, and can be written however you like.
|
|
232498
|
+
targetDep.toLowerCase().startsWith(topLevelDepName.toLowerCase()));
|
|
232526
232499
|
if (!nameWithVersion) {
|
|
232527
232500
|
throw new errors_1.InvalidManifestError(`cant find a name and a version in assets file, something's very malformed`);
|
|
232528
232501
|
}
|
|
@@ -233078,7 +233051,6 @@ exports.generateRuntimeAssemblies = void 0;
|
|
|
233078
233051
|
const errors = __webpack_require__(62153);
|
|
233079
233052
|
const fs = __webpack_require__(57147);
|
|
233080
233053
|
const lodash_1 = __webpack_require__(96486);
|
|
233081
|
-
const path = __webpack_require__(71017);
|
|
233082
233054
|
const debugModule = __webpack_require__(15158);
|
|
233083
233055
|
const debug = debugModule('snyk');
|
|
233084
233056
|
// The Nuget dependency resolution rule of lowest applicable version
|
|
@@ -233101,44 +233073,30 @@ function generateRuntimeAssemblies(filePath) {
|
|
|
233101
233073
|
// .NETCoreApp,Version=v6.0/alpine-armv6
|
|
233102
233074
|
// ... etc.
|
|
233103
233075
|
// See all: https://github.com/dotnet/runtime/blob/bd83e17052d3c09022bad1d91dca860ca6b27ab9/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json
|
|
233104
|
-
|
|
233076
|
+
let runtimeAssemblyVersions = {};
|
|
233105
233077
|
Object.entries(deps.targets).forEach(([target, dependencies]) => {
|
|
233106
233078
|
// Ignore target frameworks without dependencies, as they hold no dlls and thus no assembly versions to gauge.
|
|
233107
233079
|
if ((0, lodash_1.isEmpty)(dependencies)) {
|
|
233108
233080
|
return;
|
|
233109
233081
|
}
|
|
233110
|
-
//
|
|
233111
|
-
//
|
|
233112
|
-
|
|
233113
|
-
|
|
233114
|
-
|
|
233115
|
-
|
|
233116
|
-
//
|
|
233117
|
-
//
|
|
233118
|
-
|
|
233119
|
-
|
|
233120
|
-
|
|
233121
|
-
|
|
233122
|
-
|
|
233123
|
-
|
|
233124
|
-
|
|
233125
|
-
|
|
233126
|
-
|
|
233127
|
-
|
|
233128
|
-
for (const [fullName, version] of Object.entries(runtime)) {
|
|
233129
|
-
if ((0, lodash_1.isEmpty)(version)) {
|
|
233130
|
-
continue;
|
|
233131
|
-
}
|
|
233132
|
-
// For some versions of .NET, the dependency version generated can be more than just the System.* name, but a
|
|
233133
|
-
// full path-like structure, such as lib/netstandard2.0/System.Buffers.dll, so extract as needed:
|
|
233134
|
-
name = path.basename(fullName);
|
|
233135
|
-
runtimes[name] = version;
|
|
233136
|
-
}
|
|
233137
|
-
}
|
|
233138
|
-
}
|
|
233139
|
-
if (!runtimes) {
|
|
233140
|
-
throw new errors.FileNotProcessableError(`could not find any runtime dependencies in the ${target} dependency`);
|
|
233141
|
-
}
|
|
233082
|
+
// Since we're running `dotnet publish` with `--use-current-runtime`, this should exist in the dependency list,
|
|
233083
|
+
// but guard against it to ensure good user feedback in case we did something wrong.
|
|
233084
|
+
const runtimePack = Object.keys(dependencies).find((dep) => dep.startsWith('runtimepack'));
|
|
233085
|
+
if (!runtimePack) {
|
|
233086
|
+
throw new errors.FileNotProcessableError(`could not find any runtimepack.* identifier in the ${target} dependency`);
|
|
233087
|
+
}
|
|
233088
|
+
// The runtimepack contains all the current RuntimeIdentifier (RID) assemblies which we are interested in.
|
|
233089
|
+
// Such as
|
|
233090
|
+
// "runtimepack.Microsoft.NETCore.App.Runtime.osx-arm64/6.0.16": {
|
|
233091
|
+
// "runtime": {
|
|
233092
|
+
// "Microsoft.CSharp.dll": { .. assembly version 6.0.0 }
|
|
233093
|
+
// }
|
|
233094
|
+
// }
|
|
233095
|
+
// We traverse all those and store them for the dependency graph build.
|
|
233096
|
+
if (!('runtime' in dependencies[runtimePack])) {
|
|
233097
|
+
throw new errors.FileNotProcessableError(`could not find any runtime list in the ${runtimePack} dependency`);
|
|
233098
|
+
}
|
|
233099
|
+
const runtimes = dependencies[runtimePack]['runtime'];
|
|
233142
233100
|
// Dig down into the specific runtimepack which contains all the assembly versions of
|
|
233143
233101
|
// the bundled DLLs for the given runtime, as:
|
|
233144
233102
|
// "runtimepack.Microsoft.NETCore.App.Runtime.osx-arm64/6.0.16": {
|
|
@@ -233154,19 +233112,20 @@ function generateRuntimeAssemblies(filePath) {
|
|
|
233154
233112
|
// (...)
|
|
233155
233113
|
// We currently only address assemblyVersions. FileVersion might become relevant, depending
|
|
233156
233114
|
// on how vulnerabilities are reported in the future.
|
|
233157
|
-
runtimeAssemblyVersions
|
|
233115
|
+
runtimeAssemblyVersions = Object.entries(runtimes).reduce((acc, [dll, versions]) => {
|
|
233158
233116
|
// Take the version number (N.N.N.N) and remove the last element, in order for vulndb to understand anything.
|
|
233159
233117
|
acc[dll] = versions.assemblyVersion.split('.').slice(0, -1).join('.');
|
|
233160
233118
|
return acc;
|
|
233161
233119
|
}, {});
|
|
233120
|
+
// `dotnet publish` does not support multiple consecutive `--runtime` parameters, so there should really only
|
|
233121
|
+
// be one. Thus, drop iterating more.
|
|
233122
|
+
return;
|
|
233162
233123
|
});
|
|
233163
233124
|
if ((0, lodash_1.isEmpty)(runtimeAssemblyVersions)) {
|
|
233164
233125
|
throw new errors.FileNotProcessableError('collection of runtime assembly versions was empty, that should not happen');
|
|
233165
233126
|
}
|
|
233166
233127
|
debug('finished extracting runtime assemblies from ' + filePath);
|
|
233167
|
-
|
|
233168
|
-
// RIDs. Currently, we are only looking at the first one.
|
|
233169
|
-
return Object.values(runtimeAssemblyVersions)[0];
|
|
233128
|
+
return runtimeAssemblyVersions;
|
|
233170
233129
|
}
|
|
233171
233130
|
exports.generateRuntimeAssemblies = generateRuntimeAssemblies;
|
|
233172
233131
|
//# sourceMappingURL=runtime-assembly.js.map
|