mirror of https://github.com/ansible/ansible.git
Filter BLACKLIST_EXTS in PluginLoader (#69029)
Change: Rather than hardcoding .pyo and .pyc, filter on all BLACKLIST_EXTS in the non-legacy logic of PluginLoader (_find_fq_plugin). The two harcoded extensions are part of BLACKLIST_EXTS already and this simply adds the rest of the blacklisted extensions to the check. In addition, check .endswith() instead of an exact match of the suffix, like everywhere else that uses BLACKLIST_EXTS. This allows for blacklisting, for example, emacs's backup files which can appear after any extension, leading to things like `foo.py~`. Test Plan: Ran `ansible-playbook` against a collection where a `foo.py~` module was getting executed instead of `foo.py` which also appeared in the same directory. `foo.py~` is no longer executed. Tickets: Fixes #22268 Refs #27235 Signed-off-by: Rick Elrod <rick@elrod.me>pull/69115/head
parent
da98fc267a
commit
cace616aab
@ -0,0 +1,2 @@
|
||||
minor_changes:
|
||||
- plugin loader - Add MODULE_IGNORE_EXTS config option to skip over certain extensions when looking for script and binary modules.
|
@ -0,0 +1,3 @@
|
||||
# Intentionally blank, and intentionally attempting to shadow
|
||||
# uses_leaf_mu_flat_import.py. MODULE_IGNORE_EXTS should prevent this file
|
||||
# from ever being loaded.
|
@ -0,0 +1,3 @@
|
||||
# Intentionally blank, and intentionally attempting to shadow
|
||||
# uses_leaf_mu_flat_import.py. MODULE_IGNORE_EXTS should prevent this file
|
||||
# from ever being loaded.
|
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/python
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import json
|
||||
|
||||
|
||||
def main():
|
||||
print(json.dumps(dict(changed=False, location='a.ini')))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/python
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import json
|
||||
|
||||
|
||||
def main():
|
||||
print(json.dumps(dict(changed=False, location='a.py')))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/python
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import json
|
||||
|
||||
|
||||
def main():
|
||||
print(json.dumps(dict(changed=False, location='ping.ini')))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -0,0 +1,16 @@
|
||||
- hosts: testhost
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- name: Use ping from library path
|
||||
ping:
|
||||
register: result
|
||||
|
||||
- name: Use a from library path
|
||||
a:
|
||||
register: a_res
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- '"location" in result'
|
||||
- 'result["location"] == "library"'
|
||||
- 'a_res["location"] == "a.py"'
|
@ -0,0 +1,18 @@
|
||||
- hosts: testhost
|
||||
gather_facts: no
|
||||
roles:
|
||||
- foo
|
||||
tasks:
|
||||
- name: Use ping from role
|
||||
ping:
|
||||
register: result
|
||||
|
||||
- name: Use from role
|
||||
a:
|
||||
register: a_res
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- '"location" in result'
|
||||
- 'result["location"] == "role: foo"'
|
||||
- 'a_res["location"] == "role: foo, a.py"'
|
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/python
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import json
|
||||
|
||||
|
||||
def main():
|
||||
print(json.dumps(dict(changed=False, location='role: foo, a.ini')))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/python
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import json
|
||||
|
||||
|
||||
def main():
|
||||
print(json.dumps(dict(changed=False, location='role: foo, a.py')))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/python
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import json
|
||||
|
||||
|
||||
def main():
|
||||
print(json.dumps(dict(changed=False, location='role: foo, ping.ini')))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in New Issue