secure-cli 0.1.0__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.
@@ -0,0 +1,15 @@
1
+ Metadata-Version: 2.4
2
+ Name: secure-cli
3
+ Version: 0.1.0
4
+ Summary: secure: the Secure.com command line. Downloads the signed binary for your platform and verifies its checksum.
5
+ License: See LICENSE in securedotcom/secure-cli
6
+ Project-URL: Homepage, https://secure.com
7
+ Project-URL: Source, https://github.com/securedotcom/secure-cli
8
+ Requires-Python: >=3.9
9
+ Description-Content-Type: text/markdown
10
+
11
+ # secure-cli
12
+
13
+ `pip install secure-cli` then `secure --help`.
14
+
15
+ This package holds no code of its own beyond a launcher. On first run it downloads the `secure` binary for your platform from the matching GitHub Release of securedotcom/secure-cli into `~/.cache/secure-cli/`, checks it against the release's SHA256SUMS, and refuses on a mismatch. The same binary is behind Homebrew, npm and the install script.
@@ -0,0 +1,5 @@
1
+ # secure-cli
2
+
3
+ `pip install secure-cli` then `secure --help`.
4
+
5
+ This package holds no code of its own beyond a launcher. On first run it downloads the `secure` binary for your platform from the matching GitHub Release of securedotcom/secure-cli into `~/.cache/secure-cli/`, checks it against the release's SHA256SUMS, and refuses on a mismatch. The same binary is behind Homebrew, npm and the install script.
@@ -0,0 +1,18 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "secure-cli"
7
+ version = "0.1.0"
8
+ description = "secure: the Secure.com command line. Downloads the signed binary for your platform and verifies its checksum."
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = { text = "See LICENSE in securedotcom/secure-cli" }
12
+ urls = { Homepage = "https://secure.com", Source = "https://github.com/securedotcom/secure-cli" }
13
+
14
+ [project.scripts]
15
+ secure = "secure_cli:main"
16
+
17
+ [tool.setuptools]
18
+ packages = ["secure_cli"]
@@ -0,0 +1,78 @@
1
+ """secure-cli: a thin wrapper that fetches the signed `secure` binary on first run and execs it.
2
+
3
+ The binary comes from the GitHub Release matching this package's version. Its checksum is verified
4
+ against the release's SHA256SUMS before it is placed on disk. A mismatch deletes the download.
5
+ """
6
+ import hashlib
7
+ import os
8
+ import platform
9
+ import stat
10
+ import subprocess
11
+ import sys
12
+ import tarfile
13
+ import tempfile
14
+ import urllib.request
15
+ import zipfile
16
+ from importlib.metadata import version as _pkg_version
17
+
18
+ REPO = "securedotcom/homebrew-tap" # public repo that hosts the binaries; secure-cli builds and signs them
19
+
20
+
21
+ def _target():
22
+ system = {"Darwin": "darwin", "Linux": "linux", "Windows": "windows"}.get(platform.system())
23
+ machine = platform.machine().lower()
24
+ arch = "arm64" if machine in ("arm64", "aarch64") else "x64" if machine in ("x86_64", "amd64") else None
25
+ if not system or not arch:
26
+ sys.exit(f"secure: no binary for {platform.system()} {platform.machine()}")
27
+ return system, arch
28
+
29
+
30
+ def _cache_dir():
31
+ base = os.environ.get("XDG_CACHE_HOME") or os.path.join(os.path.expanduser("~"), ".cache")
32
+ return os.path.join(base, "secure-cli")
33
+
34
+
35
+ def _fetch(url):
36
+ req = urllib.request.Request(url, headers={"User-Agent": "secure-cli-pypi-wrapper"})
37
+ with urllib.request.urlopen(req, timeout=60) as r:
38
+ return r.read()
39
+
40
+
41
+ def ensure_binary():
42
+ ver = os.environ.get("SECURE_CLI_VERSION") or _pkg_version("secure-cli")
43
+ system, arch = _target()
44
+ exe = "secure.exe" if system == "windows" else "secure"
45
+ path = os.path.join(_cache_dir(), ver, exe)
46
+ if os.path.exists(path):
47
+ return path
48
+ asset = f"secure-{system}-{arch}.{'zip' if system == 'windows' else 'tar.gz'}"
49
+ base = f"https://github.com/{REPO}/releases/download/v{ver}/"
50
+ archive = _fetch(base + asset)
51
+ sums = _fetch(base + "SHA256SUMS").decode("utf-8")
52
+ expected = next((l.split()[0] for l in sums.splitlines() if l.strip().endswith(asset)), None)
53
+ if not expected:
54
+ sys.exit(f"secure: {asset} is not listed in SHA256SUMS; refusing to install")
55
+ actual = hashlib.sha256(archive).hexdigest()
56
+ if actual != expected:
57
+ sys.exit(f"secure: checksum mismatch for {asset}\n expected {expected}\n actual {actual}\nThe download was discarded.")
58
+ os.makedirs(os.path.dirname(path), exist_ok=True)
59
+ with tempfile.TemporaryDirectory() as tmp:
60
+ ap = os.path.join(tmp, asset)
61
+ with open(ap, "wb") as f:
62
+ f.write(archive)
63
+ if asset.endswith(".zip"):
64
+ with zipfile.ZipFile(ap) as z:
65
+ z.extract(exe, tmp)
66
+ else:
67
+ with tarfile.open(ap) as t:
68
+ t.extract(exe, tmp, filter="data")
69
+ os.replace(os.path.join(tmp, exe), path)
70
+ os.chmod(path, os.stat(path).st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
71
+ return path
72
+
73
+
74
+ def main():
75
+ path = ensure_binary()
76
+ if os.name == "nt":
77
+ sys.exit(subprocess.call([path] + sys.argv[1:]))
78
+ os.execv(path, [path] + sys.argv[1:])
@@ -0,0 +1,15 @@
1
+ Metadata-Version: 2.4
2
+ Name: secure-cli
3
+ Version: 0.1.0
4
+ Summary: secure: the Secure.com command line. Downloads the signed binary for your platform and verifies its checksum.
5
+ License: See LICENSE in securedotcom/secure-cli
6
+ Project-URL: Homepage, https://secure.com
7
+ Project-URL: Source, https://github.com/securedotcom/secure-cli
8
+ Requires-Python: >=3.9
9
+ Description-Content-Type: text/markdown
10
+
11
+ # secure-cli
12
+
13
+ `pip install secure-cli` then `secure --help`.
14
+
15
+ This package holds no code of its own beyond a launcher. On first run it downloads the `secure` binary for your platform from the matching GitHub Release of securedotcom/secure-cli into `~/.cache/secure-cli/`, checks it against the release's SHA256SUMS, and refuses on a mismatch. The same binary is behind Homebrew, npm and the install script.
@@ -0,0 +1,8 @@
1
+ README.md
2
+ pyproject.toml
3
+ secure_cli/__init__.py
4
+ secure_cli.egg-info/PKG-INFO
5
+ secure_cli.egg-info/SOURCES.txt
6
+ secure_cli.egg-info/dependency_links.txt
7
+ secure_cli.egg-info/entry_points.txt
8
+ secure_cli.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ secure = secure_cli:main
@@ -0,0 +1 @@
1
+ secure_cli
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+