cbomly 0.3.0__tar.gz → 0.3.1__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.
Files changed (49) hide show
  1. {cbomly-0.3.0/src/cbomly.egg-info → cbomly-0.3.1}/PKG-INFO +13 -15
  2. {cbomly-0.3.0 → cbomly-0.3.1}/README.md +12 -14
  3. {cbomly-0.3.0 → cbomly-0.3.1}/pyproject.toml +1 -1
  4. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly/__init__.py +1 -1
  5. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly/cli.py +6 -3
  6. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly/sbom.py +19 -4
  7. cbomly-0.3.1/src/cbomly/syft_fetch.py +119 -0
  8. {cbomly-0.3.0 → cbomly-0.3.1/src/cbomly.egg-info}/PKG-INFO +13 -15
  9. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly.egg-info/SOURCES.txt +1 -0
  10. {cbomly-0.3.0 → cbomly-0.3.1}/LICENSE +0 -0
  11. {cbomly-0.3.0 → cbomly-0.3.1}/NOTICE +0 -0
  12. {cbomly-0.3.0 → cbomly-0.3.1}/setup.cfg +0 -0
  13. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly/__main__.py +0 -0
  14. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly/algorithms.py +0 -0
  15. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly/cbom.py +0 -0
  16. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly/cbom_names.py +0 -0
  17. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly/detect/__init__.py +0 -0
  18. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly/detect/deps.py +0 -0
  19. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly/detect/keys.py +0 -0
  20. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly/detect/services.py +0 -0
  21. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly/detect/source.py +0 -0
  22. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly/findings.py +0 -0
  23. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly/importer.py +0 -0
  24. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly/inventory.py +0 -0
  25. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly/packs/au.toml +0 -0
  26. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly/packs/baseline.toml +0 -0
  27. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly/packs/ca.toml +0 -0
  28. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly/packs/eu.toml +0 -0
  29. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly/packs/india.toml +0 -0
  30. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly/packs/jp.toml +0 -0
  31. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly/packs/pci-dss.toml +0 -0
  32. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly/packs/sg.toml +0 -0
  33. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly/packs/uk.toml +0 -0
  34. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly/packs/us-cnsa2.toml +0 -0
  35. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly/packs/us-fda.toml +0 -0
  36. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly/packs/us.toml +0 -0
  37. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly/report.py +0 -0
  38. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly/rules.py +0 -0
  39. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly/scanner.py +0 -0
  40. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly/upload.py +0 -0
  41. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly.egg-info/dependency_links.txt +0 -0
  42. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly.egg-info/entry_points.txt +0 -0
  43. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly.egg-info/requires.txt +0 -0
  44. {cbomly-0.3.0 → cbomly-0.3.1}/src/cbomly.egg-info/top_level.txt +0 -0
  45. {cbomly-0.3.0 → cbomly-0.3.1}/tests/test_cli.py +0 -0
  46. {cbomly-0.3.0 → cbomly-0.3.1}/tests/test_keys.py +0 -0
  47. {cbomly-0.3.0 → cbomly-0.3.1}/tests/test_rules.py +0 -0
  48. {cbomly-0.3.0 → cbomly-0.3.1}/tests/test_source.py +0 -0
  49. {cbomly-0.3.0 → cbomly-0.3.1}/tests/test_upload.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cbomly
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: Find the cryptography in your software, write a CycloneDX CBOM, and check it is quantum-safe.
5
5
  Author-email: Cbomly <team@cbomly.com>
6
6
  License-Expression: Apache-2.0
@@ -77,25 +77,23 @@ CBOM and a migration plan:
77
77
 
78
78
  ## Install
79
79
 
80
- Cbomly needs Python 3.11 or newer. [Syft](https://github.com/anchore/syft) is optional but recommended:
81
- it builds the software list.
80
+ One command installs the scanner and [Syft](https://github.com/anchore/syft) (which builds the software list).
81
+ It needs no admin rights and fetches its own Python if yours is older than 3.11:
82
82
 
83
83
  ```bash
84
- # macOS
85
- brew install pipx syft
86
- pipx install cbomly
84
+ # macOS and Linux
85
+ curl -LsSf https://cbomly.com/install.sh | sh
87
86
 
88
- # Linux
89
- python3 -m pip install --user pipx
90
- pipx install cbomly
91
- curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b ~/.local/bin
87
+ # Windows (PowerShell or Command Prompt)
88
+ powershell -ExecutionPolicy ByPass -c "irm https://cbomly.com/install.ps1 | iex"
89
+ ```
92
90
 
93
- # Windows (PowerShell)
94
- py -m pip install --user pipx
95
- py -m pipx ensurepath
96
- pipx install cbomly
97
- winget install Anchore.syft # or: scoop install main/syft; then open a new terminal
91
+ Already have Python 3.11 or newer? `pipx install cbomly` works too. If Syft isn't installed, the first
92
+ `cbomly scan` downloads Anchore's official Syft release for your system, checks its SHA-256 against the
93
+ release's checksums, and keeps it in your user data folder (`~/.local/share/cbomly/bin` on Linux).
94
+ Set `CBOMLY_NO_SYFT=1` to never download it, or point `CBOMLY_SYFT` at your own copy.
98
95
 
96
+ ```bash
99
97
  cbomly doctor # checks everything is in place
100
98
  ```
101
99
 
@@ -51,25 +51,23 @@ CBOM and a migration plan:
51
51
 
52
52
  ## Install
53
53
 
54
- Cbomly needs Python 3.11 or newer. [Syft](https://github.com/anchore/syft) is optional but recommended:
55
- it builds the software list.
54
+ One command installs the scanner and [Syft](https://github.com/anchore/syft) (which builds the software list).
55
+ It needs no admin rights and fetches its own Python if yours is older than 3.11:
56
56
 
57
57
  ```bash
58
- # macOS
59
- brew install pipx syft
60
- pipx install cbomly
58
+ # macOS and Linux
59
+ curl -LsSf https://cbomly.com/install.sh | sh
61
60
 
62
- # Linux
63
- python3 -m pip install --user pipx
64
- pipx install cbomly
65
- curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b ~/.local/bin
61
+ # Windows (PowerShell or Command Prompt)
62
+ powershell -ExecutionPolicy ByPass -c "irm https://cbomly.com/install.ps1 | iex"
63
+ ```
66
64
 
67
- # Windows (PowerShell)
68
- py -m pip install --user pipx
69
- py -m pipx ensurepath
70
- pipx install cbomly
71
- winget install Anchore.syft # or: scoop install main/syft; then open a new terminal
65
+ Already have Python 3.11 or newer? `pipx install cbomly` works too. If Syft isn't installed, the first
66
+ `cbomly scan` downloads Anchore's official Syft release for your system, checks its SHA-256 against the
67
+ release's checksums, and keeps it in your user data folder (`~/.local/share/cbomly/bin` on Linux).
68
+ Set `CBOMLY_NO_SYFT=1` to never download it, or point `CBOMLY_SYFT` at your own copy.
72
69
 
70
+ ```bash
73
71
  cbomly doctor # checks everything is in place
74
72
  ```
75
73
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "cbomly"
7
- version = "0.3.0"
7
+ version = "0.3.1"
8
8
  description = "Find the cryptography in your software, write a CycloneDX CBOM, and check it is quantum-safe."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -1,3 +1,3 @@
1
1
  """Cbomly: find the cryptography in your software and check it is quantum-safe."""
2
2
 
3
- __version__ = "0.3.0"
3
+ __version__ = "0.3.1"
@@ -26,7 +26,7 @@ def _parser() -> argparse.ArgumentParser:
26
26
  s.add_argument("-o", "--out", default="cbomly-out", help="output folder (default: ./cbomly-out)")
27
27
  s.add_argument("--name", help="product name to put in the reports (default: folder name)")
28
28
  s.add_argument("--no-sbom", action="store_true", help="skip the Syft software list; crypto only")
29
- s.add_argument("--syft", help="path to the syft binary (default: from PATH or $CBOMLY_SYFT)")
29
+ s.add_argument("--syft", help="path to the syft binary (default: $CBOMLY_SYFT, PATH, or downloaded on first use)")
30
30
  s.add_argument("--exclude", action="append", default=[], help="extra file/folder name pattern to skip (repeatable)")
31
31
  s.add_argument("--include-vendored", action="store_true", help="also scan node_modules, vendor, venv and build folders")
32
32
  s.add_argument("--fail-on", choices=SEVERITIES[:-1], help="exit with code 1 if any issue is this severe or worse (for CI)")
@@ -83,7 +83,7 @@ def cmd_scan(a) -> int:
83
83
  sb = None
84
84
  tool_versions = {}
85
85
  if not a.no_sbom:
86
- syft = sbom.find_syft(a.syft)
86
+ syft = sbom.ensure_syft(a.syft, log)
87
87
  if not syft:
88
88
  log(sbom.INSTALL_HINT)
89
89
  notes.append("Syft was not installed, so no software list (SBOM) was produced.")
@@ -222,8 +222,11 @@ def cmd_doctor(_a) -> int:
222
222
  print(f"python {sys.version.split()[0]}")
223
223
  if syft:
224
224
  print(f"syft {sbom.syft_version(syft) or 'found'} ({syft})")
225
+ elif not sbom.syft_fetch.disabled():
226
+ print(f"syft not installed; `cbomly scan` downloads Syft {sbom.syft_fetch.SYFT_VERSION} on first use")
227
+ return 0
225
228
  else:
226
- print("syft NOT FOUND")
229
+ print("syft NOT FOUND (CBOMLY_NO_SYFT is set, so it won't be downloaded)")
227
230
  print(sbom.INSTALL_HINT)
228
231
  return 0 if syft else 1
229
232
 
@@ -13,9 +13,11 @@ import shutil
13
13
  import subprocess
14
14
  import sys
15
15
 
16
+ from . import syft_fetch
17
+
16
18
  if sys.platform == "win32":
17
19
  INSTALL_HINT = (
18
- "Syft is not installed, so the software list (SBOM) was skipped.\n"
20
+ "Syft is not available, so the software list (SBOM) was skipped. Install it with:\n"
19
21
  " Windows: winget install Anchore.syft\n"
20
22
  " or: scoop install main/syft\n"
21
23
  "Then open a new terminal (so PATH is refreshed) and run the scan again.\n"
@@ -23,7 +25,7 @@ if sys.platform == "win32":
23
25
  )
24
26
  else:
25
27
  INSTALL_HINT = (
26
- "Syft is not installed, so the software list (SBOM) was skipped.\n"
28
+ "Syft is not available, so the software list (SBOM) was skipped. Install it with:\n"
27
29
  " macOS: brew install syft\n"
28
30
  " Linux: curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b ~/.local/bin\n"
29
31
  "Then run the scan again. Use --no-sbom to silence this message."
@@ -50,9 +52,22 @@ def find_syft(explicit: str | None = None) -> str | None:
50
52
  if explicit:
51
53
  return explicit if os.path.exists(explicit) else shutil.which(explicit)
52
54
  found = os.environ.get("CBOMLY_SYFT") or shutil.which("syft")
53
- if found or sys.platform != "win32":
55
+ if found:
56
+ return found
57
+ extra = _windows_fallbacks() if sys.platform == "win32" else []
58
+ return next((p for p in [*extra, syft_fetch.cached_path()] if os.path.isfile(p)), None)
59
+
60
+
61
+ def ensure_syft(explicit: str | None = None, log=lambda *m: None) -> str | None:
62
+ """Find Syft, or download Anchore's release binary once (unless CBOMLY_NO_SYFT=1)."""
63
+ found = find_syft(explicit)
64
+ if found or explicit or syft_fetch.disabled():
54
65
  return found
55
- return next((p for p in _windows_fallbacks() if os.path.isfile(p)), None)
66
+ try:
67
+ return syft_fetch.fetch(log=log)
68
+ except syft_fetch.FetchError as e:
69
+ log(f" Could not download Syft: {e}")
70
+ return None
56
71
 
57
72
 
58
73
  # Syft prints UTF-8; without this, Windows decodes with the console code page and can crash.
@@ -0,0 +1,119 @@
1
+ """Download Anchore's official Syft release binary on first use.
2
+
3
+ Syft is a single Go binary. If it is not installed, `cbomly scan` fetches the pinned
4
+ release for this OS and CPU from GitHub, checks it against the release's published
5
+ SHA-256 checksums, and keeps it in a per-user folder. Set CBOMLY_NO_SYFT=1 to never
6
+ download (scans then skip the software list unless Syft is installed some other way).
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import hashlib
12
+ import io
13
+ import os
14
+ import platform
15
+ import stat
16
+ import sys
17
+ import tarfile
18
+ import tempfile
19
+ import time
20
+ import urllib.request
21
+ import zipfile
22
+
23
+ SYFT_VERSION = "1.42.3"
24
+ BASE_URL = "https://github.com/anchore/syft/releases/download"
25
+
26
+ _ARCH = {"x86_64": "amd64", "amd64": "amd64", "aarch64": "arm64", "arm64": "arm64",
27
+ "ppc64le": "ppc64le", "s390x": "s390x"}
28
+
29
+
30
+ class FetchError(RuntimeError):
31
+ pass
32
+
33
+
34
+ def bin_dir() -> str:
35
+ """Per-user folder for the downloaded binary (no admin rights needed)."""
36
+ home = os.path.expanduser("~")
37
+ if sys.platform == "win32":
38
+ base = os.environ.get("LOCALAPPDATA") or os.path.join(home, "AppData", "Local")
39
+ elif sys.platform == "darwin":
40
+ base = os.path.join(home, "Library", "Application Support")
41
+ else:
42
+ base = os.environ.get("XDG_DATA_HOME") or os.path.join(home, ".local", "share")
43
+ return os.path.join(base, "cbomly", "bin")
44
+
45
+
46
+ def cached_path(version: str = SYFT_VERSION) -> str:
47
+ exe = ".exe" if sys.platform == "win32" else ""
48
+ return os.path.join(bin_dir(), f"syft-{version}{exe}")
49
+
50
+
51
+ def disabled() -> bool:
52
+ return os.environ.get("CBOMLY_NO_SYFT", "").strip() not in ("", "0")
53
+
54
+
55
+ def _target() -> tuple[str, str, str]:
56
+ osname = {"linux": "linux", "darwin": "darwin", "win32": "windows"}.get(sys.platform)
57
+ arch = _ARCH.get(platform.machine().lower())
58
+ if not osname or not arch:
59
+ raise FetchError(f"no Syft download for {sys.platform}/{platform.machine()}")
60
+ return osname, arch, "zip" if osname == "windows" else "tar.gz"
61
+
62
+
63
+ def _get(url: str, timeout: int = 120, tries: int = 4) -> bytes:
64
+ """GET with retries: GitHub's release CDN sometimes answers with a short-lived error (e.g. 618 jwt:expired)."""
65
+ req = urllib.request.Request(url, headers={"User-Agent": "cbomly"})
66
+ for attempt in range(tries):
67
+ try:
68
+ with urllib.request.urlopen(req, timeout=timeout) as r:
69
+ return r.read()
70
+ except OSError as e:
71
+ if attempt == tries - 1 or getattr(e, "code", 500) in (403, 404):
72
+ raise FetchError(f"could not download {url}: {e}") from e
73
+ time.sleep(2 * (attempt + 1))
74
+ raise AssertionError("unreachable")
75
+
76
+
77
+ def fetch(version: str = SYFT_VERSION, log=lambda *m: None) -> str:
78
+ """Download, verify and unpack Syft; return the path of the binary."""
79
+ osname, arch, fmt = _target()
80
+ base = os.environ.get("CBOMLY_SYFT_BASE_URL", BASE_URL).rstrip("/")
81
+ asset = f"syft_{version}_{osname}_{arch}.{fmt}"
82
+ log(f"Downloading Syft {version} ({osname}/{arch}) from Anchore's GitHub releases…")
83
+ sums = _get(f"{base}/v{version}/syft_{version}_checksums.txt").decode("utf-8", "replace")
84
+ want = next((ln.split()[0].lower() for ln in sums.splitlines() if ln.strip().endswith(asset)), None)
85
+ if not want:
86
+ raise FetchError(f"{asset} is not listed in the release checksums")
87
+ blob = _get(f"{base}/v{version}/{asset}")
88
+ got = hashlib.sha256(blob).hexdigest()
89
+ if got != want:
90
+ raise FetchError(f"checksum mismatch for {asset} (expected {want}, got {got})")
91
+
92
+ member = "syft.exe" if osname == "windows" else "syft"
93
+ try:
94
+ if fmt == "zip":
95
+ with zipfile.ZipFile(io.BytesIO(blob)) as z:
96
+ data = z.read(member)
97
+ else:
98
+ with tarfile.open(fileobj=io.BytesIO(blob), mode="r:gz") as t:
99
+ f = t.extractfile(member)
100
+ if f is None:
101
+ raise KeyError(member)
102
+ data = f.read()
103
+ except (KeyError, zipfile.BadZipFile, tarfile.TarError) as e:
104
+ raise FetchError(f"{asset} does not contain {member}") from e
105
+
106
+ dest = cached_path(version)
107
+ os.makedirs(os.path.dirname(dest), exist_ok=True)
108
+ fd, tmp = tempfile.mkstemp(dir=os.path.dirname(dest), prefix=".syft-")
109
+ try:
110
+ with os.fdopen(fd, "wb") as fh:
111
+ fh.write(data)
112
+ os.chmod(tmp, os.stat(tmp).st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
113
+ os.replace(tmp, dest)
114
+ except OSError as e:
115
+ if os.path.exists(tmp):
116
+ os.unlink(tmp)
117
+ raise FetchError(f"could not save Syft to {dest}: {e}") from e
118
+ log(f" Saved to {dest} (checksum verified)")
119
+ return dest
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cbomly
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: Find the cryptography in your software, write a CycloneDX CBOM, and check it is quantum-safe.
5
5
  Author-email: Cbomly <team@cbomly.com>
6
6
  License-Expression: Apache-2.0
@@ -77,25 +77,23 @@ CBOM and a migration plan:
77
77
 
78
78
  ## Install
79
79
 
80
- Cbomly needs Python 3.11 or newer. [Syft](https://github.com/anchore/syft) is optional but recommended:
81
- it builds the software list.
80
+ One command installs the scanner and [Syft](https://github.com/anchore/syft) (which builds the software list).
81
+ It needs no admin rights and fetches its own Python if yours is older than 3.11:
82
82
 
83
83
  ```bash
84
- # macOS
85
- brew install pipx syft
86
- pipx install cbomly
84
+ # macOS and Linux
85
+ curl -LsSf https://cbomly.com/install.sh | sh
87
86
 
88
- # Linux
89
- python3 -m pip install --user pipx
90
- pipx install cbomly
91
- curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b ~/.local/bin
87
+ # Windows (PowerShell or Command Prompt)
88
+ powershell -ExecutionPolicy ByPass -c "irm https://cbomly.com/install.ps1 | iex"
89
+ ```
92
90
 
93
- # Windows (PowerShell)
94
- py -m pip install --user pipx
95
- py -m pipx ensurepath
96
- pipx install cbomly
97
- winget install Anchore.syft # or: scoop install main/syft; then open a new terminal
91
+ Already have Python 3.11 or newer? `pipx install cbomly` works too. If Syft isn't installed, the first
92
+ `cbomly scan` downloads Anchore's official Syft release for your system, checks its SHA-256 against the
93
+ release's checksums, and keeps it in your user data folder (`~/.local/share/cbomly/bin` on Linux).
94
+ Set `CBOMLY_NO_SYFT=1` to never download it, or point `CBOMLY_SYFT` at your own copy.
98
95
 
96
+ ```bash
99
97
  cbomly doctor # checks everything is in place
100
98
  ```
101
99
 
@@ -15,6 +15,7 @@ src/cbomly/report.py
15
15
  src/cbomly/rules.py
16
16
  src/cbomly/sbom.py
17
17
  src/cbomly/scanner.py
18
+ src/cbomly/syft_fetch.py
18
19
  src/cbomly/upload.py
19
20
  src/cbomly.egg-info/PKG-INFO
20
21
  src/cbomly.egg-info/SOURCES.txt
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes