Skip to content

detect: add checks for count keyword - #2634

Closed
catenacyber wants to merge 1 commit into
OISF:masterfrom
catenacyber:detect-count-5044-v1
Closed

detect: add checks for count keyword#2634
catenacyber wants to merge 1 commit into
OISF:masterfrom
catenacyber:detect-count-5044-v1

Conversation

@catenacyber

Copy link
Copy Markdown
Collaborator

Ticket

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

Draft : CI will be too red : need a new test with min-version instead of changing an existing test
But, saving work and getting feedback

Comment thread tests/detect-email-received/test.rules Outdated
@catenacyber
catenacyber force-pushed the detect-count-5044-v1 branch 2 times, most recently from f29d92e to 23dcf37 Compare September 25, 2025 08:52
@catenacyber catenacyber changed the title detect: WIP checks for count keyword detect: add checks for count keyword Sep 25, 2025
@catenacyber
catenacyber marked this pull request as ready for review September 25, 2025 08:52
# Match
alert smtp any any -> any any (msg:"Test mime email received"; email.received: all; content:"from"; sid: 30;)
alert smtp any any -> any any (msg:"Test mime email received"; email.received: all_or_absent; content:"from"; sid: 31;)
alert smtp any any -> any any (msg:"Test mime email received"; email.received: nb 2; content:"relay1"; sid: 32;)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/nb/index/g

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

specifies the number of expected matches of the content match following it

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

email.received: count 5; email.received: nb >2; content:"bad juju";
email.received: count 5; email.received: nb >=2; content:"bad juju";
email.received: count 5; email.received: match >=2; content:"bad juju"; # < match would replace `nb` 
email.received: index 2; content:!"bad juju"; # < would like to see additionally support for explicit `index` 

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

match or matches ?

alert smtp any any -> any any (msg:"Test mime email received count <3"; email.received: count <3; sid:21;)

# Match
alert smtp any any -> any any (msg:"Test mime email received"; email.received: all; content:"from"; sid: 30;)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this work with count as well?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leaving count out for now

# Match
alert smtp any any -> any any (msg:"Test mime email received"; email.received: all; content:"from"; sid: 30;)
alert smtp any any -> any any (msg:"Test mime email received"; email.received: all_or_absent; content:"from"; sid: 31;)
alert smtp any any -> any any (msg:"Test mime email received"; email.received: nb 2; content:"relay1"; sid: 32;)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

specifies the number of expected matches of the content match following it

# Match
alert smtp any any -> any any (msg:"Test mime email received"; email.received: all; content:"from"; sid: 30;)
alert smtp any any -> any any (msg:"Test mime email received"; email.received: all_or_absent; content:"from"; sid: 31;)
alert smtp any any -> any any (msg:"Test mime email received"; email.received: nb 2; content:"relay1"; sid: 32;)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

email.received: count 5; email.received: nb >2; content:"bad juju";
email.received: count 5; email.received: nb >=2; content:"bad juju";
email.received: count 5; email.received: match >=2; content:"bad juju"; # < match would replace `nb` 
email.received: index 2; content:!"bad juju"; # < would like to see additionally support for explicit `index` 

@catenacyber

Copy link
Copy Markdown
Collaborator Author

Replaced by #3062

@catenacyber catenacyber closed this May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

requires suricata pr Depends on a PR in Suricata

Development

Successfully merging this pull request may close these issues.

2 participants