Skip to content

Commit

Permalink
code review feedback: use tools/convert_to_ast.py
Browse files Browse the repository at this point in the history
  • Loading branch information
tarilabs committed Jun 25, 2023
1 parent 0b23b25 commit 324f2de
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/asts/test_squaredaccessor_cases_ast.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
- RuleSet:
hosts:
- all
name: Test squared accessor
rules:
- Rule:
actions:
- Action:
action: debug
action_args:
msg: 'Testcase #1 passes'
condition:
AllCondition:
- EqualsExpression:
lhs:
Event: asd["x"][1][2].a["b"]
rhs:
Float: 3.1415
enabled: true
name: 'r1 squared accessor'
sources:
- EventSource:
name: generic
source_args:
payload:
- asd:
x:
- 0
- - 0
- 0
- a:
b: 3.1415
id: 'Testcase #1'
source_filters: []
source_name: generic
40 changes: 40 additions & 0 deletions tests/asts/test_squaredaccessor_selectattr_cases_ast.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
- RuleSet:
hosts:
- all
name: Test squared accessor with selectattr operator
rules:
- Rule:
actions:
- Action:
action: debug
action_args:
msg: Output for testcase
condition:
AllCondition:
- SelectAttrExpression:
lhs:
Event: asd["x"][1][2].a
rhs:
key:
String: b
operator:
String: ==
value:
Float: 3.1415
enabled: true
name: r1 selectattr and squared accessor interaction
sources:
- EventSource:
name: generic
source_args:
payload:
- asd:
x:
- 0
- - 0
- 0
- a:
b: 3.1415
id: 'Testcase #1'
source_filters: []
source_name: generic
2 changes: 2 additions & 0 deletions tests/test_ruleset.py
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,8 @@ def test_assert_event_string_search():
"asts/test_select_with_same_event_ast.yml",
"asts/test_self_referential_ast.yml",
"asts/test_delayed_comparison_ast.yml",
"asts/test_squaredaccessor_cases_ast.yml",
"asts/test_squaredaccessor_selectattr_cases_ast.yml",
],
)
def test_integrated(rulebook):
Expand Down

0 comments on commit 324f2de

Please sign in to comment.