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

MySQL: parser v2 #12541

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Conversation

QianKaiLin
Copy link

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

Contribution style:

Our Contribution agreements:

Changes (if applicable):

  • I have updated the User Guide (in doc/userguide/) to reflect the changes made
  • I have updated the JSON schema (in etc/schema.json) to reflect all logging changes
    (including schema descriptions)

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

Describe changes:

  • fix mysql parser bug.
  • fix mysql logger bug.
  • add mysql detection keywords mysql.command and mysql.rows
  • add SV tests.
  • upgrade User Guide document and Upgrade document.

SV_BRANCH=OISF/suricata-verify#2067

Copy link
Member

@jasonish jasonish left a comment

Choose a reason for hiding this comment

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

Just a quick scan on some naming and visibility of methods that we're trying to stick to with new code, and update existing code as needed. Probably more review comments to come though.

"description": "Mysql server version"
},
"tls": {
"type": "boolean"
Copy link
Member

Choose a reason for hiding this comment

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

Description please.

"description": "sql query statement or some utility commands like ping."
},
"affected_rows": {
"type": "integer"
Copy link
Member

Choose a reason for hiding this comment

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

Description please.

Comment on lines +33 to +34
#[no_mangle]
unsafe extern "C" fn SCMysqlCommandSetup(
Copy link
Member

Choose a reason for hiding this comment

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

No pub, and only used by function pointer, this doesn't have to be #[no_mangle], and can follow Rust naming convention.

}

#[no_mangle]
unsafe extern "C" fn SCMysqlGetCommand(
Copy link
Member

Choose a reason for hiding this comment

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

Again, no pub, probably doesn't need no_mangle.

);
}

#[no_mangle]
Copy link
Member

Choose a reason for hiding this comment

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

Again, no_mangle not needed.

Comment on lines +1154 to +1155
#[no_mangle]
pub unsafe extern "C" fn rs_mysql_state_get_tx(
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't need no_mangle and pub. Also drop the rs_ prefix.

Comment on lines +1169 to +1170
#[no_mangle]
pub unsafe extern "C" fn rs_mysql_tx_get_alstate_progress(
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't need no_mangle and pub. Also drop the rs_ prefix.

const PARSER_NAME: &[u8] = b"mysql\0";

#[no_mangle]
pub unsafe extern "C" fn rs_mysql_register_parser() {
Copy link
Member

Choose a reason for hiding this comment

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

Naming, SCMysqlRegisterParser.

use suricata_derive::EnumStringU8;

#[allow(dead_code)]
pub const CLIENT_LONG_PASSWORD: u32 = BIT_U32!(0);
Copy link
Member

Choose a reason for hiding this comment

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

Do these need to be pub?

payload: &'a mut [u8],
}

impl<'a> Drop for MysqlPacket<'a> {
Copy link
Member

Choose a reason for hiding this comment

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

Clippy says the lifetimes are not needed here.

Copy link

github-actions bot commented Feb 7, 2025

NOTE: This PR may contain new authors.

Copy link

codecov bot commented Feb 7, 2025

Codecov Report

Attention: Patch coverage is 57.86082% with 981 lines in your changes missing coverage. Please review.

Project coverage is 80.51%. Comparing base (d4330ef) to head (25b613b).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12541      +/-   ##
==========================================
- Coverage   80.68%   80.51%   -0.18%     
==========================================
  Files         925      929       +4     
  Lines      258914   261234    +2320     
==========================================
+ Hits       208914   210329    +1415     
- Misses      50000    50905     +905     
Flag Coverage Δ
fuzzcorpus 56.19% <4.45%> (-0.64%) ⬇️
livemode 19.22% <4.54%> (-0.19%) ⬇️
pcap 43.66% <4.17%> (-0.54%) ⬇️
suricata-verify 63.27% <55.11%> (-0.12%) ⬇️
unittests 58.11% <29.13%> (-0.27%) ⬇️

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

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