Skip to content

Enip rust 3958 v9#10072

Closed
catenacyber wants to merge 2 commits into
OISF:masterfrom
catenacyber:enip-rust-3958-v9
Closed

Enip rust 3958 v9#10072
catenacyber wants to merge 2 commits into
OISF:masterfrom
catenacyber:enip-rust-3958-v9

Conversation

@catenacyber
Copy link
Copy Markdown
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

#10048 with needed rebase (DetectAppLayerMpmRegister2 renamed to DetectAppLayerMpmRegister) and auto squash

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
@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 19, 2023

Codecov Report

Merging #10072 (62633ae) into master (467c3f2) will decrease coverage by 0.52%.
The diff coverage is 46.74%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10072      +/-   ##
==========================================
- Coverage   82.39%   81.87%   -0.52%     
==========================================
  Files         972      991      +19     
  Lines      271406   273817    +2411     
==========================================
+ Hits       223624   224188     +564     
- Misses      47782    49629    +1847     
Flag Coverage Δ
fuzzcorpus 63.39% <34.11%> (-0.77%) ⬇️
suricata-verify 60.79% <41.21%> (-0.61%) ⬇️
unittests 62.31% <11.98%> (-0.54%) ⬇️

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

@suricata-qa
Copy link
Copy Markdown

WARNING:

field baseline test %
SURI_TLPW2_autofp_stats_chk
.uptime 181 192 106.08%

Pipeline 17157

Comment thread rust/src/enip/detect.rs
pub unsafe extern "C" fn rs_enip_parse_command(
raw: *const std::os::raw::c_char, value: *mut u16,
) -> bool {
let raw2: &CStr = CStr::from_ptr(raw); //unsafe
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.

Nothing wrong here, but in Rust its pretty normal to shadow the previous variable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

nice

Comment thread rust/src/enip/detect.rs
}

#[no_mangle]
pub unsafe extern "C" fn rs_enip_get_serial(
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.

I think we should start naming these like C functions.. ie) https://github.com/OISF/suricata/blob/master/rust/src/dns/dns.rs#L883

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread rust/src/enip/detect.rs

#[no_mangle]
pub unsafe extern "C" fn rs_enip_get_serial(
tx: *mut std::os::raw::c_void, value: *mut u32,
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.

If we're not checking these for NULL, we can get rid of the cast by tx: &mut EnipTransaction. See: https://github.com/OISF/suricata/blob/master/rust/src/dns/dns.rs#L884

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

indeed

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

Replaced by #10083 thank you @jasonish

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