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

Extend exists operator to support key paths and negation #334

Merged
merged 11 commits into from
Sep 18, 2024

Conversation

Anilm3
Copy link
Collaborator

@Anilm3 Anilm3 commented Aug 15, 2024

This PR adds support for asserting the presence of key paths when using the exists operator, such as through the following example:

  - id: 2
    name: rule2-exists-kp
    tags:
      type: flow
      category: category
    conditions:
      - operator: exists
        parameters:
          inputs:
            - address: input-2
              key_path: ["path"]

In addition, the !exists operator has also been introduced. Since addresses are provided in stages, it's not currently possible to safely assert the absence of an address, hence the operator can only be used with key paths, and limited to a single address, for example:

  - id: 2
    name: rule2-not-exists-kp
    tags:
      type: flow
      category: category
    conditions:
      - operator: "!exists"
        parameters:
          inputs:
            - address: input-2
              key_path: ["path"]

@codecov-commenter
Copy link

codecov-commenter commented Aug 15, 2024

Codecov Report

Attention: Patch coverage is 87.75510% with 6 lines in your changes missing coverage. Please review.

Project coverage is 84.61%. Comparing base (aeca2d0) to head (a5d8f5d).

Files with missing lines Patch % Lines
src/condition/exists.cpp 85.00% 3 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #334      +/-   ##
==========================================
+ Coverage   84.56%   84.61%   +0.05%     
==========================================
  Files         147      148       +1     
  Lines        7037     7080      +43     
  Branches     3252     3271      +19     
==========================================
+ Hits         5951     5991      +40     
- Misses        409      411       +2     
- Partials      677      678       +1     
Flag Coverage Δ
waf_test 84.61% <87.75%> (+0.05%) ⬆️

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.

@pr-commenter
Copy link

pr-commenter bot commented Aug 15, 2024

Benchmarks

Benchmark execution time: 2024-09-13 16:46:06

Comparing candidate commit e602c9a in PR branch anilm3/negated_exists with baseline commit aeca2d0 in branch master.

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

scenario:global-benchmark.random

  • 🟩 execution_time [-14.304ms; -14.239ms] or [-4.940%; -4.918%]

@Anilm3 Anilm3 marked this pull request as ready for review August 16, 2024 10:56
@Anilm3 Anilm3 requested a review from a team as a code owner August 16, 2024 10:56
src/condition/exists.cpp Show resolved Hide resolved
Copy link
Contributor

@cataphract cataphract left a comment

Choose a reason for hiding this comment

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

Looks good, you can mayb

src/condition/exists.cpp Outdated Show resolved Hide resolved
@Anilm3 Anilm3 merged commit 749b4fd into master Sep 18, 2024
50 checks passed
@Anilm3 Anilm3 deleted the anilm3/negated_exists branch September 18, 2024 16:06
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.

5 participants