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

smb: New keyword smb.cmd v6 #7338

Closed
wants to merge 3 commits into from
Closed

Conversation

zer1t0
Copy link
Contributor

@zer1t0 zer1t0 commented Apr 28, 2022

Make sure these boxes are signed before submitting your Pull Request -- thank you.

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

Describe changes:

  • New keyword smb.cmd added, which allows to match the command value in smb message header. It works for smb1 and smb2.
  • Documentation for the keyword added (created SMB keyword documentation)

Example of rule alert smb any any -> any any (msg: "Smb command rule"; smb.cmd: 10; sid: 1;) . More examples in documentation.

suricata-verify-pr: 733

@zer1t0 zer1t0 requested review from victorjulien, jasonish, norg and a team as code owners April 28, 2022 11:18
@zer1t0 zer1t0 mentioned this pull request Apr 28, 2022
3 tasks
@codecov
Copy link

codecov bot commented Apr 28, 2022

Codecov Report

Merging #7338 (c218349) into master (2ebb525) will decrease coverage by 1.92%.
The diff coverage is 77.27%.

❗ Current head c218349 differs from pull request most recent head 1d8ec73. Consider uploading reports for the commit 1d8ec73 to get more accurate results

@@            Coverage Diff             @@
##           master    #7338      +/-   ##
==========================================
- Coverage   77.68%   75.76%   -1.93%     
==========================================
  Files         628      657      +29     
  Lines      185657   190107    +4450     
==========================================
- Hits       144232   144029     -203     
- Misses      41425    46078    +4653     
Flag Coverage Δ
fuzzcorpus 60.25% <30.00%> (+2.20%) ⬆️
suricata-verify 51.57% <82.92%> (-2.89%) ⬇️
unittests 61.01% <32.43%> (-2.03%) ⬇️

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

Copy link
Contributor

@catenacyber catenacyber left a comment

Choose a reason for hiding this comment

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

Looks fine enough for me

  • CI : ✅
  • Code : looks good, one rust question...
  • Commits segmentation : nice
  • Commit messages : ✅
  • Git ID set : looks fine for me
  • CLA : I do not have access, but looks like some commits were already merged
  • Doc update : nice
  • Redmine ticket : ok
  • Rustfmt : was not enforced
  • Tests : Suricata-verify tests look fine

Version was not rebased on latest master

src/detect-smb-cmd.c Outdated Show resolved Hide resolved

fn gen_smb1_command_names() -> HashMap<String, u16> {
let commands = [
smb1::SMB1_COMMAND_CREATE_DIRECTORY,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a more idiomatic way ?
cc @jasonish we want to iterate over all known values of an enumeration

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These code command constants are not part of an enumeration, but are the defined in the smb1 module.

On the other hand, there is no idiomatic way to iterate over values of enumeration since those couldn't be constants (https://stackoverflow.com/a/21373995)

@zer1t0
Copy link
Contributor Author

zer1t0 commented May 4, 2022

Moved to #7372

@zer1t0 zer1t0 closed this May 4, 2022
jasonish added a commit to jasonish/suricata that referenced this pull request Oct 22, 2024
Rust was using i8 as the return type, while C uses int. As of Rust
1.82, the return value is turned to garbage over the FFI boundary.

Ticket: OISF#7338
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