owasp-depscan 4.3.2__py3-none-any.whl → 4.3.3__py3-none-any.whl

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.

depscan/cli.py CHANGED
@@ -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__)
depscan/lib/github.py ADDED
@@ -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>"
@@ -1,11 +1,12 @@
1
1
  depscan/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- depscan/cli.py,sha256=Me9Ue01W7xUEFPUaYFuXY6xCR3Xw1aOWXlUVZDU_ui8,30524
2
+ depscan/cli.py,sha256=MNjREJU9fdQpNfbMZmJpvU5pRjRZE5qu0CFm7GRt3H0,31679
3
3
  depscan/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  depscan/lib/analysis.py,sha256=TIK0TuyxOng7VbDdweTndyouwMHDoTo-JjjzxOTiCxk,42085
5
5
  depscan/lib/audit.py,sha256=rUkrlioaACfKXb7rLhJoSH4F3btpWLQ6OoSFwV0H62w,1246
6
6
  depscan/lib/bom.py,sha256=_d_ITu2-aFGerqekIFlQiDhFxKdB5C83bFod7YFxldo,16247
7
7
  depscan/lib/config.py,sha256=9tyjo6uNdlJWyNNVfYD5tEt1wWexEyImMmuO8bK9Yns,12562
8
8
  depscan/lib/csaf.py,sha256=PkVXesHbZgc5b7PD0n05oqGkKdg7F_KECtuLnrJMGxo,85499
9
+ depscan/lib/github.py,sha256=N48YUA8U74CzvHsFn2gpa8qqvNdhxp5adjdGjA4NbKY,1728
9
10
  depscan/lib/license.py,sha256=y4-WZuD2MOunKaLd2EJGcSYP6s3Lp_dgssdzhcl9eEM,2332
10
11
  depscan/lib/logger.py,sha256=PdGrJstLmvwpMnlYx1zZ12jxz4kmbGm5kTSRs_8UcK4,1529
11
12
  depscan/lib/normalize.py,sha256=k8OlhSjzhGieqK1BLJNABRuz2wcwO4J8Ce8lYUsaxik,10008
@@ -62,9 +63,9 @@ vendor/choosealicense.com/_licenses/vim.txt,sha256=d5GQjXB328L8EBkhKgxcjk344D3K7
62
63
  vendor/choosealicense.com/_licenses/wtfpl.txt,sha256=BxXeubkvQm32MDmlZsBcbzJzBpR5kWgw0JxSR9d7f3k,948
63
64
  vendor/choosealicense.com/_licenses/zlib.txt,sha256=e6dfCeLhxD3NCnIkY4cVIagRaWdRvencjNhHZ1APvpc,1678
64
65
  vendor/spdx/json/licenses.json,sha256=PU1SD-zBi-U4r1XIWJ9qU-KixVWsQ5TJePUejC79yzU,251610
65
- owasp_depscan-4.3.2.dist-info/LICENSE,sha256=oQnCbnZtJ_NLDdOLc-rVY1D1N0RNWLHPpYXcc77xzSo,1073
66
- owasp_depscan-4.3.2.dist-info/METADATA,sha256=QyAwaLUFW0NHULO144RSSjn_cHt_fQRX9msF2S2jMKM,22703
67
- owasp_depscan-4.3.2.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
68
- owasp_depscan-4.3.2.dist-info/entry_points.txt,sha256=FxQKHFWZTfKU2eBxHPFRxwhSNexntYygYhquykS8zxA,69
69
- owasp_depscan-4.3.2.dist-info/top_level.txt,sha256=qbHOZvNU2dXANv946hMdP2vOi0ESQB5t2ZY5ktKtXvQ,15
70
- owasp_depscan-4.3.2.dist-info/RECORD,,
66
+ owasp_depscan-4.3.3.dist-info/LICENSE,sha256=oQnCbnZtJ_NLDdOLc-rVY1D1N0RNWLHPpYXcc77xzSo,1073
67
+ owasp_depscan-4.3.3.dist-info/METADATA,sha256=1nnv29ztpBKkoIzSrbDy_XKR3kEGPYqgDuIM_64P16w,23495
68
+ owasp_depscan-4.3.3.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
69
+ owasp_depscan-4.3.3.dist-info/entry_points.txt,sha256=FxQKHFWZTfKU2eBxHPFRxwhSNexntYygYhquykS8zxA,69
70
+ owasp_depscan-4.3.3.dist-info/top_level.txt,sha256=qbHOZvNU2dXANv946hMdP2vOi0ESQB5t2ZY5ktKtXvQ,15
71
+ owasp_depscan-4.3.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.2)
2
+ Generator: bdist_wheel (0.41.3)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5