Skip to content

Commit

Permalink
add more parsers to the bundle (#2)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: ajvpot <ajvpot@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 8, 2022
1 parent b9266d0 commit 92a2a14
Showing 6 changed files with 392 additions and 270 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -7,9 +7,9 @@ interoperable with golang. It uses [v8go](https://github.com/rogchap/v8go) to ex

Parsers are available (checked) or planned for:
* [x] JavaScript ([snyk-nodejs-lockfile-parser](https://github.com/snyk/nodejs-lockfile-parser))
* [ ] Swift ([snyk-cocoapods-lockfile-parser](https://github.com/snyk/cocoapods-lockfile-parser))
* [ ] Swift ([@snyk/cocoapods-lockfile-parser](https://github.com/snyk/cocoapods-lockfile-parser))
* [ ] Python ([snyk-poetry-lockfile-parser](https://github.com/snyk/poetry-lockfile-parser))
* [ ] PHP ([snyk-composer-lockfile-parser](https://github.com/snyk/composer-lockfile-parser))
* [ ] PHP ([@snyk/composer-lockfile-parser](https://github.com/snyk/composer-lockfile-parser))

TODO:
* [ ] Pre-compile the js bundle instead of executing it in each isolate.
* [ ] Pre-compile the js bundle instead of executing it in each isolate.
535 changes: 277 additions & 258 deletions js/dist/built.js

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions js/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { buildDepTreeFromFiles } from "snyk-nodejs-lockfile-parser";
import { buildDepTreeFromFiles as buildJavascriptDepTreeFromFiles } from "snyk-nodejs-lockfile-parser";
import { buildDepGraph as buildPoetryDepTree } from "snyk-poetry-lockfile-parser";
import { buildDepTreeFromFiles as buildComposerDepTreeFromFiles } from "@snyk/composer-lockfile-parser";

import fs from "fs";

export { fs, buildDepTreeFromFiles };
export { fs, buildJavascriptDepTreeFromFiles, buildPoetryDepTree, buildComposerDepTreeFromFiles };
7 changes: 5 additions & 2 deletions js/package.json
Original file line number Diff line number Diff line change
@@ -9,9 +9,12 @@
"author": "",
"license": "ISC",
"dependencies": {
"snyk-nodejs-lockfile-parser": "^1.44.0",
"@snyk/cocoapods-lockfile-parser": "^3.8.0",
"@snyk/composer-lockfile-parser": "^1.4.1",
"memfs": "^3.4.12",
"node-stdlib-browser": "^1.2.0"
"node-stdlib-browser": "^1.2.0",
"snyk-nodejs-lockfile-parser": "^1.44.0",
"snyk-poetry-lockfile-parser": "^1.1.7"
},
"devDependencies": {
"esbuild": "^0.16.0",
106 changes: 102 additions & 4 deletions js/yarn.lock
Original file line number Diff line number Diff line change
@@ -119,6 +119,11 @@
resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.16.1.tgz#ca4024c5fa8bbf32cf586fd1e201d26720becc71"
integrity sha512-vxkjnTk2nCxx3eIolisfjvIN0eZj8vp27iF/fh3vQ7GXkEdK/VzbolT8Nl5YsEddrXc5RRJbHulHM0pGuY+VgQ==

"@iarna/toml@^2.2.5":
version "2.2.5"
resolved "https://registry.yarnpkg.com/@iarna/toml/-/toml-2.2.5.tgz#b32366c89b43c6f8cefbdefac778b9c828e3ba8c"
integrity sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==

"@nodelib/fs.scandir@2.1.5":
version "2.1.5"
resolved "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz"
@@ -145,6 +150,58 @@
resolved "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz"
integrity sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==

"@snyk/cli-interface@^2.9.2":
version "2.11.3"
resolved "https://registry.yarnpkg.com/@snyk/cli-interface/-/cli-interface-2.11.3.tgz#96073944cc8f17a30c5a50ef61ea5952b69a84c7"
integrity sha512-VQa8nKGQj+gJnRWXzOd5wzinXEjvA/Yna6I34lV2hiTRKA/quttWyzr6AH9KhSovd/4SflUYbu6EKuattrAEMw==
dependencies:
"@types/graphlib" "^2"

"@snyk/cocoapods-lockfile-parser@^3.8.0":
version "3.8.0"
resolved "https://registry.yarnpkg.com/@snyk/cocoapods-lockfile-parser/-/cocoapods-lockfile-parser-3.8.0.tgz#4f06ebfbec173291225bb4924b879f6d872845e8"
integrity sha512-KQpqZhBmb1a/09X8J5LNDKDmCAvT13Wv2r+WeVOpPetNEJoKdN/6FTNbAqD1mXbf3XmC1UHNMH5YzOqNrG+t4Q==
dependencies:
"@snyk/dep-graph" "^2.3.0"
"@types/js-yaml" "^3.12.1"
js-yaml "^3.13.1"
tslib "^1.10.0"

"@snyk/composer-lockfile-parser@^1.4.1":
version "1.4.1"
resolved "https://registry.yarnpkg.com/@snyk/composer-lockfile-parser/-/composer-lockfile-parser-1.4.1.tgz#2f7c93ad367520322b16d9490a208fec08445e0e"
integrity sha512-wNANv235j95NFsQuODIXCiQZ9kcyg9fz92Kg1zoGvaP3kN/ma7fgCnvQL/dyml6iouQJR5aZovjhrrfEFoKtiQ==
dependencies:
lodash.findkey "^4.6.0"
lodash.get "^4.4.2"
lodash.invert "^4.3.0"
lodash.isempty "^4.4.0"

"@snyk/dep-graph@^1.23.0":
version "1.31.0"
resolved "https://registry.yarnpkg.com/@snyk/dep-graph/-/dep-graph-1.31.0.tgz#ebe25aac857c389081b35e1a71ead3c74ecfb0a5"
integrity sha512-nGSua40dcI/ISDDW46EYSjwVZxdWohb4bDlHFYtudL5bxo0PV9wFA1QeZewKQVeHLVaGkrESXdqQubP0pFf4vA==
dependencies:
event-loop-spinner "^2.1.0"
lodash.clone "^4.5.0"
lodash.constant "^3.0.0"
lodash.filter "^4.6.0"
lodash.foreach "^4.5.0"
lodash.isempty "^4.4.0"
lodash.isequal "^4.5.0"
lodash.isfunction "^3.0.9"
lodash.isundefined "^3.0.1"
lodash.keys "^4.2.0"
lodash.map "^4.6.0"
lodash.reduce "^4.6.0"
lodash.size "^4.2.0"
lodash.transform "^4.6.0"
lodash.union "^4.6.0"
lodash.values "^4.3.0"
object-hash "^2.0.3"
semver "^7.0.0"
tslib "^1.13.0"

"@snyk/dep-graph@^2.3.0":
version "2.3.0"
resolved "https://registry.npmjs.org/@snyk/dep-graph/-/dep-graph-2.3.0.tgz"
@@ -212,11 +269,21 @@
resolved "https://registry.npmjs.org/@types/emscripten/-/emscripten-1.39.6.tgz"
integrity sha512-H90aoynNhhkQP6DRweEjJp5vfUVdIj7tdPLsu7pq89vODD/lcugKfZOsfgwpvM6XUewEp2N5dCg1Uf3Qe55Dcg==

"@types/graphlib@^2":
version "2.1.8"
resolved "https://registry.yarnpkg.com/@types/graphlib/-/graphlib-2.1.8.tgz#9edd607e4b863a33b8b78cb08385c0be6896008a"
integrity sha512-8nbbyD3zABRA9ePoBgAl2ym8cIwKQXTfv1gaIRTdY99yEOCaHfmjBeRp+BIemS8NtOqoWK7mfzWxjNrxLK3T5w==

"@types/http-cache-semantics@*":
version "4.0.1"
resolved "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.1.tgz"
integrity sha512-SZs7ekbP8CN0txVG2xVRH6EgKmEm31BOxA07vkFaETzZz1xh+cbt8BcI0slpymvwhx5dlFnQG2rTlPVQn+iRPQ==

"@types/js-yaml@^3.12.1":
version "3.12.7"
resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-3.12.7.tgz#330c5d97a3500e9c903210d6e49f02964af04a0e"
integrity sha512-S6+8JAYTE1qdsc9HMVsfY7+SgSuUU/Tp6TYTmITW0PZxiyIMvol3Gy//y69Wkhs0ti4py5qgR3uZH6uz/DNzJQ==

"@types/keyv@*":
version "4.2.0"
resolved "https://registry.npmjs.org/@types/keyv/-/keyv-4.2.0.tgz"
@@ -687,7 +754,7 @@ crypto-browserify@^3.11.0:
randombytes "^2.0.0"
randomfill "^1.0.3"

debug@^4.1.1:
debug@^4.1.1, debug@^4.2.0:
version "4.3.4"
resolved "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz"
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
@@ -1120,7 +1187,7 @@ isomorphic-timers-promises@^1.0.1:
resolved "https://registry.yarnpkg.com/isomorphic-timers-promises/-/isomorphic-timers-promises-1.0.1.tgz#e4137c24dbc54892de8abae3a4b5c1ffff381598"
integrity sha512-u4sej9B1LPSxTGKB/HiuzvEQnXH0ECYkSVQU39koSwmFAxhlEAFl9RdTvLv4TOTQUgBS5O3O5fwUxk6byBZ+IQ==

js-yaml@^3.10.0:
js-yaml@^3.10.0, js-yaml@^3.13.1:
version "3.14.1"
resolved "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz"
integrity sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==
@@ -1185,6 +1252,11 @@ lodash.filter@^4.6.0:
resolved "https://registry.npmjs.org/lodash.filter/-/lodash.filter-4.6.0.tgz"
integrity sha512-pXYUy7PR8BCLwX5mgJ/aNtyOvuJTdZAo9EQFUvMIYugqmJxnrYaANvTbgndOzHSCSR0wnlBBfRXJL5SbWxo3FQ==

lodash.findkey@^4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash.findkey/-/lodash.findkey-4.6.0.tgz#83058e903b51cbb759d09ccf546dea3ea39c4718"
integrity sha512-Y+f2R8KsUDJVqdfeai01P5A1IQeMWsMG1p0rghzdhIl7TIap47Y2Z5UJK8x4pstixNL56KVHFRE1IW9jvRwy4g==

lodash.flatmap@^4.5.0:
version "4.5.0"
resolved "https://registry.npmjs.org/lodash.flatmap/-/lodash.flatmap-4.5.0.tgz"
@@ -1195,11 +1267,21 @@ lodash.foreach@^4.5.0:
resolved "https://registry.npmjs.org/lodash.foreach/-/lodash.foreach-4.5.0.tgz"
integrity sha512-aEXTF4d+m05rVOAUG3z4vZZ4xVexLKZGF0lIxuHZ1Hplpk/3B6Z1+/ICICYRLm7c41Z2xiejbkCkJoTlypoXhQ==

lodash.get@^4.4.2:
version "4.4.2"
resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99"
integrity sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==

lodash.has@^4.5.2:
version "4.5.2"
resolved "https://registry.npmjs.org/lodash.has/-/lodash.has-4.5.2.tgz"
integrity sha512-rnYUdIo6xRCJnQmbVFEwcxF144erlD+M3YcJUVesflU9paQaE8p+fJDcIQrlMYbxoANFL+AB9hZrzSBBk5PL+g==

lodash.invert@^4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/lodash.invert/-/lodash.invert-4.3.0.tgz#8ffe20d4b616f56bea8f1aa0c6ebd80dcf742aee"
integrity sha512-3CJmOxN5y47rd+g5XjdZNcq2SorJkvlSqBwPomT094p6LZ4p7b5bUoRzYYMjwsTGWTW77z/dFZlCzeVQxBrZVg==

lodash.isempty@^4.4.0:
version "4.4.0"
resolved "https://registry.npmjs.org/lodash.isempty/-/lodash.isempty-4.4.0.tgz"
@@ -1402,6 +1484,11 @@ normalize-url@^6.0.1:
resolved "https://registry.npmjs.org/normalize-url/-/normalize-url-6.1.0.tgz"
integrity sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A==

object-hash@^2.0.3:
version "2.2.0"
resolved "https://registry.yarnpkg.com/object-hash/-/object-hash-2.2.0.tgz#5ad518581eefc443bd763472b8ff2e9c2c0d54a5"
integrity sha512-gScRMn0bS5fH+IuwyIFgnh9zBdo4DV+6GhygmWM9HyNJSgS0hScp1f5vjtm7oIIOiT9trXrShAkLFSc2IqKNgw==

object-hash@^3.0.0:
version "3.0.0"
resolved "https://registry.npmjs.org/object-hash/-/object-hash-3.0.0.tgz"
@@ -1778,6 +1865,17 @@ snyk-nodejs-lockfile-parser@^1.44.0:
tslib "^1.9.3"
uuid "^8.3.0"

snyk-poetry-lockfile-parser@^1.1.7:
version "1.1.7"
resolved "https://registry.yarnpkg.com/snyk-poetry-lockfile-parser/-/snyk-poetry-lockfile-parser-1.1.7.tgz#c7e4af4c1aefe99d51a8a18e73b148906d655bc2"
integrity sha512-5waaslW7odDlox3WQMouSh/BjBrKq2rolMox3Ij/Vaju8r/3eWvs7anikzJUzNKwNcLm8AR5u4ftG/hxqDJJgA==
dependencies:
"@iarna/toml" "^2.2.5"
"@snyk/cli-interface" "^2.9.2"
"@snyk/dep-graph" "^1.23.0"
debug "^4.2.0"
tslib "^2.0.0"

sprintf-js@~1.0.2:
version "1.0.3"
resolved "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz"
@@ -1871,12 +1969,12 @@ treeify@^1.1.0:
resolved "https://registry.npmjs.org/treeify/-/treeify-1.1.0.tgz"
integrity sha512-1m4RA7xVAJrSGrrXGs0L3YTwyvBs2S8PbRHaLZAkFw7JR8oIFwYtysxlBZhYIa7xSyiYJKZ3iGrrk55cGA3i9A==

tslib@^1.13.0, tslib@^1.9.3:
tslib@^1.10.0, tslib@^1.13.0, tslib@^1.9.3:
version "1.14.1"
resolved "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz"
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==

tslib@^2, tslib@^2.1.0:
tslib@^2, tslib@^2.0.0, tslib@^2.1.0:
version "2.4.1"
resolved "https://registry.npmjs.org/tslib/-/tslib-2.4.1.tgz"
integrity sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==
2 changes: 1 addition & 1 deletion parser/javascript/impl.go
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ func mustMarshal(v any) []byte {
}

func buildDepTree(ctx *v8go.Context, manifestPath, lockfilePath string) (*parser.PkgTree, error) {
val, err := ctx.RunScript(fmt.Sprintf(`module.exports.buildDepTreeFromFiles("./", %s, %s);`, mustMarshal(manifestPath), mustMarshal(lockfilePath)), `invoke.js`)
val, err := ctx.RunScript(fmt.Sprintf(`module.exports.buildJavascriptDepTreeFromFiles("./", %s, %s);`, mustMarshal(manifestPath), mustMarshal(lockfilePath)), `invoke.js`)
if err != nil {
return nil, err
}

0 comments on commit 92a2a14

Please sign in to comment.