ethiack-beacon 2.2.0__tar.gz → 2.2.2__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 (33) hide show
  1. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/PKG-INFO +1 -1
  2. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/cli/api.py +9 -3
  3. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/cli/wireguard.py +12 -3
  4. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/ethiack_beacon.egg-info/PKG-INFO +1 -1
  5. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/pyproject.toml +1 -1
  6. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/tests/test_api.py +31 -0
  7. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/tests/test_wireguard.py +33 -0
  8. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/README.md +0 -0
  9. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/cli/__init__.py +0 -0
  10. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/cli/config.py +0 -0
  11. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/cli/console.py +0 -0
  12. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/cli/dns.py +0 -0
  13. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/cli/exceptions.py +0 -0
  14. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/cli/main.py +0 -0
  15. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/cli/rathole.py +0 -0
  16. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/cli/system.py +0 -0
  17. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/ethiack_beacon.egg-info/SOURCES.txt +0 -0
  18. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/ethiack_beacon.egg-info/dependency_links.txt +0 -0
  19. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/ethiack_beacon.egg-info/entry_points.txt +0 -0
  20. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/ethiack_beacon.egg-info/requires.txt +0 -0
  21. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/ethiack_beacon.egg-info/top_level.txt +0 -0
  22. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/setup.cfg +0 -0
  23. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/tests/test_api_extra.py +0 -0
  24. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/tests/test_config.py +0 -0
  25. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/tests/test_console_extra.py +0 -0
  26. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/tests/test_dns.py +0 -0
  27. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/tests/test_main.py +0 -0
  28. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/tests/test_main_create_start.py +0 -0
  29. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/tests/test_main_health_misc.py +0 -0
  30. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/tests/test_rathole.py +0 -0
  31. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/tests/test_rathole_extra.py +0 -0
  32. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/tests/test_system.py +0 -0
  33. {ethiack_beacon-2.2.0 → ethiack_beacon-2.2.2}/tests/test_system_extra.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ethiack-beacon
3
- Version: 2.2.0
3
+ Version: 2.2.2
4
4
  Summary: Ethiack Beacon CLI - secure network tunnel management
5
5
  Author-email: Ethiack Engineering Team <engineering@ethiack.com>
6
6
  License: Proprietary
@@ -257,7 +257,11 @@ class BeaconAPI:
257
257
  except httpx.TimeoutException as exc:
258
258
  raise BeaconAPIError(f"Request timed out: {exc}") from exc
259
259
 
260
- _warn_if_legacy_auth(resp)
260
+ # Only a key:secret request can be legacy auth. phx_ requests also get a
261
+ # Deprecation header from deprecated routes (the /v1/events alias of
262
+ # /v1/pentests), which says nothing about the key.
263
+ if not self._settings.uses_bearer_auth:
264
+ _warn_if_legacy_auth(resp)
261
265
 
262
266
  if resp.status_code in (401, 403):
263
267
  # Naming a secret a phx_ user correctly does not have is a dead end.
@@ -293,8 +297,10 @@ class BeaconAPI:
293
297
  def _warn_if_legacy_auth(resp: httpx.Response) -> None:
294
298
  """Surface the API's Deprecation/Sunset headers once per process.
295
299
 
296
- The API sets these only on a successful legacy (key:secret) resolution, so
297
- their presence is the authoritative signal that this credential is legacy.
300
+ Only for key:secret requests: on those, the API sets these on a successful
301
+ legacy resolution, so their presence is the authoritative signal that this
302
+ credential is legacy. Deprecated routes send Deprecation whatever the
303
+ credential, so on a phx_ request the header says nothing about the key.
298
304
  Advisory only - never fails, never self-disables on the sunset date.
299
305
  """
300
306
  global _DEPRECATION_WARNED
@@ -89,13 +89,22 @@ def get_active_interfaces() -> list[str]:
89
89
 
90
90
 
91
91
  def teardown_all() -> None:
92
- """Delete every active WireGuard interface via ``ip link delete``.
92
+ """Bring down every active WireGuard interface.
93
93
 
94
94
  Used before creating a new beacon to clear stale interfaces from previous
95
- runs (e.g. Docker restart where the network namespace outlives the container
96
- and no wg-quick config files exist to run ``wg-quick down``).
95
+ runs. Interfaces with a config in the state directory go through
96
+ ``wg-quick down`` so their PostDown hooks remove the MASQUERADE rule - a
97
+ bare ``ip link delete`` leaves it behind, and the next ``wg-quick up`` adds
98
+ a duplicate. Interfaces without a config (e.g. Docker restart where the
99
+ network namespace outlives the container) fall back to ``ip link delete``.
97
100
  """
98
101
  for iface in get_active_interfaces():
102
+ if (WG_CONF_DIR / f"{iface}.conf").exists():
103
+ try:
104
+ down(iface)
105
+ continue
106
+ except BeaconSystemError:
107
+ pass # e.g. PostDown failed; make sure the link is gone below
99
108
  try:
100
109
  subprocess.run(
101
110
  [*_sudo(), "ip", "link", "delete", iface],
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ethiack-beacon
3
- Version: 2.2.0
3
+ Version: 2.2.2
4
4
  Summary: Ethiack Beacon CLI - secure network tunnel management
5
5
  Author-email: Ethiack Engineering Team <engineering@ethiack.com>
6
6
  License: Proprietary
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "ethiack-beacon"
7
- version = "2.2.0"
7
+ version = "2.2.2"
8
8
  description = "Ethiack Beacon CLI - secure network tunnel management"
9
9
  requires-python = ">=3.11"
10
10
  license = { text = "Proprietary" }
@@ -631,3 +631,34 @@ class TestAuthScheme:
631
631
  )
632
632
  api.get_organizations()
633
633
  assert warnings == []
634
+
635
+ @pytest.mark.parametrize(
636
+ "headers",
637
+ [
638
+ # What the API sends on the /v1/events alias today
639
+ {"Deprecation": "@1782345600", "Link": '</v1/pentests>; rel="successor-version"'},
640
+ # ...and once the alias gets a retirement date
641
+ {"Deprecation": "@1782345600", "Sunset": "Thu, 31 Dec 2026 23:59:59 GMT"},
642
+ ],
643
+ )
644
+ def test_phx_key_ignores_route_deprecation(
645
+ self, phx_settings, httpx_mock: HTTPXMock, monkeypatch, headers
646
+ ):
647
+ """A deprecated route is not a deprecated key: a phx_ user creating a
648
+ pentest through /v1/events must not be told to replace their key."""
649
+ import cli.api as api_mod
650
+
651
+ monkeypatch.setattr(api_mod, "_DEPRECATION_WARNED", False)
652
+ warnings: list[str] = []
653
+ monkeypatch.setattr(api_mod, "warning", warnings.append)
654
+
655
+ httpx_mock.add_response(
656
+ method="POST",
657
+ url=f"{BASE_URL}/v1/events/",
658
+ status_code=201,
659
+ json={"slug": "hackbot-c3"},
660
+ headers=headers,
661
+ )
662
+ with BeaconAPI(phx_settings) as api:
663
+ api.create_pentest(organization_id="1", name="Hackbot - beacon")
664
+ assert warnings == []
@@ -217,6 +217,10 @@ class TestGetActiveInterfaces:
217
217
 
218
218
 
219
219
  class TestTeardownAll:
220
+ @pytest.fixture(autouse=True)
221
+ def _empty_conf_dir(self, tmp_path, monkeypatch):
222
+ monkeypatch.setattr(wg, "WG_CONF_DIR", tmp_path)
223
+
220
224
  def test_deletes_all_active_interfaces(self):
221
225
  with patch("cli.wireguard.get_active_interfaces", return_value=["wg0", "wg1"]), \
222
226
  patch("subprocess.run") as mock_run:
@@ -244,6 +248,35 @@ class TestTeardownAll:
244
248
  wg.teardown_all() # should not raise
245
249
  assert mock_run.call_count == 2
246
250
 
251
+ def test_uses_wg_quick_down_when_conf_exists(self, tmp_path):
252
+ # wg-quick down runs PostDown, which removes the MASQUERADE rule;
253
+ # ip link delete alone would leak it.
254
+ (tmp_path / "wg0.conf").write_text("[Interface]\n")
255
+ with patch("cli.wireguard.get_active_interfaces", return_value=["wg0", "wg1"]), \
256
+ patch("subprocess.run") as mock_run:
257
+ mock_run.return_value = MagicMock(returncode=0)
258
+ wg.teardown_all()
259
+ calls = [c[0][0] for c in mock_run.call_args_list]
260
+ assert calls == [
261
+ ["wg-quick", "down", str(tmp_path / "wg0.conf")],
262
+ ["ip", "link", "delete", "wg1"],
263
+ ]
264
+
265
+ def test_falls_back_to_ip_link_delete_when_wg_quick_down_fails(self, tmp_path):
266
+ (tmp_path / "wg0.conf").write_text("[Interface]\n")
267
+ with patch("cli.wireguard.get_active_interfaces", return_value=["wg0"]), \
268
+ patch("subprocess.run") as mock_run:
269
+ mock_run.side_effect = [
270
+ MagicMock(returncode=1, stderr="iptables: Bad rule", stdout=""),
271
+ MagicMock(returncode=0),
272
+ ]
273
+ wg.teardown_all() # should not raise
274
+ calls = [c[0][0] for c in mock_run.call_args_list]
275
+ assert calls == [
276
+ ["wg-quick", "down", str(tmp_path / "wg0.conf")],
277
+ ["ip", "link", "delete", "wg0"],
278
+ ]
279
+
247
280
 
248
281
  # ---------------------------------------------------------------------------
249
282
  # enable_ip_forwarding
File without changes
File without changes