snyk-nuget-plugin 4.5.0 → 4.5.1
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.
|
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.generate = generate;
|
|
37
37
|
const path = __importStar(require("path"));
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
38
39
|
const generator = __importStar(require("./generator"));
|
|
39
40
|
function targetFrameworkFromSdkVersion(sdkVersion) {
|
|
40
41
|
const major = parseInt(sdkVersion.split('.')[0], 10);
|
|
@@ -49,25 +50,38 @@ function xmlAttributeEscape(value) {
|
|
|
49
50
|
.replace(/>/g, '>')
|
|
50
51
|
.replace(/"/g, '"');
|
|
51
52
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
53
|
+
// The bundled `nupkgs` folder normally lives on disk next to this module. But when this
|
|
54
|
+
// plugin runs inside the Snyk CLI's packaged binary, `pkg` mounts everything under `dist`
|
|
55
|
+
// into a virtual snapshot filesystem, so `path.join(__dirname, 'nupkgs')` resolves to a
|
|
56
|
+
// snapshot-only path (e.g. `/snapshot/...`) that only the packaged Node process itself can
|
|
57
|
+
// read. `dotnet restore` runs as a separate OS process and can't see into that snapshot at
|
|
58
|
+
// all, so instead of pointing nuget.config there directly, we copy the offline packages
|
|
59
|
+
// into the same real, on-disk directory generator.generate() already created below for
|
|
60
|
+
// Parse.csproj/Program.cs, and point nuget.config at that.
|
|
61
|
+
function writeOfflinePackagesInto(tempDir) {
|
|
62
|
+
const nugetConfigPath = path.join(tempDir, 'nuget.config');
|
|
63
|
+
if (fs.existsSync(nugetConfigPath)) {
|
|
64
|
+
// Already populated by a previous call that hit generator.generate()'s content cache
|
|
65
|
+
// and got back this same tempDir.
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const bundledNupkgsDir = path.join(__dirname, 'nupkgs');
|
|
69
|
+
fs.mkdirSync(path.join(tempDir, 'nupkgs'));
|
|
70
|
+
for (const fileName of fs.readdirSync(bundledNupkgsDir)) {
|
|
71
|
+
fs.writeFileSync(path.join(tempDir, 'nupkgs', fileName), fs.readFileSync(path.join(bundledNupkgsDir, fileName)));
|
|
72
|
+
}
|
|
73
|
+
fs.writeFileSync(nugetConfigPath, `<?xml version="1.0" encoding="utf-8"?>
|
|
63
74
|
<configuration>
|
|
64
75
|
<packageSources>
|
|
65
76
|
<clear />
|
|
66
|
-
<add key="snyk-nuget-plugin-offline" value="${
|
|
77
|
+
<add key="snyk-nuget-plugin-offline" value="${xmlAttributeEscape(tempDir)}/nupkgs" />
|
|
67
78
|
</packageSources>
|
|
68
79
|
</configuration>
|
|
69
|
-
|
|
70
|
-
|
|
80
|
+
`);
|
|
81
|
+
}
|
|
82
|
+
function generate(sdkVersion) {
|
|
83
|
+
const targetFramework = targetFrameworkFromSdkVersion(sdkVersion);
|
|
84
|
+
const files = [
|
|
71
85
|
{
|
|
72
86
|
name: 'Parse.csproj',
|
|
73
87
|
contents: `
|
|
@@ -140,6 +154,8 @@ class Program
|
|
|
140
154
|
`,
|
|
141
155
|
},
|
|
142
156
|
];
|
|
143
|
-
|
|
157
|
+
const tempDir = generator.generate('csharp', files);
|
|
158
|
+
writeOfflinePackagesInto(tempDir);
|
|
159
|
+
return tempDir;
|
|
144
160
|
}
|
|
145
161
|
//# sourceMappingURL=nugetframeworks_parser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nugetframeworks_parser.js","sourceRoot":"","sources":["../../../lib/nuget-parser/csharp/nugetframeworks_parser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"nugetframeworks_parser.js","sourceRoot":"","sources":["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