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

Action semantics and related improvements #277

Merged
merged 29 commits into from
Mar 28, 2024
Merged

Action semantics and related improvements #277

merged 29 commits into from
Mar 28, 2024

Conversation

Anilm3
Copy link
Collaborator

@Anilm3 Anilm3 commented Mar 14, 2024

  • Parse action definitions in order to understand the semantics of each action, which means the WAF can now natively understand the difference between blocking actions (i.e. block, redirect) and other actions.
  • Provide action definitions in ddwaf_result in map format, ensuring that only one blocking action (redirect > block) is provided. When two equivalent blocking actions are found, the first one takes precedence.
  • Support stack_trace action and generate pseudo-uuidv4 during result serialisation.
  • Add native support for monitor and extract_schema actions.
  • Allow unknown actions for compatibility reasons.

@codecov-commenter
Copy link

codecov-commenter commented Mar 14, 2024

Codecov Report

Attention: Patch coverage is 88.94231% with 23 lines in your changes are missing coverage. Please review.

Project coverage is 83.21%. Comparing base (24a89cb) to head (8ec7b52).

Files Patch % Lines
src/parser/actions_parser.cpp 85.00% 0 Missing and 6 partials ⚠️
src/event.cpp 93.33% 0 Missing and 5 partials ⚠️
src/parameter.cpp 64.28% 2 Missing and 3 partials ⚠️
src/action_mapper.cpp 91.17% 1 Missing and 2 partials ⚠️
src/ruleset_builder.cpp 78.57% 3 Missing ⚠️
src/parser/common.hpp 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #277      +/-   ##
==========================================
+ Coverage   83.09%   83.21%   +0.11%     
==========================================
  Files         115      119       +4     
  Lines        4566     4735     +169     
  Branches     2143     2253     +110     
==========================================
+ Hits         3794     3940     +146     
- Misses        300      304       +4     
- Partials      472      491      +19     
Flag Coverage Δ
waf_test 83.21% <88.94%> (+0.11%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Anilm3 Anilm3 changed the title Action semantics and improvements Action semantics and related improvements Mar 14, 2024
@pr-commenter
Copy link

pr-commenter bot commented Mar 14, 2024

Benchmarks

Benchmark execution time: 2024-03-27 16:15:54

Comparing candidate commit d5a33d8 in PR branch anilm3/actions with baseline commit 24a89cb in branch master.

Found 3 performance improvements and 1 performance regressions! Performance is the same for 15 metrics, 0 unstable metrics.

scenario:regex_match_matcher.case_insensitive_flag.random

  • 🟩 execution_time [-606.258µs; -604.775µs] or [-12.353%; -12.323%]

scenario:regex_match_matcher.case_insensitive_option.random

  • 🟩 execution_time [-597.074µs; -595.476µs] or [-12.187%; -12.154%]

scenario:regex_match_matcher.lowercase_transformer.random

  • 🟩 execution_time [-575.331µs; -574.451µs] or [-9.097%; -9.083%]

scenario:regex_match_matcher.random

  • 🟥 execution_time [+63.963µs; +65.045µs] or [+3.305%; +3.361%]

@Anilm3 Anilm3 marked this pull request as ready for review March 25, 2024 21:00
@Anilm3 Anilm3 requested a review from a team as a code owner March 25, 2024 21:00
@Anilm3 Anilm3 requested a review from estringana March 26, 2024 13:24
@Anilm3 Anilm3 requested a review from cataphract March 26, 2024 13:24
src/action_mapper.cpp Outdated Show resolved Hide resolved
src/action_mapper.cpp Outdated Show resolved Hide resolved
src/event.cpp Outdated Show resolved Hide resolved
ddwaf_object tmp;
ddwaf_object tags_map;

ddwaf_object_map(&rule_map);
Copy link
Contributor

Choose a reason for hiding this comment

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

a bit of an aside, but I think it would be better at some point having a better (i.e, more efficient and expressive) for building ddwaf objects. Maybe something like this: https://github.com/DataDog/dd-trace-cpp/blob/60eed64ebbf89e85276d31f99f222d880ef88ae4/src/datadog/remote_config.cpp#L133-L152

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Indeed, this is sorely needed, thanks for the tip.

src/event.cpp Show resolved Hide resolved
src/parser/actions_parser.cpp Outdated Show resolved Hide resolved
src/event.cpp Outdated Show resolved Hide resolved
src/event.cpp Outdated Show resolved Hide resolved
src/event.cpp Outdated Show resolved Hide resolved
src/uuid.cpp Outdated Show resolved Hide resolved
Anilm3 added 4 commits March 27, 2024 10:54
* Replace action_mapper setters with action_mapper_builder
* Simplify UUID generation
* Refactor serialisation
src/uuid.cpp Outdated Show resolved Hide resolved
@Anilm3 Anilm3 merged commit 1ba0674 into master Mar 28, 2024
34 of 35 checks passed
@Anilm3 Anilm3 deleted the anilm3/actions branch March 28, 2024 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants