Skip to content

Commit

Permalink
Improve jmespath expression.
Browse files Browse the repository at this point in the history
Signed-off-by: Caroline Russell <caroline@appthreat.dev>
  • Loading branch information
cerrussell committed Mar 12, 2024
1 parent 750e9e9 commit 5d4059d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions atom_tools/lib/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ def _identify_target_line_nums(self, methods):
if not file_names:
return
conditional = [f'fileName==`{json.dumps(i)}`' for i in file_names]
conditional = 'objectSlices[?' + ' || '.join(conditional) + (
'].{file_name: fileName, methods: usages[?targetObj.resolvedMethod].targetObj[].{'
'resolved_method: resolvedMethod, line_number: lineNumber}}')
conditional = '*[?' + ' || '.join(conditional) + (
'][].{file_name: fileName, methods: usages[].targetObj[].{resolved_method: '
'resolvedMethod || callName || code || name, line_number: lineNumber}}')
pattern = jmespath.compile(conditional)
result = pattern.search(self.usages.content)
result = {i['file_name']: i['methods'] for i in result if i['methods']}
Expand Down

0 comments on commit 5d4059d

Please sign in to comment.