snyk-nuget-plugin 2.7.13 → 2.7.14
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.
|
@@ -21,6 +21,18 @@ function findFile(rootDir, filter) {
|
|
|
21
21
|
}
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
|
+
function readEncodedFile(path) {
|
|
25
|
+
const buffer = fs.readFileSync(path);
|
|
26
|
+
const firstChar = buffer.readUInt16LE(0);
|
|
27
|
+
let contents;
|
|
28
|
+
if (firstChar === 0xfeff) {
|
|
29
|
+
contents = buffer.toString('utf16le');
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
contents = buffer.toString('utf8');
|
|
33
|
+
}
|
|
34
|
+
return contents;
|
|
35
|
+
}
|
|
24
36
|
function getTargetFrameworksFromProjFile(rootDir) {
|
|
25
37
|
debug('Looking for your .csproj file in ' + rootDir);
|
|
26
38
|
const csprojPath = findFile(rootDir, /.*\.csproj$/);
|
|
@@ -29,38 +41,43 @@ function getTargetFrameworksFromProjFile(rootDir) {
|
|
|
29
41
|
return [];
|
|
30
42
|
}
|
|
31
43
|
debug(`Checking .NET framework version in .csproj file ${csprojPath}`);
|
|
32
|
-
const csprojContents =
|
|
44
|
+
const csprojContents = readEncodedFile(csprojPath);
|
|
33
45
|
let result = [];
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
propertyGroup?.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
try {
|
|
47
|
+
parseXML.parseString(csprojContents, (err, parsedCsprojContents) => {
|
|
48
|
+
if (err) {
|
|
49
|
+
throw new errors_1.FileNotProcessableError(err);
|
|
50
|
+
}
|
|
51
|
+
const parsedTargetFrameworks = parsedCsprojContents?.Project?.PropertyGroup?.reduce((targetFrameworks, propertyGroup) => {
|
|
52
|
+
const targetFrameworkSource = propertyGroup?.TargetFrameworkVersion?.[0] ||
|
|
53
|
+
propertyGroup?.TargetFramework?.[0] ||
|
|
54
|
+
propertyGroup?.TargetFrameworks?.[0] ||
|
|
55
|
+
'';
|
|
56
|
+
return targetFrameworks
|
|
57
|
+
.concat(targetFrameworkSource.split(';'))
|
|
58
|
+
.filter(Boolean);
|
|
59
|
+
}, []) || [];
|
|
60
|
+
if (parsedTargetFrameworks.length < 1) {
|
|
61
|
+
debug('Could not find TargetFrameworkVersion/TargetFramework' +
|
|
62
|
+
'/TargetFrameworks defined in the Project.PropertyGroup field of ' +
|
|
63
|
+
'your .csproj file');
|
|
64
|
+
result = [];
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const targetFrameworks = parsedTargetFrameworks
|
|
68
|
+
.map(framework_1.toReadableFramework)
|
|
45
69
|
.filter(Boolean);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
result = [];
|
|
70
|
+
if (parsedTargetFrameworks.length > 1 && targetFrameworks.length < 1) {
|
|
71
|
+
debug('Could not find valid/supported .NET version in csproj file located at' +
|
|
72
|
+
csprojPath);
|
|
73
|
+
}
|
|
74
|
+
result = targetFrameworks;
|
|
52
75
|
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
debug('Could not find valid/supported .NET version in csproj file located at' +
|
|
59
|
-
csprojPath);
|
|
60
|
-
}
|
|
61
|
-
result = targetFrameworks;
|
|
62
|
-
return;
|
|
63
|
-
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
throw new errors_1.FileNotProcessableError(`Could not parse ${csprojPath}`);
|
|
80
|
+
}
|
|
64
81
|
return result;
|
|
65
82
|
}
|
|
66
83
|
//# sourceMappingURL=csproj-parser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csproj-parser.js","sourceRoot":"","sources":["../../../lib/nuget-parser/parsers/csproj-parser.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"csproj-parser.js","sourceRoot":"","sources":["../../../lib/nuget-parser/parsers/csproj-parser.ts"],"names":[],"mappings":";;AAwCA,0EAiEC;AAzGD,yCAA0E;AAE1E,yBAAyB;AACzB,6BAA6B;AAC7B,mCAAmC;AACnC,qCAAqC;AAErC,4CAAmD;AAEnD,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;AAElC,SAAS,QAAQ,CAAC,OAAO,EAAE,MAAM;IAC/B,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,0BAAiB,CAAC,gBAAgB,GAAG,OAAO,CAAC,CAAC;IAC1D,CAAC;IACD,MAAM,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACtC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAE7C,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC1B,OAAO,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC;IACD,OAAO;AACT,CAAC;AAED,SAAS,eAAe,CAAC,IAAY;IACnC,MAAM,MAAM,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAErC,MAAM,SAAS,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IACzC,IAAI,QAAgB,CAAC;IACrB,IAAI,SAAS,KAAK,MAAM,EAAE,CAAC;QACzB,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;SAAM,CAAC;QACN,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,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