suricata-verify icon indicating copy to clipboard operation
suricata-verify copied to clipboard

test-dump-counters: Test dump-counters via unix-command socket

Open awelzel opened this issue 11 months ago • 16 comments

Replaces https://github.com/OISF/suricata-verify/pull/1683

Changes since v4:

  • Switch to af-packet source because using pcap blocks Suricata termination on Debian 10 and Ubuntu 20.04.

Changes since v3:

  • Don't use ps, not available in CI everywhere.
  • Invoke suricatasc with python3.

Changes since v2:

  • Rewrote as shell script invoking suricatasc instead of using the suricatasc Python module
  • Set rule-files.0=/dev/null to prevent loading of rules
  • Set a BPF filter to make capture on lo unlikely

Test for https://github.com/OISF/suricata/pull/10468

Ticket

Ticket: 6732

Redmine ticket: https://redmine.openinfosecfoundation.org/issues/6732

awelzel avatar Mar 05 '24 10:03 awelzel

@jasonish - how does this version look to you?

awelzel avatar Mar 06 '24 18:03 awelzel

@jasonish - how does this version look to you?

Yeah, not as pretty :) But more future proof with respect for some changes I hope to have in by 8.0. Thanks.

jasonish avatar Mar 06 '24 18:03 jasonish

I ran this in my own private gitlab-ci env, where the tests run in docker containers. Got a bunch of failures with exit codes 127, 137(?), 124 and one test timeout. Haven't tried to debug it.

Would it need special capabilities?

victorjulien avatar Mar 08 '24 16:03 victorjulien

Would it need special capabilities?

Suppose CAP_NET_RAW due to listeing on lo. I ran it within a plain docker run --rm -it here and that seemed to work.

awelzel avatar Mar 08 '24 18:03 awelzel

https://github.com/OISF/suricata/pull/10583 got merged, so this should pass... let's check

catenacyber avatar Mar 14 '24 16:03 catenacyber

OISF/suricata#10583 got merged, so this should pass... let's check

Thanks for re-triggering. Think for main-7.0.x still needs f17204191d3bb2201e6b6b1c4cf2e7a96148e8cd backported for it to pass there too :crossed_fingers:

FYI - I'll be unavailable for the next few weeks. If there's interest in having this test merged and there's more polishing needed, would be great if someone could shepherd it.

cc @jlucovsky / @jasonish

awelzel avatar Mar 15 '24 09:03 awelzel

Do we know why this is failing on Suricata 7? Looks like its been backported.

jasonish avatar Mar 23 '24 21:03 jasonish

Do we know why this is failing on Suricata 7? Looks like its been backported.

Where ? git log main-7.0.x | grep f172041 yields no result for me

catenacyber avatar Mar 24 '24 19:03 catenacyber

I concur with @catenacyber

The changes are in master:

 $ git l | grep -e 'stats: Fix non-worker' -e 'schema: Add stats.capture'
f9cf87a003 schema: Add stats.capture and in_iface properties
f17204191d stats: Fix non-worker stats missing

These are not in main-7.0.x:

$ git l | grep -e 'stats: Fix non-worker' -e 'schema: Add stats.capture'
$

jlucovsky avatar Mar 25 '24 12:03 jlucovsky

7.0.x backport: https://github.com/OISF/suricata/pull/10717

jlucovsky avatar Mar 25 '24 12:03 jlucovsky

I didn't look past the backport ticket, which appears to be closed for 7.0.x.

jasonish avatar Mar 27 '24 15:03 jasonish

Backport was merged, could this PR get a rebased version to check CI ?

catenacyber avatar Apr 17 '24 11:04 catenacyber

I think it needs to be reconsidered completely, as I got massive failures in my CI setup, most likely for not working well with certain permissions missing from the CI runners.

victorjulien avatar Apr 17 '24 12:04 victorjulien

I think it needs to be reconsidered completely, as I got massive failures in my CI setup, most likely for not working well with certain permissions missing from the CI runners.

Perhaps adding capabilities to the requires section of test.yaml? But that could get complex. On Linux, you might only want to run if certain caps are available, but run on FreeBSD as long as root. That does bring a level of expression not available in S-V.

Or put tests that require a level of privilege in a separate directory, privileged-tests and then its up to the CI environment to be configured to run them.

jasonish avatar Apr 17 '24 14:04 jasonish

I think SV isn't the best place for this. I've added a bunch of "live" tests in https://github.com/OISF/suricata/pull/11006, and I think this work could be extended for the testing required here?

victorjulien avatar Jul 30 '24 13:07 victorjulien

See in suricata :

.github/workflows/live/pcap.sh:JSON=$(python3 python/bin/suricatasc -c "dump-counters" /var/run/suricata/suricata-command.socket)

catenacyber avatar Jul 30 '24 13:07 catenacyber

I'm going to close this PR. I don't have the cycles to see this through. I agree with @catenacyber 's last comment that the script looks like a good place to validate the dump-counters output more.

awelzel avatar Sep 03 '24 08:09 awelzel

Thanks Arne for your efforts

catenacyber avatar Sep 03 '24 09:09 catenacyber