snyk 1.1224.0 → 1.1226.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 +91 -64
- package/dist/cli/245.index.js.map +1 -1
- package/dist/cli/784.index.js +7 -4
- package/dist/cli/784.index.js.map +1 -1
- package/dist/cli/thirdPartyNotice.json +2 -2
- package/package.json +1 -1
- package/src/generated/sha256sums.txt +7 -7
- package/src/generated/version +1 -1
- package/wrapper_dist/generated/sha256sums.txt +7 -7
- package/wrapper_dist/generated/version +1 -1
package/dist/cli/245.index.js
CHANGED
|
@@ -230643,6 +230643,9 @@ async function inspect(root, targetFile, options) {
|
|
|
230643
230643
|
options.strict)
|
|
230644
230644
|
.then(createPackageTree);
|
|
230645
230645
|
}
|
|
230646
|
+
if (options['target-framework'] && !options['dotnet-runtime-resolution']) {
|
|
230647
|
+
return Promise.reject(new errors_1.CliCommandError('target framework flag is currently only supported when also scanning with runtime resolution using the `--dotnet-runtime-resolution` flag'));
|
|
230648
|
+
}
|
|
230646
230649
|
if (options['dotnet-runtime-resolution']) {
|
|
230647
230650
|
if (manifestType !== types_1.ManifestType.DOTNET_CORE) {
|
|
230648
230651
|
return Promise.reject(new errors_1.FileNotProcessableError(`runtime resolution flag is currently only supported for: .NET versions 5 and higher, all versions of .NET Core and all versions of .NET Standard projects. Supplied project type was parsed as ${manifestType}.`));
|
|
@@ -230651,11 +230654,10 @@ async function inspect(root, targetFile, options) {
|
|
|
230651
230654
|
\x1b[33m⚠ WARNING\x1b[0m: Testing a .NET project with runtime resolution enabled.
|
|
230652
230655
|
This should be considered experimental and not relied upon for production use.
|
|
230653
230656
|
Please report issues with this beta feature by submitting a support ticket, and attach the output of running this command
|
|
230654
|
-
with the debug (-d) flag at \x1b[4mhttps://support.snyk.io/hc/en-us/requests/new\x1b[0m
|
|
230655
|
-
`);
|
|
230657
|
+
with the debug (-d) flag at \x1b[4mhttps://support.snyk.io/hc/en-us/requests/new\x1b[0m.`);
|
|
230656
230658
|
// TODO: Replaced by a CLI argument when project is stabilized
|
|
230657
230659
|
const useRuntimeDependencies = true;
|
|
230658
|
-
const result = await nugetParser.buildDepGraphFromFiles(root, targetFile, manifestType, options['assets-project-name'], useRuntimeDependencies, options['project-name-prefix']);
|
|
230660
|
+
const result = await nugetParser.buildDepGraphFromFiles(root, targetFile, manifestType, options['assets-project-name'], useRuntimeDependencies, options['project-name-prefix'], options['target-framework']);
|
|
230659
230661
|
return {
|
|
230660
230662
|
dependencyGraph: result.dependencyGraph,
|
|
230661
230663
|
package: 'n/a',
|
|
@@ -230722,12 +230724,17 @@ async function restore(projectPath) {
|
|
|
230722
230724
|
return;
|
|
230723
230725
|
}
|
|
230724
230726
|
exports.restore = restore;
|
|
230725
|
-
async function publish(projectPath) {
|
|
230727
|
+
async function publish(projectPath, targetFramework) {
|
|
230726
230728
|
var _a;
|
|
230727
230729
|
const command = 'dotnet';
|
|
230728
230730
|
const args = ['publish', '--nologo'];
|
|
230729
230731
|
// Self-contained: Create all required .dlls for version investigation, don't rely on the environment.
|
|
230730
230732
|
args.push('--sc');
|
|
230733
|
+
// If your .csproj file contains multiple <TargetFramework> references, you need to supply which one you want to publish.
|
|
230734
|
+
if (targetFramework) {
|
|
230735
|
+
args.push('--framework');
|
|
230736
|
+
args.push(targetFramework);
|
|
230737
|
+
}
|
|
230731
230738
|
// The path that contains either some form of project file, or a .sln one.
|
|
230732
230739
|
// See: https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-publish#arguments
|
|
230733
230740
|
args.push(projectPath);
|
|
@@ -230935,17 +230942,25 @@ function getFileContents(fileContentPath) {
|
|
|
230935
230942
|
throw new errors_1.FileNotProcessableError(error);
|
|
230936
230943
|
}
|
|
230937
230944
|
}
|
|
230938
|
-
async function buildDepGraphFromFiles(root, targetFile, manifestType, useProjectNameFromAssetsFile, useRuntimeDependencies, projectNamePrefix) {
|
|
230945
|
+
async function buildDepGraphFromFiles(root, targetFile, manifestType, useProjectNameFromAssetsFile, useRuntimeDependencies, projectNamePrefix, targetFramework) {
|
|
230939
230946
|
var _a, _b;
|
|
230940
230947
|
const safeRoot = root || '.';
|
|
230941
230948
|
const safeTargetFile = targetFile || '.';
|
|
230942
230949
|
const fileContentPath = path.resolve(safeRoot, safeTargetFile);
|
|
230943
230950
|
const fileContent = getFileContents(fileContentPath);
|
|
230944
230951
|
const projectRootFolder = path.resolve(fileContentPath, '../../');
|
|
230945
|
-
const
|
|
230946
|
-
|
|
230952
|
+
const targetFrameworks = csProjParser
|
|
230953
|
+
.getTargetFrameworksFromProjFile(projectRootFolder)
|
|
230954
|
+
// The rest of the type is not needed in this context
|
|
230955
|
+
.map((tf) => tf.original);
|
|
230956
|
+
if (targetFrameworks.length <= 0) {
|
|
230947
230957
|
throw new errors_1.FileNotProcessableError(`unable to detect a target framework in ${projectRootFolder}, a valid one is needed to continue down this path.`);
|
|
230948
230958
|
}
|
|
230959
|
+
if (targetFramework && !targetFrameworks.includes(targetFramework)) {
|
|
230960
|
+
console.log(`\x1b[33m⚠ WARNING\x1b[0m: Supplied targetframework \x1b[1m${targetFramework}\x1b[0m was not detected in the supplied
|
|
230961
|
+
manifest file. Available targetFrameworks detected was \x1b[1m${targetFrameworks.join(',')}\x1b[0m.
|
|
230962
|
+
Will attempt to build dependency graph anyway, but the operation might fail.`);
|
|
230963
|
+
}
|
|
230949
230964
|
const parser = PARSERS['dotnet-core-v2'];
|
|
230950
230965
|
const manifest = await parser.fileContentParser.parse(fileContent);
|
|
230951
230966
|
let resolvedProjectName = getRootName(root, projectRootFolder, projectNamePrefix);
|
|
@@ -230959,15 +230974,25 @@ async function buildDepGraphFromFiles(root, targetFile, manifestType, useProject
|
|
|
230959
230974
|
debug(`project.assets.json file doesn't contain a value for 'projectName'. Using default value: ${resolvedProjectName}`);
|
|
230960
230975
|
}
|
|
230961
230976
|
}
|
|
230977
|
+
// TODO: OSM-347 - return vulnerability scans for all
|
|
230978
|
+
let decidedTargetFramework;
|
|
230979
|
+
if (!targetFramework) {
|
|
230980
|
+
console.log(`No targetFramework supplied, defaulting to using the first in the list of the manifest (\x1b[1m${targetFrameworks[0]}\x1b[0m).
|
|
230981
|
+
Supply a targetFramework by using the \x1b[1m--target-framework\x1b[0m argument.`);
|
|
230982
|
+
decidedTargetFramework = targetFrameworks[0];
|
|
230983
|
+
}
|
|
230984
|
+
else {
|
|
230985
|
+
decidedTargetFramework = targetFramework;
|
|
230986
|
+
}
|
|
230962
230987
|
let assemblyVersions = {};
|
|
230963
230988
|
if (useRuntimeDependencies) {
|
|
230964
|
-
if (!runtimeAssembly.isSupported(
|
|
230965
|
-
throw new errors_1.FileNotProcessableError(`runtime resolution flag is currently only supported for: .NET versions 5 and higher, all versions of .NET Core and all versions of .NET Standard projects. Supplied versions was parsed as: ${
|
|
230989
|
+
if (!runtimeAssembly.isSupported(decidedTargetFramework)) {
|
|
230990
|
+
throw new errors_1.FileNotProcessableError(`runtime resolution flag is currently only supported for: .NET versions 5 and higher, all versions of .NET Core and all versions of .NET Standard projects. Supplied versions was parsed as: ${decidedTargetFramework}.`);
|
|
230966
230991
|
}
|
|
230967
230992
|
// Ensure `dotnet` is installed on the system or fail trying.
|
|
230968
230993
|
await dotnet.validate();
|
|
230969
230994
|
// Run `dotnet publish` to create a self-contained publishable binary with included .dlls for assembly version inspection.
|
|
230970
|
-
const publishDir = await dotnet.publish(projectRootFolder);
|
|
230995
|
+
const publishDir = await dotnet.publish(projectRootFolder, decidedTargetFramework);
|
|
230971
230996
|
// Then inspect the dependency graph for the runtimepackage's assembly versions.
|
|
230972
230997
|
const depsFile = path.resolve(publishDir, `${projectNameFromManifestFile}.deps.json`);
|
|
230973
230998
|
assemblyVersions = runtimeAssembly.generateRuntimeAssemblies(depsFile);
|
|
@@ -230975,7 +231000,7 @@ async function buildDepGraphFromFiles(root, targetFile, manifestType, useProject
|
|
|
230975
231000
|
const depGraph = parser.depParser.parse(resolvedProjectName, manifest, assemblyVersions);
|
|
230976
231001
|
return {
|
|
230977
231002
|
dependencyGraph: depGraph,
|
|
230978
|
-
targetFramework:
|
|
231003
|
+
targetFramework: decidedTargetFramework,
|
|
230979
231004
|
};
|
|
230980
231005
|
}
|
|
230981
231006
|
exports.buildDepGraphFromFiles = buildDepGraphFromFiles;
|
|
@@ -230994,21 +231019,24 @@ async function buildDepTreeFromFiles(root, targetFile, packagesFolderPath, manif
|
|
|
230994
231019
|
packageFormatVersion: 'nuget:0.0.0',
|
|
230995
231020
|
version: '0.0.0',
|
|
230996
231021
|
};
|
|
230997
|
-
let
|
|
231022
|
+
let targetFrameworks;
|
|
230998
231023
|
try {
|
|
230999
231024
|
if (manifestType === types_1.ManifestType.DOTNET_CORE) {
|
|
231000
|
-
|
|
231025
|
+
targetFrameworks =
|
|
231026
|
+
csProjParser.getTargetFrameworksFromProjFile(projectRootFolder);
|
|
231001
231027
|
}
|
|
231002
231028
|
else {
|
|
231003
231029
|
// .csproj is in the same directory as packages.config or project.json
|
|
231004
231030
|
const fileContentParentDirectory = path.resolve(fileContentPath, '../');
|
|
231005
|
-
|
|
231031
|
+
targetFrameworks = csProjParser.getTargetFrameworksFromProjFile(fileContentParentDirectory);
|
|
231006
231032
|
// finally, for the .NETFramework project, try to assume the framework using dotnet-deps-parser
|
|
231007
|
-
if (
|
|
231033
|
+
if (targetFrameworks.length <= 0) {
|
|
231008
231034
|
// currently only process packages.config files
|
|
231009
231035
|
if (manifestType === types_1.ManifestType.PACKAGES_CONFIG) {
|
|
231010
|
-
|
|
231011
|
-
|
|
231036
|
+
const minimumTargetFramework = await packagesConfigParser.getMinimumTargetFramework(fileContent);
|
|
231037
|
+
if (minimumTargetFramework) {
|
|
231038
|
+
targetFrameworks = [minimumTargetFramework];
|
|
231039
|
+
}
|
|
231012
231040
|
}
|
|
231013
231041
|
}
|
|
231014
231042
|
}
|
|
@@ -231016,8 +231044,10 @@ async function buildDepTreeFromFiles(root, targetFile, packagesFolderPath, manif
|
|
|
231016
231044
|
catch (error) {
|
|
231017
231045
|
return Promise.reject(error);
|
|
231018
231046
|
}
|
|
231047
|
+
// TODO: OSM-347 - use more than just the first one we find
|
|
231048
|
+
const targetFramework = targetFrameworks.length > 0 ? targetFrameworks[0].original : undefined;
|
|
231019
231049
|
tree.meta = {
|
|
231020
|
-
targetFramework: targetFramework
|
|
231050
|
+
targetFramework: targetFramework,
|
|
231021
231051
|
};
|
|
231022
231052
|
const parser = PARSERS[manifestType];
|
|
231023
231053
|
const manifest = await parser.fileContentParser.parse(fileContent, tree);
|
|
@@ -231066,49 +231096,49 @@ function findFile(rootDir, filter) {
|
|
|
231066
231096
|
}
|
|
231067
231097
|
return;
|
|
231068
231098
|
}
|
|
231069
|
-
|
|
231070
|
-
|
|
231071
|
-
|
|
231072
|
-
|
|
231073
|
-
|
|
231074
|
-
|
|
231075
|
-
|
|
231099
|
+
function getTargetFrameworksFromProjFile(rootDir) {
|
|
231100
|
+
debug('Looking for your .csproj file in ' + rootDir);
|
|
231101
|
+
const csprojPath = findFile(rootDir, /.*\.csproj$/);
|
|
231102
|
+
if (!csprojPath) {
|
|
231103
|
+
debug('.csproj file not found in ' + rootDir + '.');
|
|
231104
|
+
return [];
|
|
231105
|
+
}
|
|
231106
|
+
debug(`Checking .NET framework version in .csproj file ${csprojPath}`);
|
|
231107
|
+
const csprojContents = fs.readFileSync(csprojPath, 'utf-8');
|
|
231108
|
+
let result = [];
|
|
231109
|
+
parseXML.parseString(csprojContents, (err, parsedCsprojContents) => {
|
|
231110
|
+
var _a, _b;
|
|
231111
|
+
if (err) {
|
|
231112
|
+
throw new errors_1.FileNotProcessableError(err);
|
|
231113
|
+
}
|
|
231114
|
+
const parsedTargetFrameworks = ((_b = (_a = parsedCsprojContents === null || parsedCsprojContents === void 0 ? void 0 : parsedCsprojContents.Project) === null || _a === void 0 ? void 0 : _a.PropertyGroup) === null || _b === void 0 ? void 0 : _b.reduce((targetFrameworks, propertyGroup) => {
|
|
231115
|
+
var _a, _b, _c;
|
|
231116
|
+
const targetFrameworkSource = ((_a = propertyGroup === null || propertyGroup === void 0 ? void 0 : propertyGroup.TargetFrameworkVersion) === null || _a === void 0 ? void 0 : _a[0]) ||
|
|
231117
|
+
((_b = propertyGroup === null || propertyGroup === void 0 ? void 0 : propertyGroup.TargetFramework) === null || _b === void 0 ? void 0 : _b[0]) ||
|
|
231118
|
+
((_c = propertyGroup === null || propertyGroup === void 0 ? void 0 : propertyGroup.TargetFrameworks) === null || _c === void 0 ? void 0 : _c[0]) ||
|
|
231119
|
+
'';
|
|
231120
|
+
return targetFrameworks
|
|
231121
|
+
.concat(targetFrameworkSource.split(';'))
|
|
231122
|
+
.filter(Boolean);
|
|
231123
|
+
}, [])) || [];
|
|
231124
|
+
if (parsedTargetFrameworks.length < 1) {
|
|
231125
|
+
debug('Could not find TargetFrameworkVersion/TargetFramework' +
|
|
231126
|
+
'/TargetFrameworks defined in the Project.PropertyGroup field of ' +
|
|
231127
|
+
'your .csproj file');
|
|
231128
|
+
result = [];
|
|
231076
231129
|
return;
|
|
231077
231130
|
}
|
|
231078
|
-
|
|
231079
|
-
|
|
231080
|
-
|
|
231081
|
-
|
|
231082
|
-
|
|
231083
|
-
|
|
231084
|
-
|
|
231085
|
-
|
|
231086
|
-
|
|
231087
|
-
const parsedTargetFrameworks = ((_b = (_a = parsedCsprojContents === null || parsedCsprojContents === void 0 ? void 0 : parsedCsprojContents.Project) === null || _a === void 0 ? void 0 : _a.PropertyGroup) === null || _b === void 0 ? void 0 : _b.reduce((targetFrameworks, propertyGroup) => {
|
|
231088
|
-
var _a, _b, _c;
|
|
231089
|
-
const targetFrameworkSource = ((_a = propertyGroup === null || propertyGroup === void 0 ? void 0 : propertyGroup.TargetFrameworkVersion) === null || _a === void 0 ? void 0 : _a[0]) ||
|
|
231090
|
-
((_b = propertyGroup === null || propertyGroup === void 0 ? void 0 : propertyGroup.TargetFramework) === null || _b === void 0 ? void 0 : _b[0]) ||
|
|
231091
|
-
((_c = propertyGroup === null || propertyGroup === void 0 ? void 0 : propertyGroup.TargetFrameworks) === null || _c === void 0 ? void 0 : _c[0]) ||
|
|
231092
|
-
'';
|
|
231093
|
-
return targetFrameworks
|
|
231094
|
-
.concat(targetFrameworkSource.split(';'))
|
|
231095
|
-
.filter(Boolean);
|
|
231096
|
-
}, [])) || [];
|
|
231097
|
-
if (parsedTargetFrameworks.length < 1) {
|
|
231098
|
-
debug('Could not find TargetFrameworkVersion/TargetFramework' +
|
|
231099
|
-
'/TargetFrameworks defined in the Project.PropertyGroup field of ' +
|
|
231100
|
-
'your .csproj file');
|
|
231101
|
-
}
|
|
231102
|
-
targetFrameworks = parsedTargetFrameworks
|
|
231103
|
-
.map(framework_1.toReadableFramework)
|
|
231104
|
-
.filter(Boolean);
|
|
231105
|
-
if (parsedTargetFrameworks.length > 1 && targetFrameworks.length < 1) {
|
|
231106
|
-
debug('Could not find valid/supported .NET version in csproj file located at' +
|
|
231107
|
-
csprojPath);
|
|
231108
|
-
}
|
|
231109
|
-
resolve(targetFrameworks[0]);
|
|
231110
|
-
});
|
|
231131
|
+
const targetFrameworks = parsedTargetFrameworks
|
|
231132
|
+
.map(framework_1.toReadableFramework)
|
|
231133
|
+
.filter(Boolean);
|
|
231134
|
+
if (parsedTargetFrameworks.length > 1 && targetFrameworks.length < 1) {
|
|
231135
|
+
debug('Could not find valid/supported .NET version in csproj file located at' +
|
|
231136
|
+
csprojPath);
|
|
231137
|
+
}
|
|
231138
|
+
result = targetFrameworks;
|
|
231139
|
+
return;
|
|
231111
231140
|
});
|
|
231141
|
+
return result;
|
|
231112
231142
|
}
|
|
231113
231143
|
exports.getTargetFrameworksFromProjFile = getTargetFrameworksFromProjFile;
|
|
231114
231144
|
//# sourceMappingURL=csproj-parser.js.map
|
|
@@ -231274,7 +231304,7 @@ function validateManifest(manifest) {
|
|
|
231274
231304
|
throw new errors_1.InvalidManifestError('0 targets were found in project.assets.json');
|
|
231275
231305
|
}
|
|
231276
231306
|
}
|
|
231277
|
-
|
|
231307
|
+
function parse(tree, manifest) {
|
|
231278
231308
|
debug('Trying to parse dot-net-cli manifest');
|
|
231279
231309
|
validateManifest(manifest);
|
|
231280
231310
|
if (manifest.project.version) {
|
|
@@ -231956,11 +231986,8 @@ const debug = debugModule('snyk');
|
|
|
231956
231986
|
// For a list of version naming currently available, see
|
|
231957
231987
|
// https://learn.microsoft.com/en-us/dotnet/standard/frameworks#supported-target-frameworks
|
|
231958
231988
|
function isSupported(targetFramework) {
|
|
231959
|
-
if (!('original' in targetFramework)) {
|
|
231960
|
-
return false;
|
|
231961
|
-
}
|
|
231962
231989
|
// Everything that does not start with 'net' is already game over. E.g. Windows Phone (wp) or silverlight (sl) etc.
|
|
231963
|
-
if (!targetFramework.
|
|
231990
|
+
if (!targetFramework.startsWith('net')) {
|
|
231964
231991
|
return false;
|
|
231965
231992
|
}
|
|
231966
231993
|
// What's left is:
|
|
@@ -231969,7 +231996,7 @@ function isSupported(targetFramework) {
|
|
|
231969
231996
|
// - .NET Standard: netstandardN.N and
|
|
231970
231997
|
// - .NET Framework: netNNN, all of which we support except the latter.
|
|
231971
231998
|
// So if there's a dot, we're good.
|
|
231972
|
-
if (targetFramework.
|
|
231999
|
+
if (targetFramework.includes('.')) {
|
|
231973
232000
|
return true;
|
|
231974
232001
|
}
|
|
231975
232002
|
// Otherwise it's something before .NET 5 and we're out
|