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

Multipart mime 3487 v21 #9443

Closed
wants to merge 4 commits into from

Conversation

catenacyber
Copy link
Contributor

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

Describe changes:

  • convert HTTP to use new rust mime parser
  • convert SMTP to use new rust mime parser

Follows #9437 with fix for rust panic (copying slices must have the exact same size) + removing some dead code cf #9419

@jasonish any ideas on how to get a better feedback that pub rs_mime_find_header_token was no longer used by the C side and should be removed as dead code ?

SV_BRANCH=pr/1371

SV tests from unit tests in OISF/suricata-verify#1371

Draft :

@jasonish
Copy link
Member

jasonish commented Sep 6, 2023

@jasonish any ideas on how to get a better feedback that pub rs_mime_find_header_token was no longer used by the C side and should be removed as dead code ?

Not really. The Rust code is just compiled into a library with externally addressable functions so I don't think we'll get a compiler to tell us.

@jasonish
Copy link
Member

jasonish commented Sep 6, 2023

Do you have scripts already for finding unused C code?

nm target/release/libsuricata_rust.a |awk '$2 == "T" && $3 !~ /^_/ { print $3 }'

will get you all externally linkable C functions from the Rust code. There are a few in there for other libraries like Brotli

@catenacyber
Copy link
Contributor Author

Replaced by #9447

@catenacyber catenacyber closed this Sep 6, 2023
@catenacyber
Copy link
Contributor Author

@jasonish any ideas on how to get a better feedback that pub rs_mime_find_header_token was no longer used by the C side and should be removed as dead code ?

Not really. The Rust code is just compiled into a library with externally addressable functions so I don't think we'll get a compiler to tell us.

Can a compiler/other tool tell us all the "externally addressable functions" from rust ? and check if they are used from C ?

@jasonish
Copy link
Member

jasonish commented Sep 6, 2023

Can a compiler/other tool tell us all the "externally addressable functions" from rust ? and check if they are used from C ?

I quick search tells me no. The compiler links looks up functions it needs, it doesn't really see functions it doesn't need. You can remove Rust from this question. As the .a library is the same as any other static C library, so all other tools like nm will work.

@catenacyber
Copy link
Contributor Author

I was not thinking about nm but some rust-analyzer tool ;-) (if it exists)

@jasonish
Copy link
Member

jasonish commented Sep 6, 2023

I was not thinking about nm but some rust-analyzer tool ;-) (if it exists)

No, this is outside the scope of Rust and back in C land.

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.

2 participants