mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-05 04:55:14 +00:00
ci: Add script to check for pickle usage in community (#22863)
Add script to check for pickle usage in community.
This commit is contained in:
27
libs/community/scripts/check_pickle.sh
Executable file
27
libs/community/scripts/check_pickle.sh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# This checks for usage of pickle in the package.
|
||||
#
|
||||
# Usage: ./scripts/check_pickle.sh /path/to/repository
|
||||
#
|
||||
# Check if a path argument is provided
|
||||
if [ $# -ne 1 ]; then
|
||||
echo "Usage: $0 /path/to/repository"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
repository_path="$1"
|
||||
|
||||
# Search for lines matching the pattern within the specified repository
|
||||
result=$(git -C "$repository_path" grep -E 'pickle.load\(|pickle.loads\(' | grep -v '# ignore\[pickle\]: explicit-opt-in')
|
||||
|
||||
# Check if any matching lines were found
|
||||
if [ -n "$result" ]; then
|
||||
echo "ERROR: The following lines need to be updated:"
|
||||
echo "$result"
|
||||
echo "Please avoid using pickle or cloudpickle."
|
||||
echo "If you must, then add:"
|
||||
echo "1. A security notice (scan the code for examples)"
|
||||
echo "2. Code path should be opt-in."
|
||||
exit 1
|
||||
fi
|
Reference in New Issue
Block a user