Skip to content

Conversation

@thorhs
Copy link

@thorhs thorhs commented Dec 13, 2021

Added .ear and .zip to types of file to test.

Also added an exit code if a match is found.
Exit codes:

  • 0: No match found
  • 1: Error
  • 2: Error parsing flags
  • 3: Match was found

This enables integration with Ansible, e.g:

--- - hosts: all become: true tasks: - name: Copy log4shelldetect to remote host copy: src: /home/XXX/log4shelldetect dest: /tmp/log4shelldetect mode: "0555" - name: Search for log4j shell: cmd: "/tmp/log4shelldetect -mode=list /" register: log4shelldetect changed_when: log4shelldetect.rc == 3 failed_when: log4shelldetect.rc == 1 or log4shelldetect.rc == 2 - name: copy: dest: "/home/XXX/log4shelldetect.out/{{ ansible_fqdn }}" content: "{{ log4shelldetect.stdout }}\n" when: log4shelldetect.rc == 3 delegate_to: localhost
I added .ear and .zip to types of file to test. Also added an exit code if a match is found. Exit codes: * 0: No match found * 1: Error * 2: Error parsing flags * 3: Match was found This enables integration with Ansible, e.g: ```yaml --- - hosts: all become: true tasks: - name: Copy log4shelldetect to remote host copy: src: /home/XXX/log4shelldetect dest: /tmp/log4shelldetect mode: "0555" - name: Search for log4j shell: cmd: "/tmp/log4shelldetect -mode=list /" register: log4shelldetect changed_when: log4shelldetect.rc == 3 failed_when: log4shelldetect.rc == 1 or log4shelldetect.rc == 2 - name: copy: dest: "/home/XXX/log4shelldetect.out/{{ ansible_fqdn }}" content: "{{ log4shelldetect.stdout }}\n" when: log4shelldetect.rc == 3 delegate_to: localhost ```
@thorhs
Copy link
Author

thorhs commented Dec 13, 2021

Sorry for this being two changes in one commit, don't have time to split them up.

@Turegano
Copy link

you are terrific!!!

@1lann
Copy link
Owner

1lann commented Dec 13, 2021

Thanks for your PR! I've adjusted it a bit to fix a race condition, return correct exit codes as you specified, and to put .zip scanning behind a flag as it can be potentially significantly slower.

@1lann 1lann merged commit 3b812e6 into 1lann:master Dec 13, 2021
@1lann 1lann mentioned this pull request Dec 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants