@cyclonedx/cdxgen 8.1.9 → 8.2.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/README.md CHANGED
@@ -23,6 +23,7 @@ When used with plugins, cdxgen could generate an SBoM for Linux docker images an
23
23
  | elixir | mix.lock | Yes |
24
24
  | c/c++ | conan.lock, conanfile.txt | Yes only for conan.lock |
25
25
  | clojure | Clojure CLI (deps.edn), Leiningen (project.clj) | Yes unless the files are parsed manually due to lack of clojure cli or leiningen command |
26
+ | swift | Package.resolved, Package.swift (swiftpm) | Yes |
26
27
  | docker / oci image | All supported languages. Linux OS packages with plugins [4] | Best effort based on lock files |
27
28
  | GitHub Actions | .github/workflows/\*.yml | N/A |
28
29
  | Linux | All supported languages. Linux OS packages with plugins [5] | Best effort based on lock files |
package/docker.js CHANGED
@@ -117,7 +117,11 @@ const getDefaultOptions = () => {
117
117
  ? "npipe//./pipe/docker_engine:"
118
118
  : "unix:/var/run/docker.sock:";
119
119
  */
120
- opts.prefixUrl = isWin ? WIN_LOCAL_TLS : "unix:/var/run/docker.sock:";
120
+ opts.prefixUrl = isWin
121
+ ? WIN_LOCAL_TLS
122
+ : isDockerRootless
123
+ ? `unix:${os.homedir()}/.docker/run/docker.sock:`
124
+ : "unix:/var/run/docker.sock:";
121
125
  }
122
126
  }
123
127
  } else {
@@ -162,6 +166,18 @@ const getConnection = async (options) => {
162
166
  }
163
167
  } catch (err) {
164
168
  // console.log(err, opts);
169
+ opts.prefixUrl = `unix:${os.homedir()}/.docker/run/docker.sock:`;
170
+ try {
171
+ await got.get("_ping", opts);
172
+ dockerConn = got.extend(opts);
173
+ isDockerRootless = true;
174
+ if (DEBUG_MODE) {
175
+ console.log("Docker service in rootless mode detected!");
176
+ }
177
+ return dockerConn;
178
+ } catch (err) {
179
+ // console.log(err, opts);
180
+ }
165
181
  try {
166
182
  if (isWin) {
167
183
  opts.prefixUrl = WIN_LOCAL_TLS;
@@ -323,7 +339,7 @@ const getImage = async (fullImageName) => {
323
339
  }
324
340
  try {
325
341
  localData = await makeRequest(`images/${repo}/json`);
326
- if (DEBUG_MODE) {
342
+ if (DEBUG_MODE && localData) {
327
343
  console.log(localData);
328
344
  }
329
345
  } catch (err) {
package/index.js CHANGED
@@ -44,6 +44,11 @@ if (process.env.PIP_CMD) {
44
44
  PIP_CMD = process.env.PIP_CMD;
45
45
  }
46
46
 
47
+ let SWIFT_CMD = "swift";
48
+ if (process.env.SWIFT_CMD) {
49
+ SWIFT_CMD = process.env.SWIFT_CMD;
50
+ }
51
+
47
52
  // Construct sbt cache directory
48
53
  let SBT_CACHE_DIR =
49
54
  process.env.SBT_CACHE_DIR || pathLib.join(os.homedir(), ".ivy2", "cache");
@@ -61,6 +66,29 @@ const HASH_PATTERN =
61
66
  // Timeout milliseconds. Default 10 mins
62
67
  const TIMEOUT_MS = parseInt(process.env.CDXGEN_TIMEOUT_MS) || 10 * 60 * 1000;
63
68
 
69
+ const createDefaultParentComponent = (path) => {
70
+ // Create a parent component based on the directory name
71
+ let dirName = pathLib.dirname(path);
72
+ const tmpA = dirName.split(pathLib.sep);
73
+ dirName = tmpA[tmpA.length - 1];
74
+ const parentComponent = {
75
+ group: "",
76
+ name: dirName,
77
+ type: "application"
78
+ };
79
+ const ppurl = new PackageURL(
80
+ "application",
81
+ parentComponent.group,
82
+ parentComponent.name,
83
+ parentComponent.version,
84
+ null,
85
+ null
86
+ ).toString();
87
+ parentComponent["bom-ref"] = ppurl;
88
+ parentComponent["purl"] = ppurl;
89
+ return parentComponent;
90
+ };
91
+
64
92
  const determineParentComponent = (options) => {
65
93
  let parentComponent = undefined;
66
94
  if (options.projectName && options.projectVersion) {
@@ -1008,13 +1036,13 @@ const createJavaBom = async (path, options) => {
1008
1036
  "Resolve the above maven error. This could be due to the following:\n"
1009
1037
  );
1010
1038
  console.log(
1011
- "1. Java version requirement - Scan or the CI build agent could be using an incompatible version"
1039
+ "1. Java version requirement: cdxgen container image bundles Java 17 with gradle 8 which might be incompatible."
1012
1040
  );
1013
1041
  console.log(
1014
- "2. Private maven repository is not serving all the required maven plugins correctly. Refer to your registry documentation to add support for jitpack.io"
1042
+ "2. Private dependencies cannot be downloaded: Check if any additional arguments must be passed to maven and set them via MVN_ARGS environment variable."
1015
1043
  );
1016
1044
  console.log(
1017
- "3. Check if all required environment variables including any maven profile arguments are passed correctly to this tool"
1045
+ "3. Check if all required environment variables including any maven profile arguments are passed correctly to this tool."
1018
1046
  );
1019
1047
  // Do not fall back to methods that can produce incomplete results when failOnError is set
1020
1048
  options.failOnError && process.exit(1);
@@ -1125,7 +1153,7 @@ const createJavaBom = async (path, options) => {
1125
1153
  console.error(result.stdout, result.stderr);
1126
1154
  }
1127
1155
  console.log(
1128
- "1. Check if the correct version of java and gradle are installed and available in PATH. For example, some project might require Java 11 with gradle 7."
1156
+ "1. Check if the correct version of java and gradle are installed and available in PATH. For example, some project might require Java 11 with gradle 7.\n cdxgen container image bundles Java 17 with gradle 8 which might be incompatible."
1129
1157
  );
1130
1158
  options.failOnError && process.exit(1);
1131
1159
  }
@@ -1251,7 +1279,7 @@ const createJavaBom = async (path, options) => {
1251
1279
  }
1252
1280
  if (DEBUG_MODE || !result.stderr || options.failOnError) {
1253
1281
  console.log(
1254
- "1. Check if the correct version of java and gradle are installed and available in PATH. For example, some project might require Java 11 with gradle 7."
1282
+ "1. Check if the correct version of java and gradle are installed and available in PATH. For example, some project might require Java 11 with gradle 7.\n cdxgen container image bundles Java 17 with gradle 8 which might be incompatible."
1255
1283
  );
1256
1284
  console.log(
1257
1285
  "2. When using tools such as sdkman, the init script must be invoked to set the PATH variables correctly."
@@ -2805,6 +2833,91 @@ const createHelmBom = async (path, options) => {
2805
2833
  return {};
2806
2834
  };
2807
2835
 
2836
+ /**
2837
+ * Function to create bom string for swift projects
2838
+ *
2839
+ * @param path to the project
2840
+ * @param options Parse options from the cli
2841
+ */
2842
+ const createSwiftBom = async (path, options) => {
2843
+ const swiftFiles = utils.getAllFiles(
2844
+ path,
2845
+ (options.multiProject ? "**/" : "") + "Package*.swift"
2846
+ );
2847
+ const pkgResolvedFiles = utils.getAllFiles(
2848
+ path,
2849
+ (options.multiProject ? "**/" : "") + "Package.resolved"
2850
+ );
2851
+ let pkgList = [];
2852
+ let dependencies = [];
2853
+ let parentComponent = {};
2854
+ let completedPath = [];
2855
+ if (pkgResolvedFiles.length) {
2856
+ for (let f of pkgResolvedFiles) {
2857
+ if (!parentComponent || !Object.keys(parentComponent).length) {
2858
+ parentComponent = createDefaultParentComponent(f);
2859
+ }
2860
+ if (DEBUG_MODE) {
2861
+ console.log("Parsing", f);
2862
+ }
2863
+ const dlist = utils.parseSwiftResolved(f);
2864
+ if (dlist && dlist.length) {
2865
+ pkgList = pkgList.concat(dlist);
2866
+ }
2867
+ }
2868
+ } else if (swiftFiles.length) {
2869
+ for (let f of swiftFiles) {
2870
+ const basePath = pathLib.dirname(f);
2871
+ if (completedPath.includes(basePath)) {
2872
+ continue;
2873
+ }
2874
+ let treeData = undefined;
2875
+ if (DEBUG_MODE) {
2876
+ console.log("Executing 'swift package show-dependencies' in", basePath);
2877
+ }
2878
+ const result = spawnSync(
2879
+ SWIFT_CMD,
2880
+ ["package", "show-dependencies", "--format", "json"],
2881
+ {
2882
+ cwd: basePath,
2883
+ encoding: "utf-8",
2884
+ timeout: TIMEOUT_MS
2885
+ }
2886
+ );
2887
+ if (result.status === 0 && result.stdout) {
2888
+ completedPath.push(basePath);
2889
+ treeData = Buffer.from(result.stdout).toString();
2890
+ const retData = utils.parseSwiftJsonTree(treeData, f);
2891
+ if (retData.pkgList && retData.pkgList.length) {
2892
+ parentComponent = retData.pkgList.splice(0, 1)[0];
2893
+ parentComponent.type = "application";
2894
+ pkgList = pkgList.concat(retData.pkgList);
2895
+ }
2896
+ if (retData.dependenciesList) {
2897
+ dependencies = mergeDependencies(
2898
+ dependencies,
2899
+ retData.dependenciesList
2900
+ );
2901
+ }
2902
+ } else {
2903
+ if (DEBUG_MODE) {
2904
+ console.log(
2905
+ "Please install swift from https://www.swift.org/download/ or use the cdxgen container image"
2906
+ );
2907
+ }
2908
+ console.error(result.stderr);
2909
+ options.failOnError && process.exit(1);
2910
+ }
2911
+ }
2912
+ }
2913
+ return buildBomNSData(options, pkgList, "swift", {
2914
+ src: path,
2915
+ filename: swiftFiles.join(", "),
2916
+ parentComponent,
2917
+ dependencies
2918
+ });
2919
+ };
2920
+
2808
2921
  /**
2809
2922
  * Function to create bom string for docker compose
2810
2923
  *
@@ -4041,6 +4154,19 @@ const createXBom = async (path, options) => {
4041
4154
  if (cbFiles.length) {
4042
4155
  return await createCloudBuildBom(path, options);
4043
4156
  }
4157
+
4158
+ // Swift
4159
+ const swiftFiles = utils.getAllFiles(
4160
+ path,
4161
+ (options.multiProject ? "**/" : "") + "Package*.swift"
4162
+ );
4163
+ const pkgResolvedFiles = utils.getAllFiles(
4164
+ path,
4165
+ (options.multiProject ? "**/" : "") + "Package.resolved"
4166
+ );
4167
+ if (swiftFiles.length || pkgResolvedFiles.length) {
4168
+ return await createSwiftBom(path, options);
4169
+ }
4044
4170
  };
4045
4171
 
4046
4172
  /**
@@ -4287,6 +4413,9 @@ const createBom = async (path, options) => {
4287
4413
  case "cloudbuild":
4288
4414
  options.multiProject = true;
4289
4415
  return await createCloudBuildBom(path, options);
4416
+ case "swift":
4417
+ options.multiProject = true;
4418
+ return await createSwiftBom(path, options);
4290
4419
  default:
4291
4420
  // In recurse mode return multi-language Bom
4292
4421
  // https://github.com/cyclonedx/cdxgen/issues/95
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cyclonedx/cdxgen",
3
- "version": "8.1.9",
3
+ "version": "8.2.0",
4
4
  "description": "Creates CycloneDX Software Bill-of-Materials (SBOM) from source or container image",
5
5
  "homepage": "http://github.com/cyclonedx/cdxgen",
6
6
  "author": "Prabhu Subramanian <prabhu@appthreat.com>",
package/utils.js CHANGED
@@ -377,7 +377,7 @@ const parsePkgLock = async (pkgLockFile) => {
377
377
  type: "application"
378
378
  };
379
379
  }
380
- if (rootPkg) {
380
+ if (rootPkg && rootPkg.name) {
381
381
  const purl = new PackageURL(
382
382
  "application",
383
383
  "",
@@ -1018,7 +1018,7 @@ exports.parsePom = parsePom;
1018
1018
  */
1019
1019
  const parseMavenTree = function (rawOutput) {
1020
1020
  if (!rawOutput) {
1021
- return [];
1021
+ return {};
1022
1022
  }
1023
1023
  const deps = [];
1024
1024
  const dependenciesList = [];
@@ -1128,7 +1128,7 @@ const parseGradleDep = function (rawOutput) {
1128
1128
  level_trees[last_purl] = [];
1129
1129
  let stack = [last_purl];
1130
1130
  const depRegex =
1131
- /^.*?--- +(?<group>[^\s:]+):(?<name>[^\s:]+)(?::(?:{strictly )?(?<versionspecified>[^\s:}]+))?(?:})?(?: +-> +(?<versionoverride>[^\s:]+))?/gm;
1131
+ /^.*?--- +(?<group>[^\s:]+):(?<name>[^\s:]+)(?::(?:{strictly [[]?)?(?<versionspecified>[^,\s:}]+))?(?:})?(?:[^->]* +-> +(?<versionoverride>[^\s:]+))?/gm;
1132
1132
  while ((match = depRegex.exec(rawOutput))) {
1133
1133
  const [line, group, name, versionspecified, versionoverride] = match;
1134
1134
  const version = versionoverride || versionspecified;
@@ -3773,6 +3773,207 @@ const convertOSQueryResults = function (queryCategory, queryObj, results) {
3773
3773
  };
3774
3774
  exports.convertOSQueryResults = convertOSQueryResults;
3775
3775
 
3776
+ const _swiftDepPkgList = (pkgList, dependenciesList, depKeys, jsonData) => {
3777
+ if (jsonData && jsonData.dependencies) {
3778
+ for (let adep of jsonData.dependencies) {
3779
+ const urlOrPath = adep.url || adep.path;
3780
+ const apkg = {
3781
+ group: adep.identity || "",
3782
+ name: adep.name,
3783
+ version: adep.version
3784
+ };
3785
+ const purl = new PackageURL(
3786
+ "swift",
3787
+ apkg.group,
3788
+ apkg.name,
3789
+ apkg.version,
3790
+ null,
3791
+ null
3792
+ );
3793
+ const purlString = decodeURIComponent(purl.toString());
3794
+ if (urlOrPath) {
3795
+ if (urlOrPath.startsWith("http")) {
3796
+ apkg.repository = { url: urlOrPath };
3797
+ if (apkg.path) {
3798
+ apkg.properties = [
3799
+ {
3800
+ name: "SrcPath",
3801
+ value: apkg.path
3802
+ }
3803
+ ];
3804
+ }
3805
+ } else {
3806
+ apkg.properties = [
3807
+ {
3808
+ name: "SrcPath",
3809
+ value: urlOrPath
3810
+ }
3811
+ ];
3812
+ }
3813
+ }
3814
+ pkgList.push(apkg);
3815
+ // Handle the immediate dependencies before recursing
3816
+ if (adep.dependencies && adep.dependencies.length) {
3817
+ const deplist = [];
3818
+ for (let cdep of adep.dependencies) {
3819
+ const deppurl = new PackageURL(
3820
+ "swift",
3821
+ cdep.identity || "",
3822
+ cdep.name,
3823
+ cdep.version,
3824
+ null,
3825
+ null
3826
+ );
3827
+ const deppurlString = decodeURIComponent(deppurl.toString());
3828
+ deplist.push(deppurlString);
3829
+ }
3830
+ if (!depKeys[purlString]) {
3831
+ dependenciesList.push({
3832
+ ref: purlString,
3833
+ dependsOn: deplist
3834
+ });
3835
+ depKeys[purlString] = true;
3836
+ }
3837
+ if (adep.dependencies && adep.dependencies.length) {
3838
+ _swiftDepPkgList(pkgList, dependenciesList, depKeys, adep);
3839
+ }
3840
+ } else {
3841
+ if (!depKeys[purlString]) {
3842
+ dependenciesList.push({
3843
+ ref: purlString,
3844
+ dependsOn: []
3845
+ });
3846
+ depKeys[purlString] = true;
3847
+ }
3848
+ }
3849
+ }
3850
+ }
3851
+ return { pkgList, dependenciesList };
3852
+ };
3853
+
3854
+ /**
3855
+ * Parse swift dependency tree output
3856
+ * @param {string} rawOutput Swift dependencies json output
3857
+ * @param {string} pkgFile Package.swift file
3858
+ */
3859
+ const parseSwiftJsonTree = (rawOutput, pkgFile) => {
3860
+ if (!rawOutput) {
3861
+ return {};
3862
+ }
3863
+ const pkgList = [];
3864
+ const dependenciesList = [];
3865
+ let depKeys = {};
3866
+ let rootPkg = {};
3867
+ let jsonData = {};
3868
+ try {
3869
+ jsonData = JSON.parse(rawOutput);
3870
+ if (jsonData && jsonData.name) {
3871
+ rootPkg = {
3872
+ group: jsonData.identity || "",
3873
+ name: jsonData.name,
3874
+ version: jsonData.version
3875
+ };
3876
+ const urlOrPath = jsonData.url || jsonData.path;
3877
+ if (urlOrPath) {
3878
+ if (urlOrPath.startsWith("http")) {
3879
+ rootPkg.repository = { url: urlOrPath };
3880
+ } else {
3881
+ rootPkg.properties = [
3882
+ {
3883
+ name: "SrcPath",
3884
+ value: urlOrPath
3885
+ },
3886
+ {
3887
+ name: "SrcFile",
3888
+ value: pkgFile
3889
+ }
3890
+ ];
3891
+ }
3892
+ }
3893
+ const purl = new PackageURL(
3894
+ "application",
3895
+ rootPkg.group,
3896
+ rootPkg.name,
3897
+ rootPkg.version,
3898
+ null,
3899
+ null
3900
+ );
3901
+ const purlString = decodeURIComponent(purl.toString());
3902
+ rootPkg["bom-ref"] = purlString;
3903
+ pkgList.push(rootPkg);
3904
+ const deplist = [];
3905
+ for (const rd of jsonData.dependencies) {
3906
+ const deppurl = new PackageURL(
3907
+ "swift",
3908
+ rd.identity || "",
3909
+ rd.name,
3910
+ rd.version,
3911
+ null,
3912
+ null
3913
+ );
3914
+ const deppurlString = decodeURIComponent(deppurl.toString());
3915
+ deplist.push(deppurlString);
3916
+ }
3917
+ dependenciesList.push({
3918
+ ref: purlString,
3919
+ dependsOn: deplist
3920
+ });
3921
+ _swiftDepPkgList(pkgList, dependenciesList, depKeys, jsonData);
3922
+ }
3923
+ } catch (e) {
3924
+ if (DEBUG_MODE) {
3925
+ console.log(e);
3926
+ }
3927
+ return {};
3928
+ }
3929
+ return {
3930
+ pkgList,
3931
+ dependenciesList
3932
+ };
3933
+ };
3934
+ exports.parseSwiftJsonTree = parseSwiftJsonTree;
3935
+
3936
+ /**
3937
+ * Parse swift package resolved file
3938
+ * @param {string} resolvedFile Package.resolved file
3939
+ */
3940
+ const parseSwiftResolved = (resolvedFile) => {
3941
+ const pkgList = [];
3942
+ if (fs.existsSync(resolvedFile)) {
3943
+ try {
3944
+ const pkgData = JSON.parse(fs.readFileSync(resolvedFile, "utf8"));
3945
+ let resolvedList = [];
3946
+ if (pkgData.pins) {
3947
+ resolvedList = pkgData.pins;
3948
+ } else if (pkgData.object && pkgData.object.pins) {
3949
+ resolvedList = pkgData.object.pins;
3950
+ }
3951
+ for (const adep of resolvedList) {
3952
+ const apkg = {
3953
+ name: adep.package || adep.identity,
3954
+ group: "",
3955
+ version: adep.state.version || adep.state.revision,
3956
+ properties: [
3957
+ {
3958
+ name: "SrcFile",
3959
+ value: resolvedFile
3960
+ }
3961
+ ]
3962
+ };
3963
+ const repLocation = adep.location || adep.repositoryURL;
3964
+ if (repLocation) {
3965
+ apkg.repository = { url: repLocation };
3966
+ }
3967
+ pkgList.push(apkg);
3968
+ }
3969
+ } catch (err) {
3970
+ // continue regardless of error
3971
+ }
3972
+ }
3973
+ return pkgList;
3974
+ };
3975
+ exports.parseSwiftResolved = parseSwiftResolved;
3976
+
3776
3977
  /**
3777
3978
  * Collect maven dependencies
3778
3979
  *
package/utils.test.js CHANGED
@@ -73,7 +73,7 @@ test("finds license id from name", () => {
73
73
  test("parse gradle dependencies", () => {
74
74
  expect(utils.parseGradleDep(null)).toEqual({});
75
75
  let parsedList = utils.parseGradleDep(
76
- fs.readFileSync("./test/gradle-dep.out", (encoding = "utf-8"))
76
+ fs.readFileSync("./test/gradle-dep.out", { encoding: "utf-8" })
77
77
  );
78
78
  expect(parsedList.pkgList.length).toEqual(34);
79
79
  expect(parsedList.dependenciesList.length).toEqual(34);
@@ -87,7 +87,7 @@ test("parse gradle dependencies", () => {
87
87
  });
88
88
 
89
89
  parsedList = utils.parseGradleDep(
90
- fs.readFileSync("./test/data/gradle-android-dep.out", (encoding = "utf-8"))
90
+ fs.readFileSync("./test/data/gradle-android-dep.out", { encoding: "utf-8" })
91
91
  );
92
92
  expect(parsedList.pkgList.length).toEqual(106);
93
93
  expect(parsedList.dependenciesList.length).toEqual(106);
@@ -116,7 +116,7 @@ test("parse gradle dependencies", () => {
116
116
  version: "1.7.0"
117
117
  });
118
118
  parsedList = utils.parseGradleDep(
119
- fs.readFileSync("./test/data/gradle-out1.dep", (encoding = "utf-8"))
119
+ fs.readFileSync("./test/data/gradle-out1.dep", { encoding: "utf-8" })
120
120
  );
121
121
  expect(parsedList.pkgList.length).toEqual(90);
122
122
  expect(parsedList.dependenciesList.length).toEqual(90);
@@ -126,20 +126,99 @@ test("parse gradle dependencies", () => {
126
126
  version: "2.2.0.RELEASE",
127
127
  qualifiers: { type: "jar" }
128
128
  });
129
+
130
+ parsedList = utils.parseGradleDep(
131
+ fs.readFileSync("./test/data/gradle-rich1.dep", { encoding: "utf-8" })
132
+ );
133
+ expect(parsedList.pkgList.length).toEqual(5);
134
+ expect(parsedList.pkgList[parsedList.pkgList.length - 1]).toEqual({
135
+ group: "ch.qos.logback",
136
+ name: "logback-core",
137
+ qualifiers: { type: "jar" },
138
+ version: "1.4.5"
139
+ });
140
+ parsedList = utils.parseGradleDep(
141
+ fs.readFileSync("./test/data/gradle-rich2.dep", { encoding: "utf-8" })
142
+ );
143
+ expect(parsedList.pkgList.length).toEqual(3);
144
+ expect(parsedList.pkgList).toEqual([
145
+ {
146
+ group: "",
147
+ name: "root",
148
+ qualifiers: { type: "jar" },
149
+ type: "maven",
150
+ version: "latest"
151
+ },
152
+ {
153
+ group: "io.appium",
154
+ name: "java-client",
155
+ qualifiers: { type: "jar" },
156
+ version: "8.1.1"
157
+ },
158
+ {
159
+ group: "org.seleniumhq.selenium",
160
+ name: "selenium-support",
161
+ qualifiers: { type: "jar" },
162
+ version: "4.5.0"
163
+ }
164
+ ]);
165
+ parsedList = utils.parseGradleDep(
166
+ fs.readFileSync("./test/data/gradle-rich3.dep", { encoding: "utf-8" })
167
+ );
168
+ expect(parsedList.pkgList.length).toEqual(2);
169
+ expect(parsedList.pkgList).toEqual([
170
+ {
171
+ group: "",
172
+ name: "root",
173
+ version: "latest",
174
+ type: "maven",
175
+ qualifiers: { type: "jar" }
176
+ },
177
+ {
178
+ group: "org.seleniumhq.selenium",
179
+ name: "selenium-remote-driver",
180
+ version: "4.5.0",
181
+ qualifiers: { type: "jar" }
182
+ }
183
+ ]);
184
+ parsedList = utils.parseGradleDep(
185
+ fs.readFileSync("./test/data/gradle-rich4.dep", { encoding: "utf-8" })
186
+ );
187
+ expect(parsedList.pkgList.length).toEqual(2);
188
+ expect(parsedList.pkgList).toEqual([
189
+ {
190
+ group: "",
191
+ name: "root",
192
+ version: "latest",
193
+ type: "maven",
194
+ qualifiers: { type: "jar" }
195
+ },
196
+ {
197
+ group: "org.seleniumhq.selenium",
198
+ name: "selenium-api",
199
+ version: "4.5.0",
200
+ qualifiers: { type: "jar" }
201
+ }
202
+ ]);
203
+ parsedList = utils.parseGradleDep(
204
+ fs.readFileSync("./test/data/gradle-rich5.dep", { encoding: "utf-8" })
205
+ );
206
+ expect(parsedList.pkgList.length).toEqual(68);
207
+ expect(parsedList.dependenciesList.length).toEqual(69);
129
208
  });
130
209
 
131
210
  test("parse gradle projects", () => {
132
211
  expect(utils.parseGradleProjects(null)).toEqual([]);
133
212
  let proj_list = utils.parseGradleProjects(
134
- fs.readFileSync("./test/data/gradle-projects.out", (encoding = "utf-8"))
213
+ fs.readFileSync("./test/data/gradle-projects.out", { encoding: "utf-8" })
135
214
  );
136
215
  expect(proj_list.length).toEqual(9);
137
216
  });
138
217
 
139
218
  test("parse maven tree", () => {
140
- expect(utils.parseMavenTree(null)).toEqual([]);
219
+ expect(utils.parseMavenTree(null)).toEqual({});
141
220
  let parsedList = utils.parseMavenTree(
142
- fs.readFileSync("./test/data/sample-mvn-tree.txt", (encoding = "utf-8"))
221
+ fs.readFileSync("./test/data/sample-mvn-tree.txt", { encoding: "utf-8" })
143
222
  );
144
223
  expect(parsedList.pkgList.length).toEqual(59);
145
224
  expect(parsedList.dependenciesList.length).toEqual(59);
@@ -173,7 +252,9 @@ test("parse maven tree", () => {
173
252
  ]
174
253
  });
175
254
  parsedList = utils.parseMavenTree(
176
- fs.readFileSync("./test/data/mvn-dep-tree-simple.txt", (encoding = "utf-8"))
255
+ fs.readFileSync("./test/data/mvn-dep-tree-simple.txt", {
256
+ encoding: "utf-8"
257
+ })
177
258
  );
178
259
  expect(parsedList.pkgList.length).toEqual(27);
179
260
  expect(parsedList.dependenciesList.length).toEqual(27);
@@ -284,7 +365,7 @@ test("parseGoModData", async () => {
284
365
  "sha256-6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg="
285
366
  };
286
367
  dep_list = await utils.parseGoModData(
287
- fs.readFileSync("./test/gomod/go.mod", (encoding = "utf-8")),
368
+ fs.readFileSync("./test/gomod/go.mod", { encoding: "utf-8" }),
288
369
  gosumMap
289
370
  );
290
371
  expect(dep_list.length).toEqual(4);
@@ -326,7 +407,7 @@ test("parseGoSumData", async () => {
326
407
  let dep_list = await utils.parseGoModData(null);
327
408
  expect(dep_list).toEqual([]);
328
409
  dep_list = await utils.parseGosumData(
329
- fs.readFileSync("./test/gomod/go.sum", (encoding = "utf-8"))
410
+ fs.readFileSync("./test/gomod/go.sum", { encoding: "utf-8" })
330
411
  );
331
412
  expect(dep_list.length).toEqual(4);
332
413
  expect(dep_list[0]).toEqual({
@@ -364,7 +445,7 @@ test("parseGoSumData", async () => {
364
445
 
365
446
  test("parse go list dependencies", async () => {
366
447
  let dep_list = await utils.parseGoListDep(
367
- fs.readFileSync("./test/data/golist-dep.txt", (encoding = "utf-8")),
448
+ fs.readFileSync("./test/data/golist-dep.txt", { encoding: "utf-8" }),
368
449
  {}
369
450
  );
370
451
  expect(dep_list.length).toEqual(8);
@@ -377,11 +458,11 @@ test("parse go list dependencies", async () => {
377
458
 
378
459
  test("parse go mod why dependencies", () => {
379
460
  let pkg_name = utils.parseGoModWhy(
380
- fs.readFileSync("./test/data/gomodwhy.txt", (encoding = "utf-8"))
461
+ fs.readFileSync("./test/data/gomodwhy.txt", { encoding: "utf-8" })
381
462
  );
382
463
  expect(pkg_name).toEqual("github.com/mailgun/mailgun-go/v4");
383
464
  pkg_name = utils.parseGoModWhy(
384
- fs.readFileSync("./test/data/gomodwhynot.txt", (encoding = "utf-8"))
465
+ fs.readFileSync("./test/data/gomodwhynot.txt", { encoding: "utf-8" })
385
466
  );
386
467
  expect(pkg_name).toBeUndefined();
387
468
  });
@@ -391,7 +472,7 @@ test("parseGopkgData", async () => {
391
472
  let dep_list = await utils.parseGopkgData(null);
392
473
  expect(dep_list).toEqual([]);
393
474
  dep_list = await utils.parseGopkgData(
394
- fs.readFileSync("./test/gopkg/Gopkg.lock", (encoding = "utf-8"))
475
+ fs.readFileSync("./test/gopkg/Gopkg.lock", { encoding: "utf-8" })
395
476
  );
396
477
  expect(dep_list.length).toEqual(36);
397
478
  expect(dep_list[0]).toEqual({
@@ -407,7 +488,7 @@ test("parseGopkgData", async () => {
407
488
 
408
489
  test("parse go version data", async () => {
409
490
  let dep_list = await utils.parseGoVersionData(
410
- fs.readFileSync("./test/data/goversion.txt", (encoding = "utf-8")),
491
+ fs.readFileSync("./test/data/goversion.txt", { encoding: "utf-8" }),
411
492
  {}
412
493
  );
413
494
  expect(dep_list.length).toEqual(125);
@@ -419,7 +500,7 @@ test("parse go version data", async () => {
419
500
  license: undefined
420
501
  });
421
502
  dep_list = await utils.parseGoVersionData(
422
- fs.readFileSync("./test/data/goversion2.txt", (encoding = "utf-8")),
503
+ fs.readFileSync("./test/data/goversion2.txt", { encoding: "utf-8" }),
423
504
  {}
424
505
  );
425
506
  expect(dep_list.length).toEqual(149);
@@ -435,7 +516,7 @@ test("parse go version data", async () => {
435
516
  test("parse cargo lock", async () => {
436
517
  expect(await utils.parseCargoData(null)).toEqual([]);
437
518
  dep_list = await utils.parseCargoData(
438
- fs.readFileSync("./test/Cargo.lock", (encoding = "utf-8"))
519
+ fs.readFileSync("./test/Cargo.lock", { encoding: "utf-8" })
439
520
  );
440
521
  expect(dep_list.length).toEqual(224);
441
522
  expect(dep_list[0]).toEqual({
@@ -446,7 +527,7 @@ test("parse cargo lock", async () => {
446
527
  "sha384-6a07677093120a02583717b6dd1ef81d8de1e8d01bd226c83f0f9bdf3e56bb3a"
447
528
  });
448
529
  dep_list = await utils.parseCargoData(
449
- fs.readFileSync("./test/data/Cargom.lock", (encoding = "utf-8"))
530
+ fs.readFileSync("./test/data/Cargom.lock", { encoding: "utf-8" })
450
531
  );
451
532
  expect(dep_list.length).toEqual(242);
452
533
  expect(dep_list[0]).toEqual({
@@ -461,7 +542,7 @@ test("parse cargo lock", async () => {
461
542
  test("parse cargo toml", async () => {
462
543
  expect(await utils.parseCargoTomlData(null)).toEqual([]);
463
544
  dep_list = await utils.parseCargoTomlData(
464
- fs.readFileSync("./test/data/Cargo1.toml", (encoding = "utf-8"))
545
+ fs.readFileSync("./test/data/Cargo1.toml", { encoding: "utf-8" })
465
546
  );
466
547
  expect(dep_list.length).toEqual(4);
467
548
  expect(dep_list).toEqual([
@@ -471,7 +552,7 @@ test("parse cargo toml", async () => {
471
552
  { name: "cfg-if", version: "0.1.8" }
472
553
  ]);
473
554
  dep_list = await utils.parseCargoTomlData(
474
- fs.readFileSync("./test/data/Cargo2.toml", (encoding = "utf-8"))
555
+ fs.readFileSync("./test/data/Cargo2.toml", { encoding: "utf-8" })
475
556
  );
476
557
  expect(dep_list.length).toEqual(3);
477
558
  expect(dep_list).toEqual([
@@ -487,7 +568,7 @@ test("parse cargo toml", async () => {
487
568
  test("parse cargo auditable data", async () => {
488
569
  expect(await utils.parseCargoAuditableData(null)).toEqual([]);
489
570
  dep_list = await utils.parseCargoAuditableData(
490
- fs.readFileSync("./test/data/cargo-auditable.txt", (encoding = "utf-8"))
571
+ fs.readFileSync("./test/data/cargo-auditable.txt", { encoding: "utf-8" })
491
572
  );
492
573
  expect(dep_list.length).toEqual(32);
493
574
  expect(dep_list[0]).toEqual({
@@ -527,7 +608,7 @@ test("get crates metadata", async () => {
527
608
  test("parse pub lock", async () => {
528
609
  expect(await utils.parsePubLockData(null)).toEqual([]);
529
610
  dep_list = await utils.parsePubLockData(
530
- fs.readFileSync("./test/data/pubspec.lock", (encoding = "utf-8"))
611
+ fs.readFileSync("./test/data/pubspec.lock", { encoding: "utf-8" })
531
612
  );
532
613
  expect(dep_list.length).toEqual(26);
533
614
  expect(dep_list[0]).toEqual({
@@ -535,7 +616,7 @@ test("parse pub lock", async () => {
535
616
  version: "2.8.2"
536
617
  });
537
618
  dep_list = await utils.parsePubYamlData(
538
- fs.readFileSync("./test/data/pubspec.yaml", (encoding = "utf-8"))
619
+ fs.readFileSync("./test/data/pubspec.yaml", { encoding: "utf-8" })
539
620
  );
540
621
  expect(dep_list.length).toEqual(1);
541
622
  expect(dep_list[0]).toEqual({
@@ -574,7 +655,7 @@ test("get dart metadata", async () => {
574
655
  test("parse cabal freeze", async () => {
575
656
  expect(await utils.parseCabalData(null)).toEqual([]);
576
657
  dep_list = await utils.parseCabalData(
577
- fs.readFileSync("./test/data/cabal.project.freeze", (encoding = "utf-8"))
658
+ fs.readFileSync("./test/data/cabal.project.freeze", { encoding: "utf-8" })
578
659
  );
579
660
  expect(dep_list.length).toEqual(24);
580
661
  expect(dep_list[0]).toEqual({
@@ -582,7 +663,7 @@ test("parse cabal freeze", async () => {
582
663
  version: "0.11.3"
583
664
  });
584
665
  dep_list = await utils.parseCabalData(
585
- fs.readFileSync("./test/data/cabal-2.project.freeze", (encoding = "utf-8"))
666
+ fs.readFileSync("./test/data/cabal-2.project.freeze", { encoding: "utf-8" })
586
667
  );
587
668
  expect(dep_list.length).toEqual(366);
588
669
  expect(dep_list[0]).toEqual({
@@ -594,7 +675,7 @@ test("parse cabal freeze", async () => {
594
675
  test("parse conan data", async () => {
595
676
  expect(await utils.parseConanLockData(null)).toEqual([]);
596
677
  dep_list = await utils.parseConanLockData(
597
- fs.readFileSync("./test/data/conan.lock", (encoding = "utf-8"))
678
+ fs.readFileSync("./test/data/conan.lock", { encoding: "utf-8" })
598
679
  );
599
680
  expect(dep_list.length).toEqual(3);
600
681
  expect(dep_list[0]).toEqual({
@@ -603,7 +684,7 @@ test("parse conan data", async () => {
603
684
  });
604
685
 
605
686
  dep_list = await utils.parseConanData(
606
- fs.readFileSync("./test/data/conanfile.txt", (encoding = "utf-8"))
687
+ fs.readFileSync("./test/data/conanfile.txt", { encoding: "utf-8" })
607
688
  );
608
689
  expect(dep_list.length).toEqual(3);
609
690
  expect(dep_list[0]).toEqual({
@@ -615,7 +696,7 @@ test("parse conan data", async () => {
615
696
  test("parse clojure data", () => {
616
697
  expect(utils.parseLeiningenData(null)).toEqual([]);
617
698
  let dep_list = utils.parseLeiningenData(
618
- fs.readFileSync("./test/data/project.clj", (encoding = "utf-8"))
699
+ fs.readFileSync("./test/data/project.clj", { encoding: "utf-8" })
619
700
  );
620
701
  expect(dep_list.length).toEqual(14);
621
702
  expect(dep_list[0]).toEqual({
@@ -624,7 +705,7 @@ test("parse clojure data", () => {
624
705
  version: "2.9.9-SNAPSHOT"
625
706
  });
626
707
  dep_list = utils.parseLeiningenData(
627
- fs.readFileSync("./test/data/project.clj.1", (encoding = "utf-8"))
708
+ fs.readFileSync("./test/data/project.clj.1", { encoding: "utf-8" })
628
709
  );
629
710
  expect(dep_list.length).toEqual(17);
630
711
  expect(dep_list[0]).toEqual({
@@ -633,7 +714,7 @@ test("parse clojure data", () => {
633
714
  version: "1.9.0"
634
715
  });
635
716
  dep_list = utils.parseLeiningenData(
636
- fs.readFileSync("./test/data/project.clj.2", (encoding = "utf-8"))
717
+ fs.readFileSync("./test/data/project.clj.2", { encoding: "utf-8" })
637
718
  );
638
719
  expect(dep_list.length).toEqual(49);
639
720
  expect(dep_list[0]).toEqual({
@@ -642,7 +723,7 @@ test("parse clojure data", () => {
642
723
  version: "2.1.6"
643
724
  });
644
725
  dep_list = utils.parseEdnData(
645
- fs.readFileSync("./test/data/deps.edn", (encoding = "utf-8"))
726
+ fs.readFileSync("./test/data/deps.edn", { encoding: "utf-8" })
646
727
  );
647
728
  expect(dep_list.length).toEqual(20);
648
729
  expect(dep_list[0]).toEqual({
@@ -651,7 +732,7 @@ test("parse clojure data", () => {
651
732
  version: "1.10.3"
652
733
  });
653
734
  dep_list = utils.parseEdnData(
654
- fs.readFileSync("./test/data/deps.edn.1", (encoding = "utf-8"))
735
+ fs.readFileSync("./test/data/deps.edn.1", { encoding: "utf-8" })
655
736
  );
656
737
  expect(dep_list.length).toEqual(11);
657
738
  expect(dep_list[0]).toEqual({
@@ -660,7 +741,7 @@ test("parse clojure data", () => {
660
741
  version: "1.11.0-beta1"
661
742
  });
662
743
  dep_list = utils.parseEdnData(
663
- fs.readFileSync("./test/data/deps.edn.2", (encoding = "utf-8"))
744
+ fs.readFileSync("./test/data/deps.edn.2", { encoding: "utf-8" })
664
745
  );
665
746
  expect(dep_list.length).toEqual(5);
666
747
  expect(dep_list[0]).toEqual({
@@ -669,7 +750,7 @@ test("parse clojure data", () => {
669
750
  version: "1.2.1"
670
751
  });
671
752
  dep_list = utils.parseCljDep(
672
- fs.readFileSync("./test/data/clj-tree.txt", (encoding = "utf-8"))
753
+ fs.readFileSync("./test/data/clj-tree.txt", { encoding: "utf-8" })
673
754
  );
674
755
  expect(dep_list.length).toEqual(253);
675
756
  expect(dep_list[0]).toEqual({
@@ -679,7 +760,7 @@ test("parse clojure data", () => {
679
760
  });
680
761
 
681
762
  dep_list = utils.parseLeinDep(
682
- fs.readFileSync("./test/data/lein-tree.txt", (encoding = "utf-8"))
763
+ fs.readFileSync("./test/data/lein-tree.txt", { encoding: "utf-8" })
683
764
  );
684
765
  expect(dep_list.length).toEqual(47);
685
766
  expect(dep_list[0]).toEqual({
@@ -692,7 +773,7 @@ test("parse clojure data", () => {
692
773
  test("parse mix lock data", async () => {
693
774
  expect(await utils.parseMixLockData(null)).toEqual([]);
694
775
  dep_list = await utils.parseMixLockData(
695
- fs.readFileSync("./test/data/mix.lock", (encoding = "utf-8"))
776
+ fs.readFileSync("./test/data/mix.lock", { encoding: "utf-8" })
696
777
  );
697
778
  expect(dep_list.length).toEqual(16);
698
779
  expect(dep_list[0]).toEqual({
@@ -700,7 +781,7 @@ test("parse mix lock data", async () => {
700
781
  version: "1.7.0"
701
782
  });
702
783
  dep_list = await utils.parseMixLockData(
703
- fs.readFileSync("./test/data/mix.lock.1", (encoding = "utf-8"))
784
+ fs.readFileSync("./test/data/mix.lock.1", { encoding: "utf-8" })
704
785
  );
705
786
  expect(dep_list.length).toEqual(23);
706
787
  expect(dep_list[0]).toEqual({
@@ -712,7 +793,7 @@ test("parse mix lock data", async () => {
712
793
  test("parse github actions workflow data", async () => {
713
794
  expect(await utils.parseGitHubWorkflowData(null)).toEqual([]);
714
795
  dep_list = await utils.parseGitHubWorkflowData(
715
- fs.readFileSync("./.github/workflows/nodejs.yml", (encoding = "utf-8"))
796
+ fs.readFileSync("./.github/workflows/nodejs.yml", { encoding: "utf-8" })
716
797
  );
717
798
  expect(dep_list.length).toEqual(3);
718
799
  expect(dep_list[0]).toEqual({
@@ -721,16 +802,18 @@ test("parse github actions workflow data", async () => {
721
802
  version: "v3"
722
803
  });
723
804
  dep_list = await utils.parseGitHubWorkflowData(
724
- fs.readFileSync("./.github/workflows/repotests.yml", (encoding = "utf-8"))
805
+ fs.readFileSync("./.github/workflows/repotests.yml", { encoding: "utf-8" })
725
806
  );
726
- expect(dep_list.length).toEqual(4);
807
+ expect(dep_list.length).toEqual(5);
727
808
  expect(dep_list[0]).toEqual({
728
809
  group: "actions",
729
810
  name: "checkout",
730
811
  version: "v3"
731
812
  });
732
813
  dep_list = await utils.parseGitHubWorkflowData(
733
- fs.readFileSync("./.github/workflows/app-release.yml", (encoding = "utf-8"))
814
+ fs.readFileSync("./.github/workflows/app-release.yml", {
815
+ encoding: "utf-8"
816
+ })
734
817
  );
735
818
  expect(dep_list.length).toEqual(4);
736
819
  });
@@ -738,7 +821,7 @@ test("parse github actions workflow data", async () => {
738
821
  test("parse cs pkg data", async () => {
739
822
  expect(await utils.parseCsPkgData(null)).toEqual([]);
740
823
  const dep_list = await utils.parseCsPkgData(
741
- fs.readFileSync("./test/data/packages.config", (encoding = "utf-8"))
824
+ fs.readFileSync("./test/data/packages.config", { encoding: "utf-8" })
742
825
  );
743
826
  expect(dep_list.length).toEqual(21);
744
827
  expect(dep_list[0]).toEqual({
@@ -751,7 +834,7 @@ test("parse cs pkg data", async () => {
751
834
  test("parse cs pkg data 2", async () => {
752
835
  expect(await utils.parseCsPkgData(null)).toEqual([]);
753
836
  const dep_list = await utils.parseCsPkgData(
754
- fs.readFileSync("./test/data/packages2.config", (encoding = "utf-8"))
837
+ fs.readFileSync("./test/data/packages2.config", { encoding: "utf-8" })
755
838
  );
756
839
  expect(dep_list.length).toEqual(1);
757
840
  expect(dep_list[0]).toEqual({
@@ -764,7 +847,7 @@ test("parse cs pkg data 2", async () => {
764
847
  test("parse cs proj", async () => {
765
848
  expect(await utils.parseCsProjData(null)).toEqual([]);
766
849
  const dep_list = await utils.parseCsProjData(
767
- fs.readFileSync("./test/sample.csproj", (encoding = "utf-8"))
850
+ fs.readFileSync("./test/sample.csproj", { encoding: "utf-8" })
768
851
  );
769
852
  expect(dep_list.length).toEqual(5);
770
853
  expect(dep_list[0]).toEqual({
@@ -777,7 +860,7 @@ test("parse cs proj", async () => {
777
860
  test("parse project.assets.json", async () => {
778
861
  expect(await utils.parseCsProjAssetsData(null)).toEqual([]);
779
862
  const dep_list = await utils.parseCsProjAssetsData(
780
- fs.readFileSync("./test/data/project.assets.json", (encoding = "utf-8"))
863
+ fs.readFileSync("./test/data/project.assets.json", { encoding: "utf-8" })
781
864
  );
782
865
  expect(dep_list.length).toEqual(142);
783
866
  expect(dep_list[0]).toEqual({
@@ -792,7 +875,7 @@ test("parse project.assets.json", async () => {
792
875
  test("parse packages.lock.json", async () => {
793
876
  expect(await utils.parseCsPkgLockData(null)).toEqual([]);
794
877
  const dep_list = await utils.parseCsPkgLockData(
795
- fs.readFileSync("./test/data/packages.lock.json", (encoding = "utf-8"))
878
+ fs.readFileSync("./test/data/packages.lock.json", { encoding: "utf-8" })
796
879
  );
797
880
  expect(dep_list.length).toEqual(14);
798
881
  expect(dep_list[0]).toEqual({
@@ -805,7 +888,7 @@ test("parse packages.lock.json", async () => {
805
888
  test("parse .net cs proj", async () => {
806
889
  expect(await utils.parseCsProjData(null)).toEqual([]);
807
890
  const dep_list = await utils.parseCsProjData(
808
- fs.readFileSync("./test/data/sample-dotnet.csproj", (encoding = "utf-8"))
891
+ fs.readFileSync("./test/data/sample-dotnet.csproj", { encoding: "utf-8" })
809
892
  );
810
893
  expect(dep_list.length).toEqual(19);
811
894
  expect(dep_list[0]).toEqual({
@@ -1326,7 +1409,7 @@ test("parseComposerLock", () => {
1326
1409
 
1327
1410
  test("parseGemfileLockData", async () => {
1328
1411
  let deps = await utils.parseGemfileLockData(
1329
- fs.readFileSync("./test/data/Gemfile.lock", (encoding = "utf-8"))
1412
+ fs.readFileSync("./test/data/Gemfile.lock", { encoding: "utf-8" })
1330
1413
  );
1331
1414
  expect(deps.length).toEqual(140);
1332
1415
  expect(deps[0]).toEqual({
@@ -1337,7 +1420,7 @@ test("parseGemfileLockData", async () => {
1337
1420
 
1338
1421
  test("parseGemspecData", async () => {
1339
1422
  let deps = await utils.parseGemspecData(
1340
- fs.readFileSync("./test/data/xmlrpc.gemspec", (encoding = "utf-8"))
1423
+ fs.readFileSync("./test/data/xmlrpc.gemspec", { encoding: "utf-8" })
1341
1424
  );
1342
1425
  expect(deps.length).toEqual(1);
1343
1426
  expect(deps[0]).toEqual({
@@ -1351,14 +1434,15 @@ test("parseGemspecData", async () => {
1351
1434
  test("parse requirements.txt", async () => {
1352
1435
  jest.setTimeout(120000);
1353
1436
  let deps = await utils.parseReqFile(
1354
- fs.readFileSync(
1355
- "./test/data/requirements.comments.txt",
1356
- (encoding = "utf-8")
1357
- )
1437
+ fs.readFileSync("./test/data/requirements.comments.txt", {
1438
+ encoding: "utf-8"
1439
+ })
1358
1440
  );
1359
1441
  expect(deps.length).toEqual(31);
1360
1442
  deps = await utils.parseReqFile(
1361
- fs.readFileSync("./test/data/requirements.freeze.txt", (encoding = "utf-8"))
1443
+ fs.readFileSync("./test/data/requirements.freeze.txt", {
1444
+ encoding: "utf-8"
1445
+ })
1362
1446
  );
1363
1447
  expect(deps.length).toEqual(113);
1364
1448
  expect(deps[0]).toEqual({
@@ -1371,18 +1455,18 @@ test("parse requirements.txt", async () => {
1371
1455
  test("parse poetry.lock", async () => {
1372
1456
  jest.setTimeout(120000);
1373
1457
  let deps = await utils.parsePoetrylockData(
1374
- fs.readFileSync("./test/data/poetry.lock", (encoding = "utf-8"))
1458
+ fs.readFileSync("./test/data/poetry.lock", { encoding: "utf-8" })
1375
1459
  );
1376
1460
  expect(deps.length).toEqual(31);
1377
1461
  deps = await utils.parsePoetrylockData(
1378
- fs.readFileSync("./test/data/poetry1.lock", (encoding = "utf-8"))
1462
+ fs.readFileSync("./test/data/poetry1.lock", { encoding: "utf-8" })
1379
1463
  );
1380
1464
  expect(deps.length).toEqual(67);
1381
1465
  });
1382
1466
 
1383
1467
  test("parse wheel metadata", () => {
1384
1468
  let deps = utils.parseBdistMetadata(
1385
- fs.readFileSync("./test/data/METADATA", (encoding = "utf-8"))
1469
+ fs.readFileSync("./test/data/METADATA", { encoding: "utf-8" })
1386
1470
  );
1387
1471
  expect(deps.length).toEqual(1);
1388
1472
  expect(deps[0]).toEqual({
@@ -1394,10 +1478,9 @@ test("parse wheel metadata", () => {
1394
1478
  repository: { url: "https://github.com/adrienverge/yamllint" }
1395
1479
  });
1396
1480
  deps = utils.parseBdistMetadata(
1397
- fs.readFileSync(
1398
- "./test/data/mercurial-5.5.2-py3.8.egg-info",
1399
- (encoding = "utf-8")
1400
- )
1481
+ fs.readFileSync("./test/data/mercurial-5.5.2-py3.8.egg-info", {
1482
+ encoding: "utf-8"
1483
+ })
1401
1484
  );
1402
1485
  expect(deps.length).toEqual(1);
1403
1486
  expect(deps[0]).toEqual({
@@ -1431,7 +1514,7 @@ test("parse pipfile.lock with hashes", async () => {
1431
1514
  jest.setTimeout(120000);
1432
1515
  let deps = await utils.parsePiplockData(
1433
1516
  JSON.parse(
1434
- fs.readFileSync("./test/data/Pipfile.lock", (encoding = "utf-8"))
1517
+ fs.readFileSync("./test/data/Pipfile.lock", { encoding: "utf-8" })
1435
1518
  )
1436
1519
  );
1437
1520
  expect(deps.length).toEqual(46);
@@ -1457,7 +1540,7 @@ test("parse nupkg file", async () => {
1457
1540
 
1458
1541
  test("parse bazel skyframe", () => {
1459
1542
  let deps = utils.parseBazelSkyframe(
1460
- fs.readFileSync("./test/data/bazel/bazel-state.txt", (encoding = "utf-8"))
1543
+ fs.readFileSync("./test/data/bazel/bazel-state.txt", { encoding: "utf-8" })
1461
1544
  );
1462
1545
  expect(deps.length).toEqual(16);
1463
1546
  expect(deps[0].name).toEqual("guava");
@@ -1465,7 +1548,7 @@ test("parse bazel skyframe", () => {
1465
1548
 
1466
1549
  test("parse bazel build", () => {
1467
1550
  let projs = utils.parseBazelBuild(
1468
- fs.readFileSync("./test/data/bazel/BUILD", (encoding = "utf-8"))
1551
+ fs.readFileSync("./test/data/bazel/BUILD", { encoding: "utf-8" })
1469
1552
  );
1470
1553
  expect(projs.length).toEqual(2);
1471
1554
  expect(projs[0]).toEqual("java-maven-lib");
@@ -1473,7 +1556,7 @@ test("parse bazel build", () => {
1473
1556
 
1474
1557
  test("parse helm charts", async () => {
1475
1558
  let dep_list = await utils.parseHelmYamlData(
1476
- fs.readFileSync("./test/data/Chart.yaml", (encoding = "utf-8"))
1559
+ fs.readFileSync("./test/data/Chart.yaml", { encoding: "utf-8" })
1477
1560
  );
1478
1561
  expect(dep_list.length).toEqual(3);
1479
1562
  expect(dep_list[0]).toEqual({
@@ -1485,10 +1568,9 @@ test("parse helm charts", async () => {
1485
1568
  }
1486
1569
  });
1487
1570
  dep_list = await utils.parseHelmYamlData(
1488
- fs.readFileSync(
1489
- "./test/data/prometheus-community-index.yaml",
1490
- (encoding = "utf-8")
1491
- )
1571
+ fs.readFileSync("./test/data/prometheus-community-index.yaml", {
1572
+ encoding: "utf-8"
1573
+ })
1492
1574
  );
1493
1575
  expect(dep_list.length).toEqual(1836);
1494
1576
  expect(dep_list[0]).toEqual({
@@ -1505,25 +1587,25 @@ test("parse helm charts", async () => {
1505
1587
 
1506
1588
  test("parse container spec like files", async () => {
1507
1589
  let dep_list = await utils.parseContainerSpecData(
1508
- fs.readFileSync("./test/data/docker-compose.yml", (encoding = "utf-8"))
1590
+ fs.readFileSync("./test/data/docker-compose.yml", { encoding: "utf-8" })
1509
1591
  );
1510
1592
  expect(dep_list.length).toEqual(4);
1511
1593
  dep_list = await utils.parseContainerSpecData(
1512
- fs.readFileSync("./test/data/docker-compose-ng.yml", (encoding = "utf-8"))
1594
+ fs.readFileSync("./test/data/docker-compose-ng.yml", { encoding: "utf-8" })
1513
1595
  );
1514
1596
  expect(dep_list.length).toEqual(8);
1515
1597
  expect(dep_list[0]).toEqual({
1516
1598
  service: "frontend"
1517
1599
  });
1518
1600
  dep_list = await utils.parseContainerSpecData(
1519
- fs.readFileSync("./test/data/docker-compose-cr.yml", (encoding = "utf-8"))
1601
+ fs.readFileSync("./test/data/docker-compose-cr.yml", { encoding: "utf-8" })
1520
1602
  );
1521
1603
  expect(dep_list.length).toEqual(14);
1522
1604
  expect(dep_list[0]).toEqual({
1523
1605
  service: "crapi-identity"
1524
1606
  });
1525
1607
  dep_list = await utils.parseContainerSpecData(
1526
- fs.readFileSync("./test/data/tekton-task.yml", (encoding = "utf-8"))
1608
+ fs.readFileSync("./test/data/tekton-task.yml", { encoding: "utf-8" })
1527
1609
  );
1528
1610
  expect(dep_list.length).toEqual(2);
1529
1611
  expect(dep_list[0]).toEqual({
@@ -1531,7 +1613,7 @@ test("parse container spec like files", async () => {
1531
1613
  "docker.io/amazon/aws-cli:2.0.52@sha256:1506cec98a7101c935176d440a14302ea528b8f92fcaf4a6f1ea2d7ecef7edc4"
1532
1614
  });
1533
1615
  dep_list = await utils.parseContainerSpecData(
1534
- fs.readFileSync("./test/data/postgrescluster.yaml", (encoding = "utf-8"))
1616
+ fs.readFileSync("./test/data/postgrescluster.yaml", { encoding: "utf-8" })
1535
1617
  );
1536
1618
  expect(dep_list.length).toEqual(6);
1537
1619
  expect(dep_list[0]).toEqual({
@@ -1539,49 +1621,49 @@ test("parse container spec like files", async () => {
1539
1621
  "registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi8-14.5-1"
1540
1622
  });
1541
1623
  dep_list = await utils.parseContainerSpecData(
1542
- fs.readFileSync("./test/data/deployment.yaml", (encoding = "utf-8"))
1624
+ fs.readFileSync("./test/data/deployment.yaml", { encoding: "utf-8" })
1543
1625
  );
1544
1626
  expect(dep_list.length).toEqual(2);
1545
1627
  expect(dep_list[0]).toEqual({
1546
1628
  image: "node-typescript-example"
1547
1629
  });
1548
1630
  dep_list = await utils.parseContainerSpecData(
1549
- fs.readFileSync("./test/data/skaffold.yaml", (encoding = "utf-8"))
1631
+ fs.readFileSync("./test/data/skaffold.yaml", { encoding: "utf-8" })
1550
1632
  );
1551
1633
  expect(dep_list.length).toEqual(6);
1552
1634
  expect(dep_list[0]).toEqual({
1553
1635
  image: "leeroy-web"
1554
1636
  });
1555
1637
  dep_list = await utils.parseContainerSpecData(
1556
- fs.readFileSync("./test/data/skaffold-ms.yaml", (encoding = "utf-8"))
1638
+ fs.readFileSync("./test/data/skaffold-ms.yaml", { encoding: "utf-8" })
1557
1639
  );
1558
1640
  expect(dep_list.length).toEqual(22);
1559
1641
  expect(dep_list[0]).toEqual({
1560
1642
  image: "emailservice"
1561
1643
  });
1562
1644
  dep_list = await utils.parseContainerSpecData(
1563
- fs.readFileSync("./test/data/emailservice.yaml", (encoding = "utf-8"))
1645
+ fs.readFileSync("./test/data/emailservice.yaml", { encoding: "utf-8" })
1564
1646
  );
1565
1647
  expect(dep_list.length).toEqual(2);
1566
1648
  expect(dep_list[0]).toEqual({
1567
1649
  image: "emailservice"
1568
1650
  });
1569
1651
  dep_list = await utils.parseContainerSpecData(
1570
- fs.readFileSync("./test/data/redis.yaml", (encoding = "utf-8"))
1652
+ fs.readFileSync("./test/data/redis.yaml", { encoding: "utf-8" })
1571
1653
  );
1572
1654
  expect(dep_list.length).toEqual(2);
1573
1655
  expect(dep_list[0]).toEqual({
1574
1656
  image: "redis:alpine"
1575
1657
  });
1576
1658
  dep_list = await utils.parseContainerSpecData(
1577
- fs.readFileSync("./test/data/adservice.yaml", (encoding = "utf-8"))
1659
+ fs.readFileSync("./test/data/adservice.yaml", { encoding: "utf-8" })
1578
1660
  );
1579
1661
  expect(dep_list.length).toEqual(2);
1580
1662
  expect(dep_list[0]).toEqual({
1581
1663
  image: "gcr.io/google-samples/microservices-demo/adservice:v0.4.1"
1582
1664
  });
1583
1665
  dep_list = await utils.parseContainerSpecData(
1584
- fs.readFileSync("./test/data/kustomization.yaml", (encoding = "utf-8"))
1666
+ fs.readFileSync("./test/data/kustomization.yaml", { encoding: "utf-8" })
1585
1667
  );
1586
1668
  expect(dep_list.length).toEqual(22);
1587
1669
  expect(dep_list[0]).toEqual({
@@ -1592,7 +1674,7 @@ test("parse container spec like files", async () => {
1592
1674
  test("parse cloudbuild data", async () => {
1593
1675
  expect(await utils.parseCloudBuildData(null)).toEqual([]);
1594
1676
  dep_list = await utils.parseCloudBuildData(
1595
- fs.readFileSync("./test/data/cloudbuild.yaml", (encoding = "utf-8"))
1677
+ fs.readFileSync("./test/data/cloudbuild.yaml", { encoding: "utf-8" })
1596
1678
  );
1597
1679
  expect(dep_list.length).toEqual(1);
1598
1680
  expect(dep_list[0]).toEqual({
@@ -1612,10 +1694,9 @@ test("parse privado files", () => {
1612
1694
 
1613
1695
  test("parse openapi spec files", async () => {
1614
1696
  let aservice = await utils.parseOpenapiSpecData(
1615
- fs.readFileSync(
1616
- "./test/data/openapi/openapi-spec.json",
1617
- (encoding = "utf-8")
1618
- )
1697
+ fs.readFileSync("./test/data/openapi/openapi-spec.json", {
1698
+ encoding: "utf-8"
1699
+ })
1619
1700
  );
1620
1701
  expect(aservice.length).toEqual(1);
1621
1702
  expect(aservice[0]).toEqual({
@@ -1667,10 +1748,9 @@ test("parse openapi spec files", async () => {
1667
1748
  authenticated: true
1668
1749
  });
1669
1750
  aservice = await utils.parseOpenapiSpecData(
1670
- fs.readFileSync(
1671
- "./test/data/openapi/openapi-oai.yaml",
1672
- (encoding = "utf-8")
1673
- )
1751
+ fs.readFileSync("./test/data/openapi/openapi-oai.yaml", {
1752
+ encoding: "utf-8"
1753
+ })
1674
1754
  );
1675
1755
  expect(aservice.length).toEqual(1);
1676
1756
  expect(aservice[0]).toEqual({
@@ -1704,3 +1784,98 @@ test("parse openapi spec files", async () => {
1704
1784
  authenticated: false
1705
1785
  });
1706
1786
  });
1787
+
1788
+ test("parse swift deps files", () => {
1789
+ expect(utils.parseSwiftJsonTree(null, "./test/data/swift-deps.json")).toEqual(
1790
+ {}
1791
+ );
1792
+ let retData = utils.parseSwiftJsonTree(
1793
+ fs.readFileSync("./test/data/swift-deps.json", { encoding: "utf-8" }),
1794
+ "./test/data/swift-deps.json"
1795
+ );
1796
+ expect(retData.pkgList.length).toEqual(5);
1797
+ expect(retData.pkgList[0]).toEqual({
1798
+ group: "swift-markdown",
1799
+ name: "swift-markdown",
1800
+ version: "unspecified",
1801
+ properties: [
1802
+ { name: "SrcPath", value: "/Volumes/Work/sandbox/swift-markdown" },
1803
+ { name: "SrcFile", value: "./test/data/swift-deps.json" }
1804
+ ],
1805
+ "bom-ref": "pkg:application/swift-markdown/swift-markdown@unspecified"
1806
+ });
1807
+ expect(retData.dependenciesList.length).toEqual(5);
1808
+ expect(retData.dependenciesList[0]).toEqual({
1809
+ ref: "pkg:application/swift-markdown/swift-markdown@unspecified",
1810
+ dependsOn: [
1811
+ "pkg:swift/swift-cmark/cmark-gfm@unspecified",
1812
+ "pkg:swift/swift-argument-parser/swift-argument-parser@1.0.3",
1813
+ "pkg:swift/swift-docc-plugin/SwiftDocCPlugin@1.1.0"
1814
+ ]
1815
+ });
1816
+ expect(retData.dependenciesList[retData.dependenciesList.length - 1]).toEqual(
1817
+ {
1818
+ ref: "pkg:swift/swift-docc-symbolkit/SymbolKit@1.0.0",
1819
+ dependsOn: []
1820
+ }
1821
+ );
1822
+ retData = utils.parseSwiftJsonTree(
1823
+ fs.readFileSync("./test/data/swift-deps1.json", { encoding: "utf-8" }),
1824
+ "./test/data/swift-deps.json"
1825
+ );
1826
+ expect(retData.pkgList.length).toEqual(5);
1827
+ expect(retData.pkgList[0]).toEqual({
1828
+ group: "swift-certificates",
1829
+ name: "swift-certificates",
1830
+ version: "unspecified",
1831
+ properties: [
1832
+ {
1833
+ name: "SrcPath",
1834
+ value: "/Volumes/Work/sandbox/swift-certificates"
1835
+ },
1836
+ { name: "SrcFile", value: "./test/data/swift-deps.json" }
1837
+ ],
1838
+ "bom-ref":
1839
+ "pkg:application/swift-certificates/swift-certificates@unspecified"
1840
+ });
1841
+ expect(retData.dependenciesList).toEqual([
1842
+ {
1843
+ ref: "pkg:application/swift-certificates/swift-certificates@unspecified",
1844
+ dependsOn: ["pkg:swift/swift-crypto/swift-crypto@2.4.0"]
1845
+ },
1846
+ {
1847
+ ref: "pkg:swift/swift-crypto/swift-crypto@2.4.0",
1848
+ dependsOn: ["pkg:swift/swift-asn1/swift-asn1@0.7.0"]
1849
+ },
1850
+ {
1851
+ ref: "pkg:swift/swift-asn1/swift-asn1@0.7.0",
1852
+ dependsOn: ["pkg:swift/swift-docc-plugin/SwiftDocCPlugin@1.1.0"]
1853
+ },
1854
+ {
1855
+ ref: "pkg:swift/swift-docc-plugin/SwiftDocCPlugin@1.1.0",
1856
+ dependsOn: ["pkg:swift/swift-docc-symbolkit/SymbolKit@1.0.0"]
1857
+ },
1858
+ {
1859
+ ref: "pkg:swift/swift-docc-symbolkit/SymbolKit@1.0.0",
1860
+ dependsOn: []
1861
+ }
1862
+ ]);
1863
+ let pkgList = utils.parseSwiftResolved("./test/data/Package.resolved");
1864
+ expect(pkgList.length).toEqual(4);
1865
+ expect(pkgList[0]).toEqual({
1866
+ name: "swift-argument-parser",
1867
+ group: "",
1868
+ version: "1.0.3",
1869
+ properties: [{ name: "SrcFile", value: "./test/data/Package.resolved" }],
1870
+ repository: { url: "https://github.com/apple/swift-argument-parser" }
1871
+ });
1872
+ pkgList = utils.parseSwiftResolved("./test/data/Package2.resolved");
1873
+ expect(pkgList.length).toEqual(4);
1874
+ expect(pkgList[0]).toEqual({
1875
+ name: "swift-argument-parser",
1876
+ group: "",
1877
+ version: "1.2.2",
1878
+ properties: [{ name: "SrcFile", value: "./test/data/Package2.resolved" }],
1879
+ repository: { url: "https://github.com/apple/swift-argument-parser.git" }
1880
+ });
1881
+ });