mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 01:47:35 -02:30
monkey-patch _digest for fips
This commit is contained in:
@@ -21,6 +21,32 @@ except ImportError: # pragma: no cover
|
|||||||
MODE = 'production'
|
MODE = 'production'
|
||||||
|
|
||||||
|
|
||||||
|
import hashlib
|
||||||
|
from django.utils.encoding import force_bytes
|
||||||
|
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
|
||||||
|
from django.db.backends.base import schema
|
||||||
|
|
||||||
|
class FipsBaseDatabaseSchemaEditor(BaseDatabaseSchemaEditor):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _digest(cls, *args):
|
||||||
|
"""
|
||||||
|
Generates a 32-bit digest of a set of arguments that can be used to
|
||||||
|
shorten identifying names.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
h = hashlib.md5()
|
||||||
|
except ValueError:
|
||||||
|
h = hashlib.md5(usedforsecurity=False)
|
||||||
|
for arg in args:
|
||||||
|
h.update(force_bytes(arg))
|
||||||
|
return h.hexdigest()[:8]
|
||||||
|
|
||||||
|
schema.BaseDatabaseSchemaEditor = FipsBaseDatabaseSchemaEditor
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def find_commands(management_dir):
|
def find_commands(management_dir):
|
||||||
# Modified version of function from django/core/management/__init__.py.
|
# Modified version of function from django/core/management/__init__.py.
|
||||||
command_dir = os.path.join(management_dir, 'commands')
|
command_dir = os.path.join(management_dir, 'commands')
|
||||||
|
|||||||
Reference in New Issue
Block a user