Skip to content

Updated test failure script - #7

Merged
dwoz merged 1 commit into
dwoz:jenkins-scriptfrom
waynew:jenkins-test-script
Jul 16, 2019
Merged

dwoz merged 1 commit into
dwoz:jenkins-scriptfrom
waynew:jenkins-test-script

Conversation

@waynew

@waynew waynew commented May 2, 2019

Copy link
Copy Markdown

This produces an output that is copy-pastable to a GitHub issue, pretty much

@dwoz
dwoz merged commit 4d42804 into dwoz:jenkins-script Jul 16, 2019
dwoz pushed a commit that referenced this pull request Aug 20, 2019
 Rename provider azure-config to azurearm-config and remove joyent configs
dwoz added a commit that referenced this pull request Jan 2, 2026
SECURITY FIX: Configuration key had typo 'clsuter_pub_signature' instead
of 'cluster_pub_signature', causing cluster public key signature
verification to always fail.

Impact:
The cluster_pub_signature verification at line 1719 would raise a
KeyError when checking self.opts["clsuter_pub_signature"], causing
the check to fail silently or crash. This meant:

- Cluster public key signatures were never properly validated
- System would fall back to warning "No cluster signature provided"
- Any cluster public key would be accepted (TOFU vulnerability)
- Man-in-the-middle could inject malicious cluster keys

The check at line 1718 uses the correct spelling:
  if self.opts.get("cluster_pub_signature", None):

But line 1719 had the typo:
  if digest != self.opts["clsuter_pub_signature"]  # ❌ typo

This is now fixed to:
  if digest != self.opts["cluster_pub_signature"]  # ✅ correct

Attack Prevented:
Previously, attacker could send discover-reply with malicious cluster
public key. Due to typo, signature verification would fail and system
would accept any cluster_pub.

Now, if cluster_pub_signature is configured, it will properly validate
the cluster public key digest matches the expected signature.

Resolves security issue #7 from CLUSTER_JOIN_SECURITY_ANALYSIS.md
dwoz added a commit that referenced this pull request Apr 2, 2026
SECURITY FIX: Configuration key had typo 'clsuter_pub_signature' instead
of 'cluster_pub_signature', causing cluster public key signature
verification to always fail.

Impact:
The cluster_pub_signature verification at line 1719 would raise a
KeyError when checking self.opts["clsuter_pub_signature"], causing
the check to fail silently or crash. This meant:

- Cluster public key signatures were never properly validated
- System would fall back to warning "No cluster signature provided"
- Any cluster public key would be accepted (TOFU vulnerability)
- Man-in-the-middle could inject malicious cluster keys

The check at line 1718 uses the correct spelling:
  if self.opts.get("cluster_pub_signature", None):

But line 1719 had the typo:
  if digest != self.opts["clsuter_pub_signature"]  # ❌ typo

This is now fixed to:
  if digest != self.opts["cluster_pub_signature"]  # ✅ correct

Attack Prevented:
Previously, attacker could send discover-reply with malicious cluster
public key. Due to typo, signature verification would fail and system
would accept any cluster_pub.

Now, if cluster_pub_signature is configured, it will properly validate
the cluster public key digest matches the expected signature.

Resolves security issue #7 from CLUSTER_JOIN_SECURITY_ANALYSIS.md
dwoz added a commit that referenced this pull request Apr 7, 2026
SECURITY FIX: Configuration key had typo 'clsuter_pub_signature' instead
of 'cluster_pub_signature', causing cluster public key signature
verification to always fail.

Impact:
The cluster_pub_signature verification at line 1719 would raise a
KeyError when checking self.opts["clsuter_pub_signature"], causing
the check to fail silently or crash. This meant:

- Cluster public key signatures were never properly validated
- System would fall back to warning "No cluster signature provided"
- Any cluster public key would be accepted (TOFU vulnerability)
- Man-in-the-middle could inject malicious cluster keys

The check at line 1718 uses the correct spelling:
  if self.opts.get("cluster_pub_signature", None):

But line 1719 had the typo:
  if digest != self.opts["clsuter_pub_signature"]  # ❌ typo

This is now fixed to:
  if digest != self.opts["cluster_pub_signature"]  # ✅ correct

Attack Prevented:
Previously, attacker could send discover-reply with malicious cluster
public key. Due to typo, signature verification would fail and system
would accept any cluster_pub.

Now, if cluster_pub_signature is configured, it will properly validate
the cluster public key digest matches the expected signature.

Resolves security issue #7 from CLUSTER_JOIN_SECURITY_ANALYSIS.md
dwoz added a commit that referenced this pull request Apr 8, 2026
SECURITY FIX: Configuration key had typo 'clsuter_pub_signature' instead
of 'cluster_pub_signature', causing cluster public key signature
verification to always fail.

Impact:
The cluster_pub_signature verification at line 1719 would raise a
KeyError when checking self.opts["clsuter_pub_signature"], causing
the check to fail silently or crash. This meant:

- Cluster public key signatures were never properly validated
- System would fall back to warning "No cluster signature provided"
- Any cluster public key would be accepted (TOFU vulnerability)
- Man-in-the-middle could inject malicious cluster keys

The check at line 1718 uses the correct spelling:
  if self.opts.get("cluster_pub_signature", None):

But line 1719 had the typo:
  if digest != self.opts["clsuter_pub_signature"]  # ❌ typo

This is now fixed to:
  if digest != self.opts["cluster_pub_signature"]  # ✅ correct

Attack Prevented:
Previously, attacker could send discover-reply with malicious cluster
public key. Due to typo, signature verification would fail and system
would accept any cluster_pub.

Now, if cluster_pub_signature is configured, it will properly validate
the cluster public key digest matches the expected signature.

Resolves security issue #7 from CLUSTER_JOIN_SECURITY_ANALYSIS.md
dwoz added a commit that referenced this pull request Apr 12, 2026
SECURITY FIX: Configuration key had typo 'clsuter_pub_signature' instead
of 'cluster_pub_signature', causing cluster public key signature
verification to always fail.

Impact:
The cluster_pub_signature verification at line 1719 would raise a
KeyError when checking self.opts["clsuter_pub_signature"], causing
the check to fail silently or crash. This meant:

- Cluster public key signatures were never properly validated
- System would fall back to warning "No cluster signature provided"
- Any cluster public key would be accepted (TOFU vulnerability)
- Man-in-the-middle could inject malicious cluster keys

The check at line 1718 uses the correct spelling:
  if self.opts.get("cluster_pub_signature", None):

But line 1719 had the typo:
  if digest != self.opts["clsuter_pub_signature"]  # ❌ typo

This is now fixed to:
  if digest != self.opts["cluster_pub_signature"]  # ✅ correct

Attack Prevented:
Previously, attacker could send discover-reply with malicious cluster
public key. Due to typo, signature verification would fail and system
would accept any cluster_pub.

Now, if cluster_pub_signature is configured, it will properly validate
the cluster public key digest matches the expected signature.

Resolves security issue #7 from CLUSTER_JOIN_SECURITY_ANALYSIS.md
dwoz added a commit that referenced this pull request May 14, 2026
This commit fixes catastrophic FD exhaustion in Salt minions running
queued state jobs. The issue manifested as "Too many open files" errors
after ~15 queued jobs.

Root causes and fixes:

1. Unawaited coroutine (salt/utils/event.py:785)
   - Changed self.pusher.publish(msg) to await self.pusher.publish(msg)

2. Unclosed event loops in job threads (salt/minion.py)
   - Added loop.close() in finally blocks of _thread_return() and _thread_multi_return()

3. SyncWrapper __getattr__ preventing cleanup (salt/utils/event.py)
   - Explicitly call SyncWrapper.close() instead of relying on __getattr__

4. Missing task cancellation (salt/utils/asynchronous.py)
   - Cancel pending tasks before closing event loop
   - Shutdown async generators with shutdown_asyncgens()
   - Shutdown executor with shutdown_default_executor()

5. IOLoop auto-creation (salt/utils/asynchronous.py)
   - Changed IOLoop.current() to IOLoop.current(instance=False)

6. Nested SyncWrapper in TCP transport (salt/transport/tcp.py)
   - Explicitly close pub_sock SyncWrapper in PublishServer.close()

7. Unclosed TCP client (salt/transport/tcp.py)
   - Added _tcp_client.close() in PublishClient.close()

8. Async generator/executor shutdown (salt/utils/asynchronous.py)
   - Call shutdown_asyncgens() and shutdown_default_executor() before loop close

Impact:
- Before: 237 FDs leaked per 15 queued jobs → OSError after ~40 jobs
- After: 0 FDs leaked (multiprocessing), minimal leaks (threading)

Tests added:
- tests/pytests/scenarios/queue/test_queue_fd_leak.py
  Comprehensive regression test for the reported bug

- tests/pytests/scenarios/regression/test_fd_leak_fire_event_async.py
  Regression test for fix #1 (unawaited coroutine)

- tests/pytests/scenarios/regression/test_fd_leak_job_thread_loop.py
  Regression test for fix #2 (job thread event loop close)

- tests/pytests/scenarios/regression/test_fd_leak_syncwrapper_close.py
  Regression test for fix #3 (SyncWrapper explicit close)

- tests/pytests/scenarios/regression/test_fd_leak_task_cancellation.py
  Regression test for fix #4 (task cancellation and cleanup)

- tests/pytests/scenarios/regression/test_fd_leak_ioloop_instance.py
  Regression test for fix #5 (IOLoop.current(instance=False))

- tests/pytests/scenarios/regression/test_fd_leak_tcp_nested_syncwrapper.py
  Regression test for fix #6 (nested SyncWrapper in TCP)

- tests/pytests/scenarios/regression/test_fd_leak_tcp_client_close.py
  Regression test for fix #7 (TCP client close)

- tests/pytests/scenarios/regression/test_fd_leak_asyncgens_executor.py
  Regression test for fix #8 (async generator and executor shutdown)

All regression tests:
- Use real Salt master/minion infrastructure (not mocks)
- Measure actual FD counts with psutil
- Exercise specific code paths that were leaking
- Assert FD leaks are minimal (≤ threshold)
dwoz pushed a commit that referenced this pull request May 14, 2026
Three of the new tests in tests/pytests/scenarios/regression/ kept failing
across the CI matrix for reasons that have nothing to do with the FD-leak
fix they were meant to guard:

  * test_fd_leak_job_thread_loop.py (both tests) fired test.ping with
    kwarg={"queue": True}, but `queue=True` is only a parameter of
    state.apply / state.sls. test.ping rejects it with SaltInvocationError
    so the minion never produces a normal return event, the assertion
    `Job did not complete` always trips. The same tests also passed
    `minion.id` (a bare string) to LocalClient.get_returns(jid, minions),
    which immediately does set(minions) and ends up matching against a
    set of single characters.

  * test_fd_leak_tcp_client_close.py and test_fd_leak_tcp_nested_syncwrapper.py
    spin up their own TCP master+minion pair inside a zmq-default scenarios
    session. The TCP auth handshake never converges in that configuration
    on a number of CI runners (Ubuntu 24.04, Photon ARM64) and saltfactories
    times out with FactoryNotStarted after ~384s. The two TCP fixes those
    tests are pointed at (#6, #7) are already exercised by the existing
    `scenarios tcp` CI variant, which runs the whole scenarios suite under
    a globally configured TCP transport.

Coverage left in place: tests/pytests/scenarios/queue/test_queue_fd_leak.py
(the comprehensive 15-queued-job test, green on both multiprocessing and
threading modes) plus the remaining regression tests in this directory
(asyncgens_executor, fire_event_async x2, ioloop_instance, syncwrapper_close,
task_cancellation, fd_threshold_queuing x2). Those collectively cover fixes
#1, #3, #4, #5, #8, and the FD-threshold queuing safety mechanism.
dwoz added a commit that referenced this pull request May 14, 2026
This commit fixes catastrophic FD exhaustion in Salt minions running
queued state jobs. The issue manifested as "Too many open files" errors
after ~15 queued jobs.

Root causes and fixes:

1. Unawaited coroutine (salt/utils/event.py:785)
   - Changed self.pusher.publish(msg) to await self.pusher.publish(msg)

2. Unclosed event loops in job threads (salt/minion.py)
   - Added loop.close() in finally blocks of _thread_return() and _thread_multi_return()

3. SyncWrapper __getattr__ preventing cleanup (salt/utils/event.py)
   - Explicitly call SyncWrapper.close() instead of relying on __getattr__

4. Missing task cancellation (salt/utils/asynchronous.py)
   - Cancel pending tasks before closing event loop
   - Shutdown async generators with shutdown_asyncgens()
   - Shutdown executor with shutdown_default_executor()

5. IOLoop auto-creation (salt/utils/asynchronous.py)
   - Changed IOLoop.current() to IOLoop.current(instance=False)

6. Nested SyncWrapper in TCP transport (salt/transport/tcp.py)
   - Explicitly close pub_sock SyncWrapper in PublishServer.close()

7. Unclosed TCP client (salt/transport/tcp.py)
   - Added _tcp_client.close() in PublishClient.close()

8. Async generator/executor shutdown (salt/utils/asynchronous.py)
   - Call shutdown_asyncgens() and shutdown_default_executor() before loop close

Impact:
- Before: 237 FDs leaked per 15 queued jobs → OSError after ~40 jobs
- After: 0 FDs leaked (multiprocessing), minimal leaks (threading)

Tests added:
- tests/pytests/scenarios/queue/test_queue_fd_leak.py
  Comprehensive regression test for the reported bug

- tests/pytests/scenarios/regression/test_fd_leak_fire_event_async.py
  Regression test for fix #1 (unawaited coroutine)

- tests/pytests/scenarios/regression/test_fd_leak_job_thread_loop.py
  Regression test for fix #2 (job thread event loop close)

- tests/pytests/scenarios/regression/test_fd_leak_syncwrapper_close.py
  Regression test for fix #3 (SyncWrapper explicit close)

- tests/pytests/scenarios/regression/test_fd_leak_task_cancellation.py
  Regression test for fix #4 (task cancellation and cleanup)

- tests/pytests/scenarios/regression/test_fd_leak_ioloop_instance.py
  Regression test for fix #5 (IOLoop.current(instance=False))

- tests/pytests/scenarios/regression/test_fd_leak_tcp_nested_syncwrapper.py
  Regression test for fix #6 (nested SyncWrapper in TCP)

- tests/pytests/scenarios/regression/test_fd_leak_tcp_client_close.py
  Regression test for fix #7 (TCP client close)

- tests/pytests/scenarios/regression/test_fd_leak_asyncgens_executor.py
  Regression test for fix #8 (async generator and executor shutdown)

All regression tests:
- Use real Salt master/minion infrastructure (not mocks)
- Measure actual FD counts with psutil
- Exercise specific code paths that were leaking
- Assert FD leaks are minimal (≤ threshold)
dwoz pushed a commit that referenced this pull request May 14, 2026
Three of the new tests in tests/pytests/scenarios/regression/ kept failing
across the CI matrix for reasons that have nothing to do with the FD-leak
fix they were meant to guard:

  * test_fd_leak_job_thread_loop.py (both tests) fired test.ping with
    kwarg={"queue": True}, but `queue=True` is only a parameter of
    state.apply / state.sls. test.ping rejects it with SaltInvocationError
    so the minion never produces a normal return event, the assertion
    `Job did not complete` always trips. The same tests also passed
    `minion.id` (a bare string) to LocalClient.get_returns(jid, minions),
    which immediately does set(minions) and ends up matching against a
    set of single characters.

  * test_fd_leak_tcp_client_close.py and test_fd_leak_tcp_nested_syncwrapper.py
    spin up their own TCP master+minion pair inside a zmq-default scenarios
    session. The TCP auth handshake never converges in that configuration
    on a number of CI runners (Ubuntu 24.04, Photon ARM64) and saltfactories
    times out with FactoryNotStarted after ~384s. The two TCP fixes those
    tests are pointed at (#6, #7) are already exercised by the existing
    `scenarios tcp` CI variant, which runs the whole scenarios suite under
    a globally configured TCP transport.

Coverage left in place: tests/pytests/scenarios/queue/test_queue_fd_leak.py
(the comprehensive 15-queued-job test, green on both multiprocessing and
threading modes) plus the remaining regression tests in this directory
(asyncgens_executor, fire_event_async x2, ioloop_instance, syncwrapper_close,
task_cancellation, fd_threshold_queuing x2). Those collectively cover fixes
#1, #3, #4, #5, #8, and the FD-threshold queuing safety mechanism.
dwoz added a commit that referenced this pull request Sep 10, 2026
…-caller-close

Wrap fire-and-forget MinionEvent callers to close SaltEvent chain (#7…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants