@dxworks/depinder 0.1.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.
Files changed (98) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +108 -0
  3. package/dist/assets/.gitkeep +0 -0
  4. package/dist/assets/depinder.docker-compose.yml +68 -0
  5. package/dist/assets/init-mongo.d.ts +0 -0
  6. package/dist/assets/init-mongo.js +16 -0
  7. package/dist/assets/init-mongo.js.map +1 -0
  8. package/dist/cache/cache.d.ts +9 -0
  9. package/dist/cache/cache.js +18 -0
  10. package/dist/cache/cache.js.map +1 -0
  11. package/dist/cache/json-cache.d.ts +2 -0
  12. package/dist/cache/json-cache.js +45 -0
  13. package/dist/cache/json-cache.js.map +1 -0
  14. package/dist/cache/mongo-cache.d.ts +5 -0
  15. package/dist/cache/mongo-cache.js +97 -0
  16. package/dist/cache/mongo-cache.js.map +1 -0
  17. package/dist/commands/analyse.d.ts +8 -0
  18. package/dist/commands/analyse.js +215 -0
  19. package/dist/commands/analyse.js.map +1 -0
  20. package/dist/commands/cache.d.ts +11 -0
  21. package/dist/commands/cache.js +83 -0
  22. package/dist/commands/cache.js.map +1 -0
  23. package/dist/commands/info.d.ts +0 -0
  24. package/dist/commands/info.js +190 -0
  25. package/dist/commands/info.js.map +1 -0
  26. package/dist/commands/update.d.ts +3 -0
  27. package/dist/commands/update.js +85 -0
  28. package/dist/commands/update.js.map +1 -0
  29. package/dist/depinder.d.ts +2 -0
  30. package/dist/depinder.js +16 -0
  31. package/dist/depinder.js.map +1 -0
  32. package/dist/extension-points/code-impact.d.ts +14 -0
  33. package/dist/extension-points/code-impact.js +3 -0
  34. package/dist/extension-points/code-impact.js.map +1 -0
  35. package/dist/extension-points/extract.d.ts +36 -0
  36. package/dist/extension-points/extract.js +3 -0
  37. package/dist/extension-points/extract.js.map +1 -0
  38. package/dist/extension-points/plugin-loader.d.ts +2 -0
  39. package/dist/extension-points/plugin-loader.js +18 -0
  40. package/dist/extension-points/plugin-loader.js.map +1 -0
  41. package/dist/extension-points/plugin.d.ts +13 -0
  42. package/dist/extension-points/plugin.js +3 -0
  43. package/dist/extension-points/plugin.js.map +1 -0
  44. package/dist/extension-points/registrar.d.ts +41 -0
  45. package/dist/extension-points/registrar.js +59 -0
  46. package/dist/extension-points/registrar.js.map +1 -0
  47. package/dist/extension-points/vulnerability-checker.d.ts +21 -0
  48. package/dist/extension-points/vulnerability-checker.js +3 -0
  49. package/dist/extension-points/vulnerability-checker.js.map +1 -0
  50. package/dist/index.d.ts +2 -0
  51. package/dist/index.js +7 -0
  52. package/dist/index.js.map +1 -0
  53. package/dist/info/php/parser.d.ts +80 -0
  54. package/dist/info/php/parser.js +61 -0
  55. package/dist/info/php/parser.js.map +1 -0
  56. package/dist/plugins/dotnet/index.d.ts +11 -0
  57. package/dist/plugins/dotnet/index.js +146 -0
  58. package/dist/plugins/dotnet/index.js.map +1 -0
  59. package/dist/plugins/index.d.ts +3 -0
  60. package/dist/plugins/index.js +35 -0
  61. package/dist/plugins/index.js.map +1 -0
  62. package/dist/plugins/java/google.registrar.d.ts +0 -0
  63. package/dist/plugins/java/google.registrar.js +59 -0
  64. package/dist/plugins/java/google.registrar.js.map +1 -0
  65. package/dist/plugins/java/index.d.ts +7 -0
  66. package/dist/plugins/java/index.js +152 -0
  67. package/dist/plugins/java/index.js.map +1 -0
  68. package/dist/plugins/java/parsers/maven.d.ts +2 -0
  69. package/dist/plugins/java/parsers/maven.js +51 -0
  70. package/dist/plugins/java/parsers/maven.js.map +1 -0
  71. package/dist/plugins/javascript/index.d.ts +4 -0
  72. package/dist/plugins/javascript/index.js +151 -0
  73. package/dist/plugins/javascript/index.js.map +1 -0
  74. package/dist/plugins/php/index.d.ts +9 -0
  75. package/dist/plugins/php/index.js +131 -0
  76. package/dist/plugins/php/index.js.map +1 -0
  77. package/dist/plugins/php/php-interfaces.d.ts +117 -0
  78. package/dist/plugins/php/php-interfaces.js +67 -0
  79. package/dist/plugins/php/php-interfaces.js.map +1 -0
  80. package/dist/plugins/python/index.d.ts +15 -0
  81. package/dist/plugins/python/index.js +235 -0
  82. package/dist/plugins/python/index.js.map +1 -0
  83. package/dist/plugins/ruby/index.d.ts +4 -0
  84. package/dist/plugins/ruby/index.js +142 -0
  85. package/dist/plugins/ruby/index.js.map +1 -0
  86. package/dist/utils/blacklist.d.ts +1 -0
  87. package/dist/utils/blacklist.js +13 -0
  88. package/dist/utils/blacklist.js.map +1 -0
  89. package/dist/utils/npm.d.ts +8 -0
  90. package/dist/utils/npm.js +19 -0
  91. package/dist/utils/npm.js.map +1 -0
  92. package/dist/utils/utils.d.ts +10 -0
  93. package/dist/utils/utils.js +58 -0
  94. package/dist/utils/utils.js.map +1 -0
  95. package/dist/utils/vulnerabilities.d.ts +5 -0
  96. package/dist/utils/vulnerabilities.js +103 -0
  97. package/dist/utils/vulnerabilities.js.map +1 -0
  98. package/package.json +109 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2021 DxWorks
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,108 @@
1
+ # Dxworks depinder
2
+
3
+ This project was generated using the `dxworks-template-node-ts` repository template.
4
+
5
+ ## Installation
6
+
7
+ Use `npm` to install
8
+
9
+ ```shell
10
+ npm i -g @dxworks/depinder
11
+ ```
12
+
13
+ or, to use it from `dxw cli`:
14
+
15
+ ```shell
16
+ dxw plugin i @dxworks/depinder
17
+ ```
18
+
19
+ To check if the installation was successful, run:
20
+
21
+ ```shell
22
+ depinder --version
23
+ ```
24
+
25
+ ## Configuration
26
+ `Depinder` relies on `GitHub` and `Libraries.io` to get information about packages and known security vulnerabilities. In order to call these downstream services, you need to add two environment variables with the corresponding tokens:
27
+ - `GH_TOKEN` should contain a `GitHub` token with the `read:packages` scope.
28
+ - `LIBRARIES_IO_API_KEY` should contain the `Libraries.io` API Key.
29
+
30
+ ## Preprocess data
31
+ If you want to run `Depinder` on a project that has not been processed by `Depminer` before,
32
+ you need to run the following command to generate the folder structure:
33
+
34
+ ```shell
35
+ dxw depminer construct <path-to-dx-dependencies-folder> <path-to-exported-folder>
36
+ ```
37
+
38
+ After doing this, some package managers will require some more post-processing, in order to generate the `dependency tree` or the `lock file`.
39
+
40
+ ### Maven
41
+ To generate the `dependency tree` for a maven project, run the following command in each project (or root project in case they contain modules):
42
+
43
+ ```shell
44
+ mvn dependency:tree -DoutputFile=deptree.txt
45
+ ```
46
+ This command should create a `deptree.txt` file next to each `pom.xml` file.
47
+ This file will be processed by MavenMiner to generate the a `pom.json` file, that corresponds to the expectations that the `Depinder` Java plugin has.
48
+
49
+
50
+ ### Gradle
51
+ To generate the `dependency tree` for a gradle project, run the following command in each project (or root project in case they contain modules):
52
+
53
+ ```shell
54
+ gradle dependencies --configuration compileClasspath > deptree.txt
55
+ ```
56
+ This command should create a `deptree.txt` file next to each `build.gradle` file.
57
+ This file will be processed by GradleMiner to generate the a `gradle.json` file, that corresponds to the expectations that the `Depinder` Java plugin has.
58
+
59
+ ## Usage
60
+ The following commands can be used either as standalone, or with the `dxw` prefix ahead.
61
+
62
+ ### Cache command
63
+
64
+ To check if the MongoDB cache is running:
65
+ ```shell
66
+ depinder cache
67
+ ```
68
+
69
+ To initalise the Redis cache:
70
+ ```shell
71
+ depinder cache init
72
+ ```
73
+
74
+ To start the MongoDB cache:
75
+ ```shell
76
+ depinder cache start
77
+ ```
78
+
79
+ To stop the MongoDB cache:
80
+ ```shell
81
+ depinder cache stop
82
+ ```
83
+
84
+ To see what is available in the cache, please visit the [Mongo Express Dashboard](http://localhost:8002/).
85
+
86
+ ### Analyse
87
+ To analyse a project, run the following command:
88
+
89
+ ```shell
90
+ depinder analyse <paths-to-analysed-project-folders> ... -r <path-to-results-folder>
91
+ ```
92
+ This command gets as an argument multiple fully qualified folder paths and will automatically run all plugins that are available for the project's used languages
93
+ and export the results in the specified `results` folder.
94
+
95
+ ## Acknowledgements
96
+
97
+ Packagist api calls were inspired by [packagist-api-client](https://www.npmjs.com/package/packagist-api-client).
98
+ Depinder also uses some libraries from `Snyk.io` to parse dependency files.
99
+
100
+ ## Contributing
101
+
102
+ Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
103
+
104
+ Please make sure to update tests as appropriate.
105
+
106
+ ## License
107
+
108
+ [Apache-2.0](https://choosealicense.com/licenses/apache)
File without changes
@@ -0,0 +1,68 @@
1
+ version: "3.8"
2
+
3
+ services:
4
+ # redis-stack:
5
+ # image: redis/redis-stack:latest
6
+ # container_name: depinder-redis-stack
7
+ # ports:
8
+ # - "6379:6379"
9
+ # - "8001:8001"
10
+ # volumes:
11
+ # - depinder_redis_data:/data
12
+ # networks:
13
+ # - traefiknet
14
+ # labels:
15
+ # #### Labels define the behavior and rules of the traefik proxy for this container ####
16
+ # - "traefik.enable=true" # <== Enable traefik on itself to view dashboard and assign subdomain to view it
17
+ # - "traefik.http.routers.redis.rule=Host(`depinder.redisinsight.localhost`)" # <== Setting the domain for the dashboard
18
+ # - "traefik.http.routers.redis.service=redis" # <== Enabling the api to be a service to access
19
+ # - "traefik.http.services.redis.loadbalancer.server.port=8001" # <== Enabling the api to be a service to access
20
+ # - "traefik.docker.network=traefiknet"
21
+ # - "traefik.http.routers.redis.tls=true"
22
+ # - "traefik.http.routers.redis.tls.certresolver=default"
23
+
24
+ mongo:
25
+ image: mongo:latest
26
+ container_name: depinder-mongo
27
+ environment:
28
+ MONGO_INITDB_ROOT_USERNAME: root
29
+ MONGO_INITDB_ROOT_PASSWORD: secret
30
+ ports:
31
+ - "27018:27017"
32
+ volumes:
33
+ - depinder_mongo_data:/data/db
34
+ - ./init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js
35
+ networks:
36
+ - traefiknet
37
+
38
+ mongo-express:
39
+ image: mongo-express:latest
40
+ container_name: depinder-mongo-express
41
+ restart: unless-stopped
42
+ ports:
43
+ - "8002:8081"
44
+ environment:
45
+ ME_CONFIG_MONGODB_ADMINUSERNAME: root
46
+ ME_CONFIG_MONGODB_ADMINPASSWORD: secret
47
+ ME_CONFIG_MONGODB_URL: mongodb://root:secret@mongo:27017/
48
+ networks:
49
+ - traefiknet
50
+ labels:
51
+ - "traefik.enable=true"
52
+ - "traefik.http.routers.mongo-express.rule=Host(`depinder.mongoexpress.localhost`)"
53
+ - "traefik.http.routers.mongo-express.service=mongo-express"
54
+ - "traefik.http.services.mongo-express.loadbalancer.server.port=8081"
55
+ - "traefik.docker.network=traefiknet"
56
+ - "traefik.http.routers.mongo-express.tls=true"
57
+ - "traefik.http.routers.mongo-express.tls.certresolver=default"
58
+ depends_on:
59
+ - mongo
60
+
61
+ volumes:
62
+ # depinder_redis_data:
63
+ depinder_mongo_data:
64
+
65
+ networks:
66
+ traefiknet:
67
+ external: true
68
+
File without changes
@@ -0,0 +1,16 @@
1
+ db = db.getSiblingDB('depinder')
2
+
3
+ db.createUser(
4
+ {
5
+ user: 'depinder',
6
+ pwd: 'depinder',
7
+ roles: [
8
+ {
9
+ role: 'readWrite',
10
+ db: 'depinder',
11
+ },
12
+ ],
13
+ }
14
+ )
15
+
16
+ db.intialisationCollection.insert({ initialized: true });
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-mongo.js","sourceRoot":"","sources":["../../src/assets/init-mongo.js"],"names":[],"mappings":";AAAA,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,UAAU,CAAC,CAAA;AAEhC,EAAE,CAAC,UAAU,CACT;IACI,IAAI,EAAE,UAAU;IAChB,GAAG,EAAE,UAAU;IACf,KAAK,EAAE;QACH;YACI,IAAI,EAAE,WAAW;YACjB,EAAE,EAAE,UAAU;SACjB;KACJ;CACJ,CACJ,CAAA;AAED,EAAE,CAAC,uBAAuB,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { LibraryInfo } from '../extension-points/registrar';
2
+ export interface Cache {
3
+ get: (key: string) => LibraryInfo | Promise<LibraryInfo> | undefined | any;
4
+ set: (key: string, value: LibraryInfo) => void | Promise<void>;
5
+ has: (key: string) => boolean | Promise<boolean>;
6
+ load: () => void | Promise<void>;
7
+ write: () => void | Promise<void>;
8
+ }
9
+ export declare const noCache: Cache;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.noCache = void 0;
4
+ exports.noCache = {
5
+ get(key) {
6
+ return undefined;
7
+ },
8
+ set(key, value) {
9
+ },
10
+ has(key) {
11
+ return false;
12
+ },
13
+ load() {
14
+ },
15
+ write() {
16
+ },
17
+ };
18
+ //# sourceMappingURL=cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.js","sourceRoot":"","sources":["../../src/cache/cache.ts"],"names":[],"mappings":";;;AAUa,QAAA,OAAO,GAAU;IAC1B,GAAG,CAAC,GAAW;QACX,OAAO,SAAS,CAAA;IACpB,CAAC;IACD,GAAG,CAAC,GAAW,EAAE,KAAkB;IAEnC,CAAC;IACD,GAAG,CAAC,GAAW;QACX,OAAO,KAAK,CAAA;IAChB,CAAC;IACD,IAAI;IACJ,CAAC;IACD,KAAK;IACL,CAAC;CACJ,CAAA"}
@@ -0,0 +1,2 @@
1
+ import { Cache } from './cache';
2
+ export declare const jsonCache: Cache;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.jsonCache = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const CACHE_FILE_NAME = 'libs.json';
10
+ function loadCache() {
11
+ const cacheFile = path_1.default.resolve(process.cwd(), 'cache', CACHE_FILE_NAME);
12
+ if (!fs_1.default.existsSync(cacheFile)) {
13
+ fs_1.default.mkdirSync(path_1.default.resolve(process.cwd(), 'cache'), { recursive: true });
14
+ fs_1.default.writeFileSync(cacheFile, '{}');
15
+ }
16
+ const json = JSON.parse(fs_1.default.readFileSync(cacheFile, 'utf8').toString());
17
+ return new Map(Object.entries(json));
18
+ }
19
+ let libMap;
20
+ exports.jsonCache = {
21
+ get(key) {
22
+ if (!libMap) {
23
+ this.load();
24
+ }
25
+ return libMap.get(key);
26
+ }, set(key, value) {
27
+ if (!libMap) {
28
+ this.load();
29
+ }
30
+ libMap.set(key, value);
31
+ },
32
+ has(key) {
33
+ if (!libMap) {
34
+ this.load();
35
+ }
36
+ return libMap.has(key);
37
+ },
38
+ write() {
39
+ fs_1.default.writeFileSync(path_1.default.resolve(process.cwd(), 'cache', 'libs.json'), JSON.stringify(Object.fromEntries(libMap)));
40
+ },
41
+ load() {
42
+ libMap = loadCache();
43
+ },
44
+ };
45
+ //# sourceMappingURL=json-cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-cache.js","sourceRoot":"","sources":["../../src/cache/json-cache.ts"],"names":[],"mappings":";;;;;;AACA,gDAAuB;AACvB,4CAAmB;AAGnB,MAAM,eAAe,GAAG,WAAW,CAAA;AAEnC,SAAS,SAAS;IACd,MAAM,SAAS,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,eAAe,CAAC,CAAA;IACvE,IAAG,CAAC,YAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;QAC1B,YAAE,CAAC,SAAS,CAAC,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,EAAE,EAAC,SAAS,EAAE,IAAI,EAAC,CAAC,CAAA;QACrE,YAAE,CAAC,aAAa,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;KACpC;IACD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAA;IACtE,OAAO,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;AACxC,CAAC;AAED,IAAI,MAAgC,CAAA;AACvB,QAAA,SAAS,GAAU;IAC5B,GAAG,CAAC,GAAW;QACX,IAAI,CAAC,MAAM,EAAE;YACT,IAAI,CAAC,IAAI,EAAE,CAAA;SACd;QACD,OAAO,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAC1B,CAAC,EAAE,GAAG,CAAC,GAAW,EAAE,KAAU;QAC1B,IAAI,CAAC,MAAM,EAAE;YACT,IAAI,CAAC,IAAI,EAAE,CAAA;SACd;QACD,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IAC1B,CAAC;IACD,GAAG,CAAC,GAAW;QACX,IAAI,CAAC,MAAM,EAAE;YACT,IAAI,CAAC,IAAI,EAAE,CAAA;SACd;QACD,OAAO,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAC1B,CAAC;IACD,KAAK;QACD,YAAE,CAAC,aAAa,CAAC,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;IACnH,CAAC;IACD,IAAI;QACA,MAAM,GAAG,SAAS,EAAE,CAAA;IACxB,CAAC;CACJ,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { Cache } from './cache';
2
+ import { Model } from 'mongoose';
3
+ import { LibraryInfo } from '../extension-points/registrar';
4
+ export declare const LibraryInfoModel: Model<LibraryInfo>;
5
+ export declare const mongoCache: Cache;
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var _a, _b, _c;
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.mongoCache = exports.LibraryInfoModel = void 0;
28
+ const mongoose_1 = __importStar(require("mongoose"));
29
+ const LibraryVersionSchema = new mongoose_1.Schema({
30
+ version: String,
31
+ timestamp: Number,
32
+ licenses: mongoose_1.Schema.Types.Mixed,
33
+ downloads: Number,
34
+ latest: Boolean,
35
+ });
36
+ const VulnerabilitySchema = new mongoose_1.Schema({
37
+ severity: String,
38
+ score: Number,
39
+ description: String,
40
+ summary: String,
41
+ timestamp: Number,
42
+ permalink: String,
43
+ identifiers: [mongoose_1.Schema.Types.Mixed],
44
+ references: [mongoose_1.Schema.Types.Mixed],
45
+ vulnerableRange: String,
46
+ vulnerableVersions: String,
47
+ firstPatchedVersion: String,
48
+ });
49
+ const LibraryInfoSchema = new mongoose_1.Schema({
50
+ _id: String,
51
+ name: { type: String, required: true },
52
+ description: String,
53
+ versions: [LibraryVersionSchema],
54
+ licenses: [String],
55
+ keywords: [String],
56
+ issuesUrl: [String],
57
+ reposUrl: [String],
58
+ homepageUrl: [String],
59
+ documentationUrl: [String],
60
+ packageUrl: [String],
61
+ downloads: Number,
62
+ authors: [String],
63
+ vulnerabilities: [VulnerabilitySchema],
64
+ requiresLicenseAcceptance: Boolean,
65
+ }, { timestamps: true });
66
+ exports.LibraryInfoModel = mongoose_1.default.model('LibraryInfo', LibraryInfoSchema);
67
+ const MONGO_USER = (_a = process.env.MONGO_USER) !== null && _a !== void 0 ? _a : 'root';
68
+ const MONGO_PASSWORD = (_b = process.env.MONGO_PASSWORD) !== null && _b !== void 0 ? _b : 'secret';
69
+ const DATABASE_NAME = 'depinder';
70
+ const MONGO_URI = (_c = process.env.MONGO_URI) !== null && _c !== void 0 ? _c : `mongodb://localhost:27018/${DATABASE_NAME}`;
71
+ exports.mongoCache = {
72
+ async get(key) {
73
+ return await exports.LibraryInfoModel.findById(key).exec();
74
+ },
75
+ async set(key, value) {
76
+ await exports.LibraryInfoModel.findByIdAndUpdate(key, value, { upsert: true }).exec();
77
+ },
78
+ async has(key) {
79
+ return (await exports.LibraryInfoModel.exists({ _id: key }) !== null);
80
+ },
81
+ async load() {
82
+ if (mongoose_1.default.connection.readyState === 0) {
83
+ await mongoose_1.default.connect(MONGO_URI, {
84
+ dbName: DATABASE_NAME,
85
+ user: MONGO_USER,
86
+ pass: MONGO_PASSWORD,
87
+ authSource: 'admin',
88
+ });
89
+ }
90
+ },
91
+ async write() {
92
+ if (mongoose_1.default.connection.readyState === 1) {
93
+ await mongoose_1.default.disconnect();
94
+ }
95
+ },
96
+ };
97
+ //# sourceMappingURL=mongo-cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mongo-cache.js","sourceRoot":"","sources":["../../src/cache/mongo-cache.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,8 @@
1
+ import { Command } from 'commander';
2
+ export interface AnalyseOptions {
3
+ plugins?: string[];
4
+ results: string;
5
+ refresh: boolean;
6
+ }
7
+ export declare const analyseCommand: Command;
8
+ export declare function analyseFiles(folders: string[], options: AnalyseOptions, useCache?: boolean): Promise<void>;