Skip to content

Iprep feature 6857/v3#11264

Closed
victorjulien wants to merge 6 commits into
OISF:masterfrom
victorjulien:iprep-feature-6857/v3
Closed

Iprep feature 6857/v3#11264
victorjulien wants to merge 6 commits into
OISF:masterfrom
victorjulien:iprep-feature-6857/v3

Conversation

@victorjulien
Copy link
Copy Markdown
Member

SV_BRANCH=OISF/suricata-verify#1896

#11091, rebased, cleaned up and with docs added.

https://redmine.openinfosecfoundation.org/issues/6857

No need to init ptrs to NULL after SCCalloc.
Implement special "isset" and "isnotset" modes.

"isset" matches if an IP address is part of an iprep category with any
value.

It is internally implemented as ">=,0", which should always be true if
there is a value to evaluate, as valid reputation values are 0-127.

"isnotset" matches if an IP address is not part of an iprep category.

Internally it is implemented outside the uint support.

Ticket: OISF#6857.
Bring in line with new Rust code naming for FFI functions.
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 6, 2024

Codecov Report

Attention: Patch coverage is 84.65909% with 27 lines in your changes missing coverage. Please review.

Project coverage is 82.99%. Comparing base (358bc05) to head (3adfe5c).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11264      +/-   ##
==========================================
+ Coverage   79.68%   82.99%   +3.30%     
==========================================
  Files         942      942              
  Lines      249186   249487     +301     
==========================================
+ Hits       198566   207059    +8493     
+ Misses      50620    42428    -8192     
Flag Coverage Δ
fuzzcorpus 61.08% <23.00%> (-0.02%) ⬇️
livemode 18.78% <0.00%> (-0.01%) ⬇️
pcap 44.27% <0.00%> (-0.06%) ⬇️
suricata-verify 61.69% <65.00%> (?)
unittests 60.51% <78.97%> (+<0.01%) ⬆️

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

@suricata-qa
Copy link
Copy Markdown

Information:

ERROR: QA failed on SURI_TLPR1_suri_time.

field baseline test %
SURI_TLPR1_stats_chk
.uptime 642 682 106.23%

Pipeline 20984


drop ip $HOME_NET any -> any any (:example-rule-options:`iprep:src,trusted-hosts,isnotset;` sid:1;)

In this example traffic for a host w/o a trust score would be blocked.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't we use the preferred "without" form, since these are the official docs?

Copy link
Copy Markdown
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.

Thanks for the work :-)

Good enough even if I have a few nits

  • CI : 🟢
  • Code : good for me
  • Commits segmentation : ok for me
  • Commit messages : good enough for me
  • Git ID set : looks fine for me
  • CLA : you already contributed :-p
  • Doc update : ok for me
  • Redmine ticket : ok
  • Rustfmt : 🟠 some changes done like
- -    } else  {
+    } else {
  • Tests : SV ok
  • Dependencies added: none

``category``: the category short name

operator: <, >, =
``operator``: <, <=, >, >=, =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There are more

You could add a link to doc/userguide/rules/integer-keywords.rst

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

/// value matching is done use `DetectUintData` logic.
/// isset matching is done using special `DetectUintData` value ">= 0"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ok, but why not add a bool outside the DetectUintData ?

Comment thread rust/src/detect/iprep.rs
if args == 4 || args == 3 {
let cmd = if let Ok(cmd) = DetectIPRepDataCmd::from_str(values[0].trim()) {
cmd
} else {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

5 lines instead of let (i, cmd) = map_res(alpha0, DetectIPRepDataCmd::from_str)(i)?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(meaning I preferred it without separated_list1 and we could still support what you want with alt)

Comment thread rust/src/detect/iprep.rs
};
let du8 = DetectUintData::<u8> {
arg1,
arg2: 0,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we support ranges ?

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

if args == 4 {
let mode = match detect_parse_uint_mode(values[2].trim()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if let instead of match

Comment thread src/reputation.c
exit(EXIT_FAILURE);
SRepCIDRTree *cidr_ctx = de_ctx->srepCIDR_ctx;

for (i = 0; i < SREP_MAX_CATS; i++) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice, I wonder if we can remove more of these...

Copy link
Copy Markdown
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.

I meant to approve

@victorjulien victorjulien added this to the 8.0 milestone Jun 15, 2024
@victorjulien
Copy link
Copy Markdown
Member Author

Merged in #11309, thanks!

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