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

detect/asn1: Migrate to Rust - v1 #4954

Closed
wants to merge 7 commits into from

Conversation

sharksforarms
Copy link
Contributor

@sharksforarms sharksforarms commented May 19, 2020

Draft PR: Request for review/comments

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

Describe changes:

  • Migration of ASN1 decoder and detect module to Rust

PRScript output (if applicable):

TODO:

Update der-parser crate and update kerberos and snmp modules with API
changes
This module uses the `der-parser` crate to parse ASN1 objects in order to replace src/util-decode-asn1.c
It also handles the parsing of the asn1 keyword rules and detection checks performed in src/detect-asn1.c
Mark rust extern "C" functions as pub in asn1 module to expose via cbindgen
Update detect-asn1.c/h to use rust functions
- In favor of rust parser
- To be consistent with recent C version changes
- Add checks for over/underflows
- Failure to parse asn1-max-frames
- Failure on asn1 detection checks
- 'static is only realistic when allocating and leaking it over the
FFI boundary
@sharksforarms sharksforarms requested review from jasonish, victorjulien and a team as code owners May 19, 2020 14:04
@sharksforarms sharksforarms marked this pull request as draft May 19, 2020 14:08
@sharksforarms
Copy link
Contributor Author

sharksforarms commented May 19, 2020

Blockers:

CI: Rust 1.34.2 fails to compile der-parser and ipsec-parser

 Compiling der-parser v4.0.0-alpha3
error[E0658]: use of unstable library feature 'option_xor' (see issue #50512)
   --> /github/home/.cargo/registry/src/github.com-1ecc6299db9ec823/der-parser-4.0.0-alpha3/src/ber/ber.rs:392:33
    |
392 |                 if self.raw_tag.xor(other.raw_tag).is_none() {
    |                                 ^^^

   Compiling ipsec-parser v0.5.0
error[E0658]: use of unstable library feature 'iter_copied' (see issue #57127)
   --> /github/home/.cargo/registry/src/github.com-1ecc6299db9ec823/der-parser-4.0.0-alpha3/src/oid.rs:134:14
    |
134 |             .copied()
    |              ^^^^^^

@victorjulien
Copy link
Member

cc @chifflier

Copy link
Member

@victorjulien victorjulien left a comment

Choose a reason for hiding this comment

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

Some minor comments. Nice work!

@sharksforarms
Copy link
Contributor Author

Continued: #4965

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.

3 participants