Skip to content

Commit

Permalink
Reset the tracking of syscalls found per file
Browse files Browse the repository at this point in the history
When running a playbook profile, they were accumulating over the entire
run.
  • Loading branch information
yuumasato committed Aug 18, 2021
1 parent 6dd2a03 commit fe88dfb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions shared/macros-ansible.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -422,15 +422,20 @@ The macro requires following parameters:
register: find_command
loop: '{{ (syscall_grouping + syscalls) | unique }}'

- name: Reset syscalls found per file
set_fact:
syscalls_per_file: {}
found_paths_dict: {}

- name: Declare syscalls found per file
set_fact: syscalls_per_file="{{ syscalls_per_file | default({}) | combine( {item.files[0].path :[item.item]+(syscalls_per_file | default({})).get(item.files[0].path, []) } ) }}"
set_fact: syscalls_per_file="{{ syscalls_per_file | combine( {item.files[0].path :[item.item] + syscalls_per_file.get(item.files[0].path, []) } ) }}"
loop: "{{ find_command.results | selectattr('matched') | list}}"

- name: Declare files where syscalls where found
set_fact: found_paths="{{ find_command.results | map(attribute='files') | flatten | map(attribute='path') | list }}"

- name: Count occurrences of syscalls in paths
set_fact: found_paths_dict="{{ found_paths_dict | default({}) | combine({ item:1+(found_paths_dict | default({})).get(item, 0) }) }}"
set_fact: found_paths_dict="{{ found_paths_dict | combine({ item:1+found_paths_dict.get(item, 0) }) }}"
loop: "{{ find_command.results | map(attribute='files') | flatten | map(attribute='path') | list }}"

- name: Get path with most syscalls
Expand Down

0 comments on commit fe88dfb

Please sign in to comment.