snyk-nuget-plugin 4.4.0 → 4.5.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.
@@ -34,14 +34,40 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.generate = generate;
37
+ const path = __importStar(require("path"));
37
38
  const generator = __importStar(require("./generator"));
38
39
  function targetFrameworkFromSdkVersion(sdkVersion) {
39
40
  const major = parseInt(sdkVersion.split('.')[0], 10);
40
41
  return `net${major}.0`;
41
42
  }
43
+ // Escape a filesystem path so it can be safely embedded in a double-quoted XML
44
+ // attribute value (Windows user paths can legitimately contain '&', etc.).
45
+ function xmlAttributeEscape(value) {
46
+ return value
47
+ .replace(/&/g, '&')
48
+ .replace(/</g, '&lt;')
49
+ .replace(/>/g, '&gt;')
50
+ .replace(/"/g, '&quot;');
51
+ }
42
52
  function generate(sdkVersion) {
43
53
  const targetFramework = targetFrameworkFromSdkVersion(sdkVersion);
54
+ // Offline support: we ship the (single, dependency-free) NuGet.Frameworks package
55
+ // alongside this module — in `lib` for tests, and copied into `dist` at build time.
56
+ // A generated nuget.config points `dotnet restore` at this folder as its only source,
57
+ // so projects without internet access can still be scanned.
58
+ const offlinePackagesSource = xmlAttributeEscape(path.join(__dirname, 'nupkgs'));
44
59
  const files = [
60
+ {
61
+ name: 'nuget.config',
62
+ contents: `<?xml version="1.0" encoding="utf-8"?>
63
+ <configuration>
64
+ <packageSources>
65
+ <clear />
66
+ <add key="snyk-nuget-plugin-offline" value="${offlinePackagesSource}" />
67
+ </packageSources>
68
+ </configuration>
69
+ `,
70
+ },
45
71
  {
46
72
  name: 'Parse.csproj',
47
73
  contents: `
@@ -56,8 +82,7 @@ function generate(sdkVersion) {
56
82
  </PropertyGroup>
57
83
 
58
84
  <ItemGroup>
59
- <PackageReference Include='Newtonsoft.Json' Version='13.0.3' />
60
- <PackageReference Include='NuGet.Frameworks' Version='6.7.0' />
85
+ <PackageReference Include='NuGet.Frameworks' Version='6.14.3' />
61
86
  </ItemGroup>
62
87
  </Project>
63
88
  `,
@@ -66,8 +91,8 @@ function generate(sdkVersion) {
66
91
  name: 'Program.cs',
67
92
  contents: `
68
93
  using System;
94
+ using System.Text.Json;
69
95
  using NuGet.Frameworks;
70
- using Newtonsoft.Json;
71
96
 
72
97
  class Program
73
98
  {
@@ -84,12 +109,12 @@ class Program
84
109
  try
85
110
  {
86
111
  NuGetFramework framework = NuGetFramework.Parse(shortName);
87
- string json = JsonConvert.SerializeObject(new
112
+ string json = JsonSerializer.Serialize(new
88
113
  {
89
114
  framework.Framework,
90
- framework.Version,
115
+ Version = framework.Version.ToString(),
91
116
  framework.Platform,
92
- framework.PlatformVersion,
117
+ PlatformVersion = framework.PlatformVersion?.ToString(),
93
118
  framework.HasPlatform,
94
119
  framework.HasProfile,
95
120
  framework.Profile,
@@ -103,7 +128,7 @@ class Program
103
128
  framework.IsAny,
104
129
  framework.IsSpecificFramework,
105
130
  ShortName = shortName
106
- }, Formatting.None);
131
+ });
107
132
  Console.Write(json);
108
133
  }
109
134
  catch (Exception ex)
@@ -115,7 +140,6 @@ class Program
115
140
  `,
116
141
  },
117
142
  ];
118
- const tempDir = generator.generate('csharp', files);
119
- return tempDir;
143
+ return generator.generate('csharp', files);
120
144
  }
121
145
  //# 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,4BAgFC;AAvFD,uDAAyC;AAEzC,SAAS,6BAA6B,CAAC,UAAkB;IACvD,MAAM,KAAK,GAAG,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACrD,OAAO,MAAM,KAAK,IAAI,CAAC;AACzB,CAAC;AAED,SAAgB,QAAQ,CAAC,UAAkB;IACzC,MAAM,eAAe,GAAG,6BAA6B,CAAC,UAAU,CAAC,CAAC;IAElE,MAAM,KAAK,GAAuB;QAChC;YACE,IAAI,EAAE,cAAc;YACpB,QAAQ,EAAE;;;;uBAIO,eAAe;;;;;;;;;;;;CAYrC;SACI;QACD;YACE,IAAI,EAAE,YAAY;YAClB,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDf;SACI;KACF,CAAC;IAEF,MAAM,OAAO,GAAG,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACpD,OAAO,OAAO,CAAC;AACjB,CAAC"}
1
+ {"version":3,"file":"nugetframeworks_parser.js","sourceRoot":"","sources":["../../../lib/nuget-parser/csharp/nugetframeworks_parser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,4BAiGC;AApHD,2CAA6B;AAE7B,uDAAyC;AAEzC,SAAS,6BAA6B,CAAC,UAAkB;IACvD,MAAM,KAAK,GAAG,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACrD,OAAO,MAAM,KAAK,IAAI,CAAC;AACzB,CAAC;AAED,+EAA+E;AAC/E,2EAA2E;AAC3E,SAAS,kBAAkB,CAAC,KAAa;IACvC,OAAO,KAAK;SACT,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC7B,CAAC;AAED,SAAgB,QAAQ,CAAC,UAAkB;IACzC,MAAM,eAAe,GAAG,6BAA6B,CAAC,UAAU,CAAC,CAAC;IAElE,kFAAkF;IAClF,oFAAoF;IACpF,sFAAsF;IACtF,4DAA4D;IAC5D,MAAM,qBAAqB,GAAG,kBAAkB,CAC9C,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAC/B,CAAC;IAEF,MAAM,KAAK,GAAuB;QAChC;YACE,IAAI,EAAE,cAAc;YACpB,QAAQ,EAAE;;;;kDAIkC,qBAAqB;;;CAGtE;SACI;QACD;YACE,IAAI,EAAE,cAAc;YACpB,QAAQ,EAAE;;;;uBAIO,eAAe;;;;;;;;;;;CAWrC;SACI;QACD;YACE,IAAI,EAAE,YAAY;YAClB,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDf;SACI;KACF,CAAC;IAEF,OAAO,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AAC7C,CAAC"}
package/package.json CHANGED
@@ -11,7 +11,8 @@
11
11
  "lint:eslint": "eslint '{lib,test}/**/*.ts'",
12
12
  "lint:prettier": "prettier --check '{lib,test}/**/*.{ts,csproj,json}' --log-level 'warn'",
13
13
  "lint:fix": "prettier --write '{lib,test}/**/*.{ts,csproj,json}' && eslint --fix '{lib,test}/**/*.ts'",
14
- "build": "tsc",
14
+ "build": "tsc && npm run copy-nupkgs",
15
+ "copy-nupkgs": "node -e \"require('fs').cpSync('lib/nuget-parser/csharp/nupkgs','dist/nuget-parser/csharp/nupkgs',{recursive:true})\"",
15
16
  "build:watch": "tsc -w",
16
17
  "prepare": "npm run build"
17
18
  },
@@ -65,5 +66,5 @@
65
66
  "ts-jest": "^29.1.2",
66
67
  "typescript": "^6.0.3"
67
68
  },
68
- "version": "4.4.0"
69
+ "version": "4.5.0"
69
70
  }