ethiack-beacon 2.2.2__tar.gz → 2.3.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.
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/PKG-INFO +1 -1
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/README.md +21 -10
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/cli/api.py +6 -6
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/cli/config.py +9 -7
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/ethiack_beacon.egg-info/PKG-INFO +1 -1
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/ethiack_beacon.egg-info/SOURCES.txt +1 -0
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/pyproject.toml +1 -1
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/tests/test_api.py +2 -2
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/tests/test_config.py +10 -0
- ethiack_beacon-2.3.0/tests/test_install_sh.py +45 -0
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/tests/test_main.py +3 -2
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/cli/__init__.py +0 -0
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/cli/console.py +0 -0
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/cli/dns.py +0 -0
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/cli/exceptions.py +0 -0
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/cli/main.py +0 -0
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/cli/rathole.py +0 -0
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/cli/system.py +0 -0
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/cli/wireguard.py +0 -0
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/ethiack_beacon.egg-info/dependency_links.txt +0 -0
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/ethiack_beacon.egg-info/entry_points.txt +0 -0
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/ethiack_beacon.egg-info/requires.txt +0 -0
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/ethiack_beacon.egg-info/top_level.txt +0 -0
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/setup.cfg +0 -0
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/tests/test_api_extra.py +0 -0
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/tests/test_console_extra.py +0 -0
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/tests/test_dns.py +0 -0
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/tests/test_main_create_start.py +0 -0
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/tests/test_main_health_misc.py +0 -0
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/tests/test_rathole.py +0 -0
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/tests/test_rathole_extra.py +0 -0
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/tests/test_system.py +0 -0
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/tests/test_system_extra.py +0 -0
- {ethiack_beacon-2.2.2 → ethiack_beacon-2.3.0}/tests/test_wireguard.py +0 -0
|
@@ -42,16 +42,27 @@ Or pre-seed your credentials for a fully automated install (e.g. from the Ethiac
|
|
|
42
42
|
|
|
43
43
|
```bash
|
|
44
44
|
curl -fsSL https://raw.githubusercontent.com/ethiack/beacon/main/install.sh \
|
|
45
|
-
| ETHIACK_API_KEY=
|
|
45
|
+
| ETHIACK_API_KEY=your-key sudo -E bash
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
Legacy (
|
|
48
|
+
Legacy keys (not starting with `phx_` or `ethiack_`) additionally need `ETHIACK_API_SECRET=your-secret`.
|
|
49
49
|
|
|
50
50
|
The script will:
|
|
51
51
|
1. Detect Docker - if available, recommend the Docker Compose path (simpler, fewer support issues)
|
|
52
52
|
2. Otherwise install WireGuard + the beacon CLI natively, then set up a systemd/launchd service
|
|
53
53
|
3. Interactively collect beacon name, CIDRs, and optionally a pentest slug to automatically scope the beacon's networks
|
|
54
54
|
|
|
55
|
+
### Updating
|
|
56
|
+
|
|
57
|
+
Run the update script on the same machine - it detects how the beacon was installed:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
curl -fsSL https://portal.ethiack.com/scripts/beacon/update | sudo bash
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
- **Docker** - pulls the latest image and recreates the container. The install directory is found from the running container; set `BEACON_INSTALL_DIR` (with `sudo -E`) if it can't be.
|
|
64
|
+
- **Native** - upgrades the beacon CLI and restarts the systemd/launchd service.
|
|
65
|
+
|
|
55
66
|
<p align="right"><small>(<a href="#readme-top">back to top</a>)</small></p>
|
|
56
67
|
|
|
57
68
|
## Prerequisites
|
|
@@ -100,8 +111,8 @@ cp .env.example .env
|
|
|
100
111
|
Key variables:
|
|
101
112
|
|
|
102
113
|
```bash
|
|
103
|
-
ETHIACK_API_KEY=
|
|
104
|
-
# Legacy (
|
|
114
|
+
ETHIACK_API_KEY=your-key
|
|
115
|
+
# Legacy keys (not starting with phx_ or ethiack_) only:
|
|
105
116
|
# ETHIACK_API_SECRET=your-secret
|
|
106
117
|
```
|
|
107
118
|
|
|
@@ -139,8 +150,8 @@ sudo -E beacon stop <id>
|
|
|
139
150
|
All parameters can be passed via environment variables for use in Kubernetes, Helm, or Ansible:
|
|
140
151
|
|
|
141
152
|
```bash
|
|
142
|
-
export ETHIACK_API_KEY=
|
|
143
|
-
# Legacy (
|
|
153
|
+
export ETHIACK_API_KEY=your-key
|
|
154
|
+
# Legacy keys (not starting with phx_ or ethiack_) only: export ETHIACK_API_SECRET=your-secret
|
|
144
155
|
export ETHIACK_BEACON_NAME=prod-cluster
|
|
145
156
|
export ETHIACK_BEACON_CIDRS=10.0.0.0/8,172.16.0.0/12
|
|
146
157
|
export ETHIACK_PENTEST_SLUG=my-pentest # optional: auto-scope CIDRs to this pentest
|
|
@@ -168,8 +179,8 @@ sudo -E beacon create --yes
|
|
|
168
179
|
|
|
169
180
|
| Variable | Required | Default | Description |
|
|
170
181
|
|---|---|---|---|
|
|
171
|
-
| `ETHIACK_API_KEY` | Yes | - | API key. A `phx_
|
|
172
|
-
| `ETHIACK_API_SECRET` | Legacy only | - | API secret - required only for legacy (
|
|
182
|
+
| `ETHIACK_API_KEY` | Yes | - | API key. A key starting with `phx_` or `ethiack_` authenticates as `Authorization: Bearer` and needs no secret; anything else is a legacy key sent as HTTP Basic together with `ETHIACK_API_SECRET` |
|
|
183
|
+
| `ETHIACK_API_SECRET` | Legacy only | - | API secret - required only for legacy keys (not starting with `phx_` or `ethiack_`). Do not set it alongside a `phx_` or `ethiack_` key |
|
|
173
184
|
| `ETHIACK_API_URL` | No | `https://api.ethiack.com` | API base URL |
|
|
174
185
|
| `ETHIACK_ORG_ID` | No | auto | Organization ID (auto-selected if your key has access to only one org) |
|
|
175
186
|
| `ETHIACK_BEACON_ID` | No | - | Beacon ID to start (Docker mode) |
|
|
@@ -254,7 +265,7 @@ docker compose logs -f
|
|
|
254
265
|
|
|
255
266
|
```bash
|
|
256
267
|
# beacon.env
|
|
257
|
-
ETHIACK_API_KEY=
|
|
268
|
+
ETHIACK_API_KEY=your-key
|
|
258
269
|
ETHIACK_BEACON_ID=<beacon-id>
|
|
259
270
|
```
|
|
260
271
|
|
|
@@ -264,7 +275,7 @@ Create the beacon once with the CLI, then deploy the container with its ID. On e
|
|
|
264
275
|
|
|
265
276
|
```bash
|
|
266
277
|
# beacon.env
|
|
267
|
-
ETHIACK_API_KEY=
|
|
278
|
+
ETHIACK_API_KEY=your-key
|
|
268
279
|
ETHIACK_BEACON_NAME=my-beacon
|
|
269
280
|
ETHIACK_BEACON_CIDRS=192.168.1.0/24,10.0.0.0/8
|
|
270
281
|
# ETHIACK_PENTEST_SLUG=my-pentest # optional: auto-scope CIDRs to this pentest
|
|
@@ -7,7 +7,7 @@ from typing import Any
|
|
|
7
7
|
import httpx
|
|
8
8
|
|
|
9
9
|
from . import __version__
|
|
10
|
-
from .config import
|
|
10
|
+
from .config import Settings
|
|
11
11
|
from .console import warning
|
|
12
12
|
from .exceptions import BeaconAPIError, BeaconAuthError, BeaconNotFoundError
|
|
13
13
|
|
|
@@ -257,14 +257,14 @@ class BeaconAPI:
|
|
|
257
257
|
except httpx.TimeoutException as exc:
|
|
258
258
|
raise BeaconAPIError(f"Request timed out: {exc}") from exc
|
|
259
259
|
|
|
260
|
-
# Only a key:secret request can be legacy auth.
|
|
261
|
-
# Deprecation header from deprecated routes (the /v1/events alias of
|
|
260
|
+
# Only a key:secret request can be legacy auth. Bearer requests also get
|
|
261
|
+
# a Deprecation header from deprecated routes (the /v1/events alias of
|
|
262
262
|
# /v1/pentests), which says nothing about the key.
|
|
263
263
|
if not self._settings.uses_bearer_auth:
|
|
264
264
|
_warn_if_legacy_auth(resp)
|
|
265
265
|
|
|
266
266
|
if resp.status_code in (401, 403):
|
|
267
|
-
#
|
|
267
|
+
# Bearer keys have no secret, so the hint must not name one.
|
|
268
268
|
hint = (
|
|
269
269
|
"check ETHIACK_API_KEY"
|
|
270
270
|
if self._settings.uses_bearer_auth
|
|
@@ -300,7 +300,7 @@ def _warn_if_legacy_auth(resp: httpx.Response) -> None:
|
|
|
300
300
|
Only for key:secret requests: on those, the API sets these on a successful
|
|
301
301
|
legacy resolution, so their presence is the authoritative signal that this
|
|
302
302
|
credential is legacy. Deprecated routes send Deprecation whatever the
|
|
303
|
-
credential, so on a
|
|
303
|
+
credential, so on a bearer request the header says nothing about the key.
|
|
304
304
|
Advisory only - never fails, never self-disables on the sunset date.
|
|
305
305
|
"""
|
|
306
306
|
global _DEPRECATION_WARNED
|
|
@@ -313,7 +313,7 @@ def _warn_if_legacy_auth(resp: httpx.Response) -> None:
|
|
|
313
313
|
tail = f" It may stop working after {sunset}." if sunset else ""
|
|
314
314
|
warning(
|
|
315
315
|
"This API key uses the deprecated legacy authentication scheme."
|
|
316
|
-
f"{tail} Generate a new
|
|
316
|
+
f"{tail} Generate a new API key in the Ethiack Portal."
|
|
317
317
|
)
|
|
318
318
|
|
|
319
319
|
|
|
@@ -21,10 +21,12 @@ DNS_DIR = STATE_DIR / "dns"
|
|
|
21
21
|
DEFAULT_API_URL = "https://api.ethiack.com"
|
|
22
22
|
DEFAULT_DNS_SERVER = "10.252.0.1"
|
|
23
23
|
|
|
24
|
-
# Modern API keys
|
|
25
|
-
# <key>" with no secret.
|
|
26
|
-
#
|
|
27
|
-
|
|
24
|
+
# Modern API keys start with phx_ or ethiack_ and authenticate as
|
|
25
|
+
# "Authorization: Bearer <key>" with no secret. The API reserves the ethiack_
|
|
26
|
+
# namespace for its own tokens; ethiack_key_ is the next key format. Anything
|
|
27
|
+
# else is a legacy key:secret pair sent as HTTP Basic. The API rejects a
|
|
28
|
+
# request carrying both, so exactly one is ever sent.
|
|
29
|
+
BEARER_KEY_PREFIXES = ("phx_", "ethiack_")
|
|
28
30
|
|
|
29
31
|
# API settings (read from env vars)
|
|
30
32
|
|
|
@@ -32,14 +34,14 @@ PHX_KEY_PREFIX = "phx_"
|
|
|
32
34
|
class Settings:
|
|
33
35
|
api_url: str = DEFAULT_API_URL
|
|
34
36
|
api_key: str = ""
|
|
35
|
-
# Legacy key:secret pairs only. Ignored for
|
|
37
|
+
# Legacy key:secret pairs only. Ignored for modern keys.
|
|
36
38
|
api_secret: str = ""
|
|
37
39
|
org_id: str = ""
|
|
38
40
|
|
|
39
41
|
@property
|
|
40
42
|
def uses_bearer_auth(self) -> bool:
|
|
41
43
|
"""True when api_key is a modern key (Bearer token, no secret)."""
|
|
42
|
-
return self.api_key.startswith(
|
|
44
|
+
return self.api_key.startswith(BEARER_KEY_PREFIXES)
|
|
43
45
|
|
|
44
46
|
@classmethod
|
|
45
47
|
def from_env(cls) -> "Settings":
|
|
@@ -62,7 +64,7 @@ class Settings:
|
|
|
62
64
|
if not self.uses_bearer_auth and not self.api_secret:
|
|
63
65
|
raise BeaconConfigError(
|
|
64
66
|
"Missing required environment variables: ETHIACK_API_SECRET "
|
|
65
|
-
|
|
67
|
+
"(required for legacy API keys; phx_ and ethiack_ keys "
|
|
66
68
|
"authenticate with the key alone)"
|
|
67
69
|
)
|
|
68
70
|
|
|
@@ -517,7 +517,7 @@ class TestAuthScheme:
|
|
|
517
517
|
)
|
|
518
518
|
with BeaconAPI(phx_settings) as api:
|
|
519
519
|
api.get_organizations()
|
|
520
|
-
assert httpx_mock.get_request().headers["authorization"] == "Bearer
|
|
520
|
+
assert httpx_mock.get_request().headers["authorization"] == f"Bearer {phx_settings.api_key}"
|
|
521
521
|
|
|
522
522
|
def test_phx_key_with_stale_secret_still_sends_bearer(self, httpx_mock: HTTPXMock):
|
|
523
523
|
"""The scheme comes from the key prefix, NOT from "is a secret present".
|
|
@@ -572,7 +572,7 @@ class TestAuthScheme:
|
|
|
572
572
|
with BeaconAPI(phx_settings) as api:
|
|
573
573
|
api.health(beacon_id="b", status="active", beacon_token="tok")
|
|
574
574
|
request = httpx_mock.get_request()
|
|
575
|
-
assert request.headers.get_list("authorization") == ["Bearer
|
|
575
|
+
assert request.headers.get_list("authorization") == [f"Bearer {phx_settings.api_key}"]
|
|
576
576
|
assert request.headers["X-Beacon-Token"] == "tok"
|
|
577
577
|
|
|
578
578
|
def test_phx_auth_error_message_omits_secret(self, phx_settings, httpx_mock: HTTPXMock):
|
|
@@ -73,6 +73,16 @@ class TestSettings:
|
|
|
73
73
|
assert Settings(api_key="abc", api_secret="s").uses_bearer_auth is False
|
|
74
74
|
assert Settings().uses_bearer_auth is False
|
|
75
75
|
|
|
76
|
+
def test_ethiack_keys_use_bearer_auth(self):
|
|
77
|
+
assert Settings(api_key="ethiack_key_abc").uses_bearer_auth is True
|
|
78
|
+
# The whole ethiack_ namespace, so a new Ethiack token type needs no release.
|
|
79
|
+
assert Settings(api_key="ethiack_oauth_at_abc").uses_bearer_auth is True
|
|
80
|
+
# Only the namespace with its underscore: anything else is a legacy pair.
|
|
81
|
+
assert Settings(api_key="ethiackabc", api_secret="s").uses_bearer_auth is False
|
|
82
|
+
|
|
83
|
+
def test_validate_passes_when_ethiack_key_without_secret(self):
|
|
84
|
+
Settings(api_key="ethiack_key_abc123").validate() # should not raise
|
|
85
|
+
|
|
76
86
|
def test_from_env_strips_whitespace(self, monkeypatch):
|
|
77
87
|
monkeypatch.setenv("ETHIACK_API_KEY", "phx_abc123\n")
|
|
78
88
|
monkeypatch.setenv("ETHIACK_API_SECRET", " s ")
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""install.sh's key-prefix branch, run in isolation.
|
|
2
|
+
|
|
3
|
+
The installer can't be sourced (it ends in an unconditional `main "$@"`), so the
|
|
4
|
+
real `case` block is cut out of the file and run with the prompts stubbed. It is
|
|
5
|
+
checked against BEARER_KEY_PREFIXES, so the shell and the CLI can't drift apart.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import re
|
|
9
|
+
import subprocess
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
import pytest
|
|
13
|
+
|
|
14
|
+
from cli.config import BEARER_KEY_PREFIXES
|
|
15
|
+
|
|
16
|
+
INSTALL_SH = Path(__file__).resolve().parent.parent / "install.sh"
|
|
17
|
+
_KEY_CASE = re.compile(r'^\s*case "\$\{ETHIACK_API_KEY\}" in$.*?^\s*esac$', re.M | re.S)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _run_key_case(api_key: str) -> str:
|
|
21
|
+
"""Run collect_config's key-prefix case block with the prompts stubbed out."""
|
|
22
|
+
match = _KEY_CASE.search(INSTALL_SH.read_text())
|
|
23
|
+
assert match, "install.sh no longer has the ETHIACK_API_KEY case block"
|
|
24
|
+
script = (
|
|
25
|
+
"info() { :; }\n"
|
|
26
|
+
"prompt_required() { echo PROMPTED; }\n"
|
|
27
|
+
f"{match.group(0)}\n"
|
|
28
|
+
'echo "secret=${ETHIACK_API_SECRET-unset}"\n'
|
|
29
|
+
)
|
|
30
|
+
env = {"PATH": "/usr/bin:/bin", "ETHIACK_API_KEY": api_key, "ETHIACK_API_SECRET": "stale"}
|
|
31
|
+
return subprocess.run(
|
|
32
|
+
["bash", "-c", script], env=env, capture_output=True, text=True, check=True
|
|
33
|
+
).stdout
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@pytest.mark.parametrize("prefix", BEARER_KEY_PREFIXES)
|
|
37
|
+
def test_bearer_key_skips_secret_prompt_and_drops_stale_secret(prefix):
|
|
38
|
+
out = _run_key_case(f"{prefix}abc")
|
|
39
|
+
assert "PROMPTED" not in out
|
|
40
|
+
assert "secret=unset" in out
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@pytest.mark.parametrize("api_key", ["legacy-key", "ethiackabc"])
|
|
44
|
+
def test_legacy_key_prompts_for_secret(api_key):
|
|
45
|
+
assert "PROMPTED" in _run_key_case(api_key)
|
|
@@ -298,8 +298,9 @@ class TestMissingCredentials:
|
|
|
298
298
|
assert result.exit_code == 0
|
|
299
299
|
mock_api.list.assert_called_once()
|
|
300
300
|
|
|
301
|
-
|
|
302
|
-
|
|
301
|
+
@pytest.mark.parametrize("api_key", ["phx_test-key", "ethiack_key_test"])
|
|
302
|
+
def test_warns_when_phx_key_has_stale_secret(self, state_dir, monkeypatch, api_key):
|
|
303
|
+
monkeypatch.setenv("ETHIACK_API_KEY", api_key)
|
|
303
304
|
monkeypatch.setenv("ETHIACK_API_SECRET", "leftover")
|
|
304
305
|
|
|
305
306
|
mock_api = MagicMock()
|
|
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
|