owasp-depscan 4.3.2__tar.gz → 4.3.3__tar.gz

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.

Potentially problematic release.


This version of owasp-depscan might be problematic. Click here for more details.

Files changed (86) hide show
  1. {owasp-depscan-4.3.2/owasp_depscan.egg-info → owasp-depscan-4.3.3}/PKG-INFO +49 -19
  2. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/README.md +46 -18
  3. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/depscan/cli.py +22 -2
  4. owasp-depscan-4.3.3/depscan/lib/github.py +62 -0
  5. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3/owasp_depscan.egg-info}/PKG-INFO +49 -19
  6. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/owasp_depscan.egg-info/SOURCES.txt +2 -0
  7. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/owasp_depscan.egg-info/requires.txt +2 -0
  8. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/pyproject.toml +4 -2
  9. owasp-depscan-4.3.3/test/test_github.py +122 -0
  10. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/LICENSE +0 -0
  11. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/MANIFEST.in +0 -0
  12. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/depscan/__init__.py +0 -0
  13. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/depscan/lib/__init__.py +0 -0
  14. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/depscan/lib/analysis.py +0 -0
  15. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/depscan/lib/audit.py +0 -0
  16. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/depscan/lib/bom.py +0 -0
  17. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/depscan/lib/config.py +0 -0
  18. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/depscan/lib/csaf.py +0 -0
  19. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/depscan/lib/license.py +0 -0
  20. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/depscan/lib/logger.py +0 -0
  21. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/depscan/lib/normalize.py +0 -0
  22. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/depscan/lib/pkg_query.py +0 -0
  23. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/depscan/lib/privado.py +0 -0
  24. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/depscan/lib/utils.py +0 -0
  25. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/owasp_depscan.egg-info/dependency_links.txt +0 -0
  26. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/owasp_depscan.egg-info/entry_points.txt +0 -0
  27. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/owasp_depscan.egg-info/top_level.txt +0 -0
  28. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/setup.cfg +0 -0
  29. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/test/test_analysis.py +0 -0
  30. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/test/test_bom.py +0 -0
  31. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/test/test_csaf.py +0 -0
  32. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/test/test_license.py +0 -0
  33. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/test/test_norm.py +0 -0
  34. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/test/test_pkg_query.py +0 -0
  35. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/test/test_privado.py +0 -0
  36. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/test/test_utils.py +0 -0
  37. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/__init__.py +0 -0
  38. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_data/fields.yml +0 -0
  39. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_data/meta.yml +0 -0
  40. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_data/rules.yml +0 -0
  41. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/0bsd.txt +0 -0
  42. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/afl-3.0.txt +0 -0
  43. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/agpl-3.0.txt +0 -0
  44. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/apache-2.0.txt +0 -0
  45. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/artistic-2.0.txt +0 -0
  46. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/bsd-2-clause.txt +0 -0
  47. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/bsd-3-clause-clear.txt +0 -0
  48. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/bsd-3-clause.txt +0 -0
  49. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/bsd-4-clause.txt +0 -0
  50. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/bsl-1.0.txt +0 -0
  51. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/cc-by-4.0.txt +0 -0
  52. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/cc-by-sa-4.0.txt +0 -0
  53. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/cc0-1.0.txt +0 -0
  54. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/cecill-2.1.txt +0 -0
  55. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/cern-ohl-p-2.0.txt +0 -0
  56. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/cern-ohl-s-2.0.txt +0 -0
  57. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/cern-ohl-w-2.0.txt +0 -0
  58. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/ecl-2.0.txt +0 -0
  59. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/epl-1.0.txt +0 -0
  60. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/epl-2.0.txt +0 -0
  61. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/eupl-1.1.txt +0 -0
  62. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/eupl-1.2.txt +0 -0
  63. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/gfdl-1.3.txt +0 -0
  64. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/gpl-2.0.txt +0 -0
  65. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/gpl-3.0.txt +0 -0
  66. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/isc.txt +0 -0
  67. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/lgpl-2.1.txt +0 -0
  68. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/lgpl-3.0.txt +0 -0
  69. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/lppl-1.3c.txt +0 -0
  70. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/mit-0.txt +0 -0
  71. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/mit.txt +0 -0
  72. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/mpl-2.0.txt +0 -0
  73. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/ms-pl.txt +0 -0
  74. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/ms-rl.txt +0 -0
  75. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/mulanpsl-2.0.txt +0 -0
  76. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/ncsa.txt +0 -0
  77. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/odbl-1.0.txt +0 -0
  78. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/ofl-1.1.txt +0 -0
  79. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/osl-3.0.txt +0 -0
  80. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/postgresql.txt +0 -0
  81. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/unlicense.txt +0 -0
  82. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/upl-1.0.txt +0 -0
  83. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/vim.txt +0 -0
  84. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/wtfpl.txt +0 -0
  85. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/choosealicense.com/_licenses/zlib.txt +0 -0
  86. {owasp-depscan-4.3.2 → owasp-depscan-4.3.3}/vendor/spdx/json/licenses.json +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: owasp-depscan
3
- Version: 4.3.2
3
+ Version: 4.3.3
4
4
  Summary: Fully open-source security audit for project dependencies based on known vulnerabilities and advisories.
5
5
  Author-email: Team AppThreat <cloud@appthreat.com>
6
6
  License: MIT
@@ -26,12 +26,14 @@ Requires-Dist: oras
26
26
  Requires-Dist: PyYAML
27
27
  Requires-Dist: rich
28
28
  Requires-Dist: quart
29
+ Requires-Dist: PyGithub
29
30
  Requires-Dist: toml
30
31
  Provides-Extra: dev
31
32
  Requires-Dist: black; extra == "dev"
32
33
  Requires-Dist: flake8; extra == "dev"
33
34
  Requires-Dist: pytest; extra == "dev"
34
35
  Requires-Dist: pytest-cov; extra == "dev"
36
+ Requires-Dist: httpretty; extra == "dev"
35
37
 
36
38
  # Introduction
37
39
 
@@ -174,36 +176,60 @@ depscan --src $PWD --reports-dir $PWD/reports
174
176
  Full list of options are below:
175
177
 
176
178
  ```bash
177
- usage: depscan [-h] [--no-banner] [--cache] [--csaf] [--sync] [--suggest] [--risk-audit] [--private-ns PRIVATE_NS] [-t PROJECT_TYPE] [--bom BOM] [-i SRC_DIR_IMAGE] [-o REPORT_FILE] [--reports-dir REPORTS_DIR] [--no-error]
178
- [--no-license-scan] [--deep] [--no-universal] [--no-vuln-table] [--threatdb-server THREATDB_SERVER] [--threatdb-username THREATDB_USERNAME] [--threatdb-password THREATDB_PASSWORD] [--threatdb-token THREATDB_TOKEN]
179
- [--privado-json PRIVADO_JSON] [--server] [--server-host SERVER_HOST] [--server-port SERVER_PORT] [--cdxgen-server CDXGEN_SERVER] [-v]
180
-
181
- Fully open-source security and license audit for application dependencies and container images based on known vulnerabilities and advisories.
179
+ usage: cli.py [-h] [--no-banner] [--cache] [--csaf] [--sync] [--suggest]
180
+ [--no-suggest] [--risk-audit] [--private-ns PRIVATE_NS]
181
+ [-t PROJECT_TYPE] [--bom BOM] [-i SRC_DIR_IMAGE]
182
+ [-o REPORT_FILE] [--reports-dir REPORTS_DIR] [--no-error]
183
+ [--no-license-scan] [--deep] [--no-universal] [--no-vuln-table]
184
+ [--threatdb-server THREATDB_SERVER]
185
+ [--threatdb-username THREATDB_USERNAME]
186
+ [--threatdb-password THREATDB_PASSWORD]
187
+ [--threatdb-token THREATDB_TOKEN] [--privado-json PRIVADO_JSON]
188
+ [--server] [--server-host SERVER_HOST]
189
+ [--server-port SERVER_PORT] [--cdxgen-server CDXGEN_SERVER] [-v]
190
+
191
+ Fully open-source security and license audit for application dependencies and
192
+ container images based on known vulnerabilities and advisories.
182
193
 
183
194
  options:
184
195
  -h, --help show this help message and exit
185
196
  --no-banner Do not display banner
186
- --cache Cache vulnerability information in platform specific user_data_dir
197
+ --cache Cache vulnerability information in platform specific
198
+ user_data_dir
187
199
  --csaf Generate a CSAF
188
- --sync Sync to receive the latest vulnerability data. Should have invoked cache first.
189
- --suggest DEPRECATED: Suggest is the default mode for determining fix version.
200
+ --sync Sync to receive the latest vulnerability data. Should
201
+ have invoked cache first.
202
+ --suggest DEPRECATED: Suggest is the default mode for
203
+ determining fix version.
204
+ --no-suggest Disable suggest mode
190
205
  --risk-audit Perform package risk audit (slow operation). Npm only.
191
206
  --private-ns PRIVATE_NS
192
- Private namespace to use while performing oss risk audit. Private packages should not be available in public registries by default. Comma separated values accepted.
207
+ Private namespace to use while performing oss risk
208
+ audit. Private packages should not be available in
209
+ public registries by default. Comma separated values
210
+ accepted.
193
211
  -t PROJECT_TYPE, --type PROJECT_TYPE
194
212
  Override project type if auto-detection is incorrect
195
- --bom BOM Examine using the given Software Bill-of-Materials (SBoM) file in CycloneDX format. Use cdxgen command to produce one.
213
+ --bom BOM Examine using the given Software Bill-of-Materials
214
+ (SBoM) file in CycloneDX format. Use cdxgen command to
215
+ produce one.
196
216
  -i SRC_DIR_IMAGE, --src SRC_DIR_IMAGE
197
217
  Source directory or container image or binary file
198
218
  -o REPORT_FILE, --report_file REPORT_FILE
199
- DEPRECATED. Use reports directory since multiple files are created. Report filename with directory
219
+ DEPRECATED. Use reports directory since multiple files
220
+ are created. Report filename with directory
200
221
  --reports-dir REPORTS_DIR
201
222
  Reports directory
202
223
  --no-error Continue on error to prevent build from breaking
203
- --no-license-scan DEPRECATED: dep-scan does not perform license scanning by default
204
- --deep Perform deep scan by passing this --deep argument to cdxgen. Useful while scanning docker images and OS packages.
205
- --no-universal Depscan would attempt to perform a single universal scan instead of individual scans per language type.
206
- --no-vuln-table Do not print the table with the full list of vulnerabilities. This can help reduce console output.
224
+ --no-license-scan DEPRECATED: dep-scan does not perform license scanning
225
+ by default
226
+ --deep Perform deep scan by passing this --deep argument to
227
+ cdxgen. Useful while scanning docker images and OS
228
+ packages.
229
+ --no-universal Depscan would attempt to perform a single universal
230
+ scan instead of individual scans per language type.
231
+ --no-vuln-table Do not print the table with the full list of
232
+ vulnerabilities. This can help reduce console output.
207
233
  --threatdb-server THREATDB_SERVER
208
234
  ThreatDB server url. Eg: https://api.sbom.cx
209
235
  --threatdb-username THREATDB_USERNAME
@@ -213,7 +239,10 @@ options:
213
239
  --threatdb-token THREATDB_TOKEN
214
240
  ThreatDB token for token based submission
215
241
  --privado-json PRIVADO_JSON
216
- Optional: Enrich the VEX report with information from privado.ai json report. cdxgen can process and include privado info automatically so this argument is usually not required.
242
+ Optional: Enrich the VEX report with information from
243
+ privado.ai json report. cdxgen can process and include
244
+ privado info automatically so this argument is usually
245
+ not required.
217
246
  --server Run depscan as a server
218
247
  --server-host SERVER_HOST
219
248
  depscan server host
@@ -343,9 +372,10 @@ The following environment variables can be used to customise the behaviour.
343
372
 
344
373
  ## GitHub Security Advisory
345
374
 
346
- To download security advisories from GitHub, a personal access token with the following scope is necessary.
375
+ To download security advisories from GitHub, a personal access token with minimal permissions is necessary.
347
376
 
348
- - read:packages
377
+ - Fine-grained token: Grant no permissions and select the following for repository access: `Public Repositories (read-only)`
378
+ - Token (classic): Grant no permissions
349
379
 
350
380
  ```bash
351
381
  export GITHUB_TOKEN="<PAT token>"
@@ -139,36 +139,60 @@ depscan --src $PWD --reports-dir $PWD/reports
139
139
  Full list of options are below:
140
140
 
141
141
  ```bash
142
- usage: depscan [-h] [--no-banner] [--cache] [--csaf] [--sync] [--suggest] [--risk-audit] [--private-ns PRIVATE_NS] [-t PROJECT_TYPE] [--bom BOM] [-i SRC_DIR_IMAGE] [-o REPORT_FILE] [--reports-dir REPORTS_DIR] [--no-error]
143
- [--no-license-scan] [--deep] [--no-universal] [--no-vuln-table] [--threatdb-server THREATDB_SERVER] [--threatdb-username THREATDB_USERNAME] [--threatdb-password THREATDB_PASSWORD] [--threatdb-token THREATDB_TOKEN]
144
- [--privado-json PRIVADO_JSON] [--server] [--server-host SERVER_HOST] [--server-port SERVER_PORT] [--cdxgen-server CDXGEN_SERVER] [-v]
145
-
146
- Fully open-source security and license audit for application dependencies and container images based on known vulnerabilities and advisories.
142
+ usage: cli.py [-h] [--no-banner] [--cache] [--csaf] [--sync] [--suggest]
143
+ [--no-suggest] [--risk-audit] [--private-ns PRIVATE_NS]
144
+ [-t PROJECT_TYPE] [--bom BOM] [-i SRC_DIR_IMAGE]
145
+ [-o REPORT_FILE] [--reports-dir REPORTS_DIR] [--no-error]
146
+ [--no-license-scan] [--deep] [--no-universal] [--no-vuln-table]
147
+ [--threatdb-server THREATDB_SERVER]
148
+ [--threatdb-username THREATDB_USERNAME]
149
+ [--threatdb-password THREATDB_PASSWORD]
150
+ [--threatdb-token THREATDB_TOKEN] [--privado-json PRIVADO_JSON]
151
+ [--server] [--server-host SERVER_HOST]
152
+ [--server-port SERVER_PORT] [--cdxgen-server CDXGEN_SERVER] [-v]
153
+
154
+ Fully open-source security and license audit for application dependencies and
155
+ container images based on known vulnerabilities and advisories.
147
156
 
148
157
  options:
149
158
  -h, --help show this help message and exit
150
159
  --no-banner Do not display banner
151
- --cache Cache vulnerability information in platform specific user_data_dir
160
+ --cache Cache vulnerability information in platform specific
161
+ user_data_dir
152
162
  --csaf Generate a CSAF
153
- --sync Sync to receive the latest vulnerability data. Should have invoked cache first.
154
- --suggest DEPRECATED: Suggest is the default mode for determining fix version.
163
+ --sync Sync to receive the latest vulnerability data. Should
164
+ have invoked cache first.
165
+ --suggest DEPRECATED: Suggest is the default mode for
166
+ determining fix version.
167
+ --no-suggest Disable suggest mode
155
168
  --risk-audit Perform package risk audit (slow operation). Npm only.
156
169
  --private-ns PRIVATE_NS
157
- Private namespace to use while performing oss risk audit. Private packages should not be available in public registries by default. Comma separated values accepted.
170
+ Private namespace to use while performing oss risk
171
+ audit. Private packages should not be available in
172
+ public registries by default. Comma separated values
173
+ accepted.
158
174
  -t PROJECT_TYPE, --type PROJECT_TYPE
159
175
  Override project type if auto-detection is incorrect
160
- --bom BOM Examine using the given Software Bill-of-Materials (SBoM) file in CycloneDX format. Use cdxgen command to produce one.
176
+ --bom BOM Examine using the given Software Bill-of-Materials
177
+ (SBoM) file in CycloneDX format. Use cdxgen command to
178
+ produce one.
161
179
  -i SRC_DIR_IMAGE, --src SRC_DIR_IMAGE
162
180
  Source directory or container image or binary file
163
181
  -o REPORT_FILE, --report_file REPORT_FILE
164
- DEPRECATED. Use reports directory since multiple files are created. Report filename with directory
182
+ DEPRECATED. Use reports directory since multiple files
183
+ are created. Report filename with directory
165
184
  --reports-dir REPORTS_DIR
166
185
  Reports directory
167
186
  --no-error Continue on error to prevent build from breaking
168
- --no-license-scan DEPRECATED: dep-scan does not perform license scanning by default
169
- --deep Perform deep scan by passing this --deep argument to cdxgen. Useful while scanning docker images and OS packages.
170
- --no-universal Depscan would attempt to perform a single universal scan instead of individual scans per language type.
171
- --no-vuln-table Do not print the table with the full list of vulnerabilities. This can help reduce console output.
187
+ --no-license-scan DEPRECATED: dep-scan does not perform license scanning
188
+ by default
189
+ --deep Perform deep scan by passing this --deep argument to
190
+ cdxgen. Useful while scanning docker images and OS
191
+ packages.
192
+ --no-universal Depscan would attempt to perform a single universal
193
+ scan instead of individual scans per language type.
194
+ --no-vuln-table Do not print the table with the full list of
195
+ vulnerabilities. This can help reduce console output.
172
196
  --threatdb-server THREATDB_SERVER
173
197
  ThreatDB server url. Eg: https://api.sbom.cx
174
198
  --threatdb-username THREATDB_USERNAME
@@ -178,7 +202,10 @@ options:
178
202
  --threatdb-token THREATDB_TOKEN
179
203
  ThreatDB token for token based submission
180
204
  --privado-json PRIVADO_JSON
181
- Optional: Enrich the VEX report with information from privado.ai json report. cdxgen can process and include privado info automatically so this argument is usually not required.
205
+ Optional: Enrich the VEX report with information from
206
+ privado.ai json report. cdxgen can process and include
207
+ privado info automatically so this argument is usually
208
+ not required.
182
209
  --server Run depscan as a server
183
210
  --server-host SERVER_HOST
184
211
  depscan server host
@@ -308,9 +335,10 @@ The following environment variables can be used to customise the behaviour.
308
335
 
309
336
  ## GitHub Security Advisory
310
337
 
311
- To download security advisories from GitHub, a personal access token with the following scope is necessary.
338
+ To download security advisories from GitHub, a personal access token with minimal permissions is necessary.
312
339
 
313
- - read:packages
340
+ - Fine-grained token: Grant no permissions and select the following for repository access: `Public Repositories (read-only)`
341
+ - Token (classic): Grant no permissions
314
342
 
315
343
  ```bash
316
344
  export GITHUB_TOKEN="<PAT token>"
@@ -20,6 +20,7 @@ from vdb.lib.utils import parse_purl
20
20
 
21
21
  import oras.client
22
22
 
23
+ from depscan.lib import privado, utils, github
23
24
  from depscan.lib.csaf import export_csaf, write_toml
24
25
  from depscan.lib import privado, utils
25
26
  from depscan.lib.analysis import (
@@ -114,6 +115,12 @@ def build_args():
114
115
  help="DEPRECATED: Suggest is the default mode for determining fix "
115
116
  "version.",
116
117
  )
118
+ parser.add_argument(
119
+ "--no-suggest",
120
+ action="store_false",
121
+ dest="suggest",
122
+ help="Disable suggest mode",
123
+ )
117
124
  parser.add_argument(
118
125
  "--risk-audit",
119
126
  action="store_true",
@@ -791,8 +798,20 @@ def main():
791
798
  )
792
799
 
793
800
  sources_list = [OSVSource(), NvdSource()]
794
- if os.environ.get("GITHUB_TOKEN"):
795
- sources_list.insert(0, GitHubSource())
801
+ github_token = os.environ.get("GITHUB_TOKEN")
802
+ if github_token:
803
+ github_client = github.GitHub(github_token)
804
+
805
+ if not github_client.can_authenticate():
806
+ LOG.error("The GitHub personal access token supplied appears to be invalid or expired. Please see: https://github.com/owasp-dep-scan/dep-scan#github-security-advisory")
807
+ else:
808
+ sources_list.insert(0, GitHubSource())
809
+ scopes = github_client.get_token_scopes()
810
+ if not scopes is None and len(scopes) > 0:
811
+ LOG.warning(
812
+ "The GitHub personal access token was granted more permissions than is necessary for depscan to operate, including the scopes of: %s. It is recommended to use a dedicated token with only the minimum scope necesary for depscan to operate. Please see: https://github.com/owasp-dep-scan/dep-scan#github-security-advisory",
813
+ ', '.join([scope for scope in scopes])
814
+ )
796
815
  if run_cacher:
797
816
  LOG.debug(
798
817
  "About to download vdb from %s. This might take a while ...",
@@ -804,6 +823,7 @@ def main():
804
823
  )
805
824
  LOG.debug("VDB data is stored at: %s", paths_list)
806
825
  run_cacher = False
826
+ db = db_lib.get()
807
827
  elif args.sync:
808
828
  for s in sources_list:
809
829
  LOG.debug("Syncing %s", s.__class__.__name__)
@@ -0,0 +1,62 @@
1
+ from github import Github, Auth
2
+ from depscan.lib import config
3
+ import httpx
4
+
5
+
6
+ class GitHub:
7
+ # The GitHub instance object from the PyGithub library
8
+ github = None
9
+ github_token = None
10
+
11
+
12
+ def __init__(self, github_token: str) -> None:
13
+ self.github = Github(auth=Auth.Token(github_token))
14
+ self.github_token = github_token
15
+
16
+
17
+ def can_authenticate(self) -> bool:
18
+ """
19
+ Calls the GitHub API to determine if the token is valid
20
+
21
+ :return: Flag indicating whether authentication was successful or not
22
+ """
23
+ headers = {"Authorization": f"token {self.github_token}"}
24
+
25
+ response = httpx.get(
26
+ url='https://api.github.com/',
27
+ headers=headers,
28
+ follow_redirects=True,
29
+ timeout=config.request_timeout_sec
30
+ )
31
+
32
+ if response.status_code == 401:
33
+ return False
34
+ else:
35
+ return True
36
+
37
+
38
+ def get_token_scopes(self) -> list:
39
+ """
40
+ Provides the scopes associated to the access token provided in the environment variable
41
+ Only classic personal access tokens will result in scopes returned from the GitHub API
42
+
43
+ :return: List of token scopes
44
+ """
45
+ headers = {"Authorization": f"token {self.github_token}"}
46
+
47
+ response = httpx.get(
48
+ url='https://api.github.com/',
49
+ headers=headers,
50
+ follow_redirects=True,
51
+ timeout=config.request_timeout_sec
52
+ )
53
+
54
+ oauth_scopes = response.headers.get('x-oauth-scopes')
55
+
56
+ if not oauth_scopes is None:
57
+ if oauth_scopes == '':
58
+ return None
59
+ else:
60
+ return oauth_scopes.split(', ')
61
+
62
+ return None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: owasp-depscan
3
- Version: 4.3.2
3
+ Version: 4.3.3
4
4
  Summary: Fully open-source security audit for project dependencies based on known vulnerabilities and advisories.
5
5
  Author-email: Team AppThreat <cloud@appthreat.com>
6
6
  License: MIT
@@ -26,12 +26,14 @@ Requires-Dist: oras
26
26
  Requires-Dist: PyYAML
27
27
  Requires-Dist: rich
28
28
  Requires-Dist: quart
29
+ Requires-Dist: PyGithub
29
30
  Requires-Dist: toml
30
31
  Provides-Extra: dev
31
32
  Requires-Dist: black; extra == "dev"
32
33
  Requires-Dist: flake8; extra == "dev"
33
34
  Requires-Dist: pytest; extra == "dev"
34
35
  Requires-Dist: pytest-cov; extra == "dev"
36
+ Requires-Dist: httpretty; extra == "dev"
35
37
 
36
38
  # Introduction
37
39
 
@@ -174,36 +176,60 @@ depscan --src $PWD --reports-dir $PWD/reports
174
176
  Full list of options are below:
175
177
 
176
178
  ```bash
177
- usage: depscan [-h] [--no-banner] [--cache] [--csaf] [--sync] [--suggest] [--risk-audit] [--private-ns PRIVATE_NS] [-t PROJECT_TYPE] [--bom BOM] [-i SRC_DIR_IMAGE] [-o REPORT_FILE] [--reports-dir REPORTS_DIR] [--no-error]
178
- [--no-license-scan] [--deep] [--no-universal] [--no-vuln-table] [--threatdb-server THREATDB_SERVER] [--threatdb-username THREATDB_USERNAME] [--threatdb-password THREATDB_PASSWORD] [--threatdb-token THREATDB_TOKEN]
179
- [--privado-json PRIVADO_JSON] [--server] [--server-host SERVER_HOST] [--server-port SERVER_PORT] [--cdxgen-server CDXGEN_SERVER] [-v]
180
-
181
- Fully open-source security and license audit for application dependencies and container images based on known vulnerabilities and advisories.
179
+ usage: cli.py [-h] [--no-banner] [--cache] [--csaf] [--sync] [--suggest]
180
+ [--no-suggest] [--risk-audit] [--private-ns PRIVATE_NS]
181
+ [-t PROJECT_TYPE] [--bom BOM] [-i SRC_DIR_IMAGE]
182
+ [-o REPORT_FILE] [--reports-dir REPORTS_DIR] [--no-error]
183
+ [--no-license-scan] [--deep] [--no-universal] [--no-vuln-table]
184
+ [--threatdb-server THREATDB_SERVER]
185
+ [--threatdb-username THREATDB_USERNAME]
186
+ [--threatdb-password THREATDB_PASSWORD]
187
+ [--threatdb-token THREATDB_TOKEN] [--privado-json PRIVADO_JSON]
188
+ [--server] [--server-host SERVER_HOST]
189
+ [--server-port SERVER_PORT] [--cdxgen-server CDXGEN_SERVER] [-v]
190
+
191
+ Fully open-source security and license audit for application dependencies and
192
+ container images based on known vulnerabilities and advisories.
182
193
 
183
194
  options:
184
195
  -h, --help show this help message and exit
185
196
  --no-banner Do not display banner
186
- --cache Cache vulnerability information in platform specific user_data_dir
197
+ --cache Cache vulnerability information in platform specific
198
+ user_data_dir
187
199
  --csaf Generate a CSAF
188
- --sync Sync to receive the latest vulnerability data. Should have invoked cache first.
189
- --suggest DEPRECATED: Suggest is the default mode for determining fix version.
200
+ --sync Sync to receive the latest vulnerability data. Should
201
+ have invoked cache first.
202
+ --suggest DEPRECATED: Suggest is the default mode for
203
+ determining fix version.
204
+ --no-suggest Disable suggest mode
190
205
  --risk-audit Perform package risk audit (slow operation). Npm only.
191
206
  --private-ns PRIVATE_NS
192
- Private namespace to use while performing oss risk audit. Private packages should not be available in public registries by default. Comma separated values accepted.
207
+ Private namespace to use while performing oss risk
208
+ audit. Private packages should not be available in
209
+ public registries by default. Comma separated values
210
+ accepted.
193
211
  -t PROJECT_TYPE, --type PROJECT_TYPE
194
212
  Override project type if auto-detection is incorrect
195
- --bom BOM Examine using the given Software Bill-of-Materials (SBoM) file in CycloneDX format. Use cdxgen command to produce one.
213
+ --bom BOM Examine using the given Software Bill-of-Materials
214
+ (SBoM) file in CycloneDX format. Use cdxgen command to
215
+ produce one.
196
216
  -i SRC_DIR_IMAGE, --src SRC_DIR_IMAGE
197
217
  Source directory or container image or binary file
198
218
  -o REPORT_FILE, --report_file REPORT_FILE
199
- DEPRECATED. Use reports directory since multiple files are created. Report filename with directory
219
+ DEPRECATED. Use reports directory since multiple files
220
+ are created. Report filename with directory
200
221
  --reports-dir REPORTS_DIR
201
222
  Reports directory
202
223
  --no-error Continue on error to prevent build from breaking
203
- --no-license-scan DEPRECATED: dep-scan does not perform license scanning by default
204
- --deep Perform deep scan by passing this --deep argument to cdxgen. Useful while scanning docker images and OS packages.
205
- --no-universal Depscan would attempt to perform a single universal scan instead of individual scans per language type.
206
- --no-vuln-table Do not print the table with the full list of vulnerabilities. This can help reduce console output.
224
+ --no-license-scan DEPRECATED: dep-scan does not perform license scanning
225
+ by default
226
+ --deep Perform deep scan by passing this --deep argument to
227
+ cdxgen. Useful while scanning docker images and OS
228
+ packages.
229
+ --no-universal Depscan would attempt to perform a single universal
230
+ scan instead of individual scans per language type.
231
+ --no-vuln-table Do not print the table with the full list of
232
+ vulnerabilities. This can help reduce console output.
207
233
  --threatdb-server THREATDB_SERVER
208
234
  ThreatDB server url. Eg: https://api.sbom.cx
209
235
  --threatdb-username THREATDB_USERNAME
@@ -213,7 +239,10 @@ options:
213
239
  --threatdb-token THREATDB_TOKEN
214
240
  ThreatDB token for token based submission
215
241
  --privado-json PRIVADO_JSON
216
- Optional: Enrich the VEX report with information from privado.ai json report. cdxgen can process and include privado info automatically so this argument is usually not required.
242
+ Optional: Enrich the VEX report with information from
243
+ privado.ai json report. cdxgen can process and include
244
+ privado info automatically so this argument is usually
245
+ not required.
217
246
  --server Run depscan as a server
218
247
  --server-host SERVER_HOST
219
248
  depscan server host
@@ -343,9 +372,10 @@ The following environment variables can be used to customise the behaviour.
343
372
 
344
373
  ## GitHub Security Advisory
345
374
 
346
- To download security advisories from GitHub, a personal access token with the following scope is necessary.
375
+ To download security advisories from GitHub, a personal access token with minimal permissions is necessary.
347
376
 
348
- - read:packages
377
+ - Fine-grained token: Grant no permissions and select the following for repository access: `Public Repositories (read-only)`
378
+ - Token (classic): Grant no permissions
349
379
 
350
380
  ```bash
351
381
  export GITHUB_TOKEN="<PAT token>"
@@ -10,6 +10,7 @@ depscan/lib/audit.py
10
10
  depscan/lib/bom.py
11
11
  depscan/lib/config.py
12
12
  depscan/lib/csaf.py
13
+ depscan/lib/github.py
13
14
  depscan/lib/license.py
14
15
  depscan/lib/logger.py
15
16
  depscan/lib/normalize.py
@@ -25,6 +26,7 @@ owasp_depscan.egg-info/top_level.txt
25
26
  test/test_analysis.py
26
27
  test/test_bom.py
27
28
  test/test_csaf.py
29
+ test/test_github.py
28
30
  test/test_license.py
29
31
  test/test_norm.py
30
32
  test/test_pkg_query.py
@@ -4,6 +4,7 @@ oras
4
4
  PyYAML
5
5
  rich
6
6
  quart
7
+ PyGithub
7
8
  toml
8
9
 
9
10
  [dev]
@@ -11,3 +12,4 @@ black
11
12
  flake8
12
13
  pytest
13
14
  pytest-cov
15
+ httpretty
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "owasp-depscan"
3
- version = "4.3.2"
3
+ version = "4.3.3"
4
4
  description = "Fully open-source security audit for project dependencies based on known vulnerabilities and advisories."
5
5
  authors = [
6
6
  {name = "Team AppThreat", email = "cloud@appthreat.com"},
@@ -12,6 +12,7 @@ dependencies = [
12
12
  "PyYAML",
13
13
  "rich",
14
14
  "quart",
15
+ "PyGithub",
15
16
  "toml",
16
17
  ]
17
18
 
@@ -44,7 +45,8 @@ scan = "depscan.cli:main"
44
45
  dev = ["black",
45
46
  "flake8",
46
47
  "pytest",
47
- "pytest-cov"
48
+ "pytest-cov",
49
+ "httpretty"
48
50
  ]
49
51
 
50
52
  [build-system]
@@ -0,0 +1,122 @@
1
+ from depscan.lib import github
2
+ import httpretty
3
+
4
+
5
+ url = 'https://api.github.com/'
6
+
7
+
8
+ def test_can_authenticate_success():
9
+ httpretty.enable()
10
+ httpretty.reset()
11
+
12
+ headers = {
13
+ 'content-type': 'application/json',
14
+ 'X-OAuth-Scopes': 'admin:org, admin:repo_hook, repo, user',
15
+ 'X-Accepted-OAuth-Scopes': 'repo'
16
+ }
17
+
18
+ httpretty.register_uri(
19
+ method=httpretty.GET,
20
+ uri=url,
21
+ adding_headers=headers
22
+ )
23
+
24
+ github_client = github.GitHub('test-token')
25
+ result = github_client.can_authenticate()
26
+
27
+ httpretty.disable()
28
+
29
+ assert result == True
30
+
31
+
32
+ def test_can_authenticate_unauthentiated():
33
+ httpretty.enable()
34
+ httpretty.reset()
35
+
36
+ headers = {
37
+ 'content-type': 'application/json'
38
+ }
39
+
40
+ httpretty.register_uri(
41
+ method=httpretty.GET,
42
+ uri=url,
43
+ body='{"message":"Bad credentials"}',
44
+ adding_headers=headers,
45
+ status=401
46
+ )
47
+
48
+ github_client = github.GitHub('test-token')
49
+ result = github_client.can_authenticate()
50
+
51
+ httpretty.disable()
52
+
53
+ assert result == False
54
+
55
+
56
+ def test_get_token_scopes_success():
57
+ httpretty.enable()
58
+ httpretty.reset()
59
+
60
+ headers = {
61
+ 'content-type': 'application/json',
62
+ 'X-OAuth-Scopes': 'admin:org, admin:repo_hook, repo, user',
63
+ 'X-Accepted-OAuth-Scopes': 'repo'
64
+ }
65
+
66
+ httpretty.register_uri(
67
+ method=httpretty.GET,
68
+ uri=url,
69
+ adding_headers=headers
70
+ )
71
+
72
+ github_client = github.GitHub('test-token')
73
+ result = github_client.get_token_scopes()
74
+
75
+ httpretty.disable()
76
+
77
+ assert len(result) == 4 and result.index('admin:org') >= 0 and result.index('admin:repo_hook') >= 0 and result.index('repo') >= 0 and result.index('user') >= 0
78
+
79
+
80
+ def test_get_token_scopes_none():
81
+ httpretty.enable()
82
+ httpretty.reset()
83
+
84
+ headers = {
85
+ 'content-type': 'application/json',
86
+ }
87
+
88
+ httpretty.register_uri(
89
+ method=httpretty.GET,
90
+ uri=url,
91
+ adding_headers=headers
92
+ )
93
+
94
+ github_client = github.GitHub('test-token')
95
+ result = github_client.get_token_scopes()
96
+
97
+ httpretty.disable()
98
+
99
+ assert result is None
100
+
101
+
102
+ def test_get_token_scopes_empty():
103
+ httpretty.enable()
104
+ httpretty.reset()
105
+
106
+ headers = {
107
+ 'content-type': 'application/json',
108
+ 'x-oauth-scopes': ''
109
+ }
110
+
111
+ httpretty.register_uri(
112
+ method=httpretty.GET,
113
+ uri=url,
114
+ adding_headers=headers
115
+ )
116
+
117
+ github_client = github.GitHub('test-token')
118
+ result = github_client.get_token_scopes()
119
+
120
+ httpretty.disable()
121
+
122
+ assert result is None
File without changes
File without changes
File without changes