Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enip rust 3958 v7 #9991

Closed
wants to merge 2 commits into from
Closed

Conversation

catenacyber
Copy link
Contributor

Link to redmine ticket:
https://redmine.openinfosecfoundation.org/issues/3958

Describe changes:

  • convert enip parser to rust
  • integer keywords now support hexadecimal notation

Alon the way, also

  • transactions are now bidirectional
  • there is a enip logger
  • gap support is improved with probing for resync
  • frames
  • events
  • enip_command keyword accepts now string enumeration as values.
  • more keywords

#9940 with rebase and fixup commit autosquashed + new S-V tests

Provide values to any of the below to override the defaults.

SV_BRANCH=pr/1521

OISF/suricata-verify#1521

Does the first commit deserve its own redmine ticket ?
And the one in 4a49352 also ?

So that we can write enip.revision: 0x203
Ticket: 3958

- transactions are now bidirectional
- there is a logger
- gap support is improved with probing for resync
- frames support
- app-layer events
- enip_command keyword accepts now string enumeration as values.
- add enip.status keyword
- add keywords :
    enip.product_name, enip.protocol_version, enip.revision,
    enip.identity_status, enip.state, enip.serial, enip.product_code,
    enip.device_type, enip.vendor_id, enip.capabilities,
    enip.cip_attribute, enip.cip_class, enip.cip_instance,
    enip.cip_status, enip.cip_extendedstatus
@catenacyber
Copy link
Contributor Author

Also #9870 should be merged before this to avoid a short-lived output-json-enip.c file ;-)

Copy link

codecov bot commented Dec 7, 2023

Codecov Report

Merging #9991 (a9a0b78) into master (64d12aa) will decrease coverage by 4.57%.
Report is 7 commits behind head on master.
The diff coverage is 34.79%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9991      +/-   ##
==========================================
- Coverage   82.45%   77.89%   -4.57%     
==========================================
  Files         970      989      +19     
  Lines      271356   273570    +2214     
==========================================
- Hits       223746   213096   -10650     
- Misses      47610    60474   +12864     
Flag Coverage Δ
fuzzcorpus 63.67% <33.73%> (-0.86%) ⬇️
suricata-verify ?
unittests 62.34% <11.98%> (-0.54%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

@suricata-qa
Copy link

Information: QA ran without warnings.

Pipeline 16954

Copy link
Contributor

@jufajardini jufajardini left a comment

Choose a reason for hiding this comment

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

I've noticed that some of the keywords match against specific ENIP messages. Makes me wonder if we could add subsections for these, to help organize 🤔

Left some (mainly nit) inline comments.

enip.cip_extendedstatus
-----------------------

Match on the cip extended status if any (one of them in case of multiple service packet).
Copy link
Contributor

Choose a reason for hiding this comment

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

This sentence is a bit confusing to me. Does this mean that cip_extendedstatus will match on extended status if there is any, and that it can match on any of the seen statuses - as is, a single packet might have more than one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Your understanding is correct.

Do you have another way to phrase this ?

Copy link
Contributor

Choose a reason for hiding this comment

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

What about...
Match on the cip extended status, if any is present. For multiple service packet, if there is more than one, can match on any of the seen statuses.

doc/userguide/rules/enip-keyword.rst Show resolved Hide resolved
doc/userguide/rules/enip-keyword.rst Show resolved Hide resolved
Comment on lines +54 to +59
return -1;

DetectU32Data *du32 = DetectU32Parse(rulestr);
if (du32 == NULL) {
return -1;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious: why not use SCReturnInt in these cases, too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do not know what SCReturnInt does different... @victorjulien ?

Copy link
Member

Choose a reason for hiding this comment

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

It's a wrapper around a SCLogDebug + return statement, so it can be helpful during debug. But we're not very consistent in using it.

Examples::

enip.status:100;
enip.status:>106;
Copy link
Contributor

Choose a reason for hiding this comment

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

For all these cases where a value is accepted, are all other modes (<, <=, >...) also accepted? Wonder if this should be made more evident, if nothing else, by using other operands, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Every mode is supported is true for all integer keywords...

Maybe there should be from every integer keyword documentation a link to some special section where integers are documented ? This should be its own redmine ticket ;-)

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair point, and makes sense.

Copy link
Contributor

Choose a reason for hiding this comment

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

@catenacyber catenacyber mentioned this pull request Dec 13, 2023
@catenacyber
Copy link
Contributor Author

Replaced by #10048

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants