Skip to content

Commit

Permalink
Tried to answer acc. to last comment
Browse files Browse the repository at this point in the history
  • Loading branch information
gauravsaini04 committed Feb 21, 2024
1 parent f6fe5d3 commit 5a69b7b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 56 deletions.
38 changes: 10 additions & 28 deletions test/python/install_python310_setuptools_vulnerability.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,40 +64,22 @@ check "which pydocstyle" bash -c "which pydocstyle | grep /usr/local/py-utils/bi
check "which pylint" bash -c "which pylint | grep /usr/local/py-utils/bin/pylint"
check "which pytest" bash -c "which pytest | grep /usr/local/py-utils/bin/pytest"
checkVulnerableDir()
checkVulnerableFile_OR_DIR()
{
DIRECTORY=$1
VERSION=$2
if [[ -d $DIRECTORY ]] ; then
echoStderr "❌ check for vulnerable setuptools version failed for python ${VERSION}."
return 1
else
echo "✅ Passed! Either the container does not have vulnerable version or vulnerable version specific directory got removed."
return 0
fi
}
checkVulnerableFile()
{
FILE=$1
VERSION=$2
if [[ -f $FILE ]] ; then
echoStderr "❌ check for vulnerable setuptools version failed for python ${VERSION}."
return 1
else
echo "✅ Passed! Either the container does not have vulnerable version or vulnerable version specific file got removed."
return 0
fi
for arg in "$@"; do
if [[ -e $arg ]]; then
echo -e "\n✅ Vulnerable:- ${arg} - exists in v3.10 as Vulnerability Patching has been skipped."
else
echo -e "\n❌ Vulnerable:- ${arg} - don't exist in v3.10 as Vulnerability Patching has not been skipped."
fi
done
}
# print setuptools
check "all files and folders containing setuptools" bash -c 'find / -name "*setuptools*"'
check "Show All Files/Folders which include setuptools" bash -c 'find / -name "*setuptools*"'
# only for 3.10
checkVulnerableDir "/usr/local/py-utils/shared/lib/python3.10/site-packages/setuptools-65.5.0.dist-info" "3.10"
checkVulnerableFile "/usr/local/lib/python3.10/ensurepip/_bundled/setuptools-65.5.0-py3-none-any.whl" "3.10"
checkVulnerableFile_OR_DIR "/usr/local/py-utils/shared/lib/python3.10/site-packages/setuptools-65.5.0.dist-info" "/usr/local/lib/python3.10/ensurepip/_bundled/setuptools-65.5.0-py3-none-any.whl"
# Function to check if a package is installed
checkPackageInstalled() {
Expand Down
38 changes: 10 additions & 28 deletions test/python/install_python311_setuptools_vulnerability.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,40 +65,22 @@ check "which pydocstyle" bash -c "which pydocstyle | grep /usr/local/py-utils/bi
check "which pylint" bash -c "which pylint | grep /usr/local/py-utils/bin/pylint"
check "which pytest" bash -c "which pytest | grep /usr/local/py-utils/bin/pytest"
checkVulnerableDir()
checkVulnerableFile_OR_DIR()
{
DIRECTORY=$1
VERSION=$2
if [[ -d $DIRECTORY ]] ; then
echoStderr "❌ check for vulnerable setuptools version failed for python ${VERSION}."
return 1
else
echo "✅ Passed! Either the container does not have vulnerable version or vulnerable version specific directory got removed."
return 0
fi
}
checkVulnerableFile()
{
FILE=$1
VERSION=$2
if [[ -f $FILE ]] ; then
echoStderr "❌ check for vulnerable setuptools version failed for python ${VERSION}."
return 1
else
echo "✅ Passed! Either the container does not have vulnerable version or vulnerable version specific file got removed."
return 0
fi
for arg in "$@"; do
if [[ -e $arg ]]; then
echo -e "\n✅ Vulnerable:- ${arg} - exists in v3.11 as Vulnerability Patching has been skipped."
else
echo -e "\n❌ Vulnerable:- ${arg} - don't exist in v3.11 as Vulnerability Patching has not been skipped."
fi
done
}
# print setuptools
check "all files and folders containing setuptools" bash -c 'find / -name "*setuptools*"'
check "Show All Files/Folders which include setuptools" bash -c 'find / -name "*setuptools*"'
# only for 3.11
checkVulnerableDir "/usr/local/py-utils/shared/lib/python3.11/site-packages/setuptools-65.5.0.dist-info" "3.11"
checkVulnerableFile "/usr/local/lib/python3.11/ensurepip/_bundled/setuptools-65.5.0-py3-none-any.whl" "3.11"
checkVulnerableFile_OR_DIR "/usr/local/py-utils/shared/lib/python3.11/site-packages/setuptools-65.5.0.dist-info" "/usr/local/lib/python3.11/ensurepip/_bundled/setuptools-65.5.0-py3-none-any.whl"
# Function to check if a package is installed
checkPackageInstalled() {
Expand Down

0 comments on commit 5a69b7b

Please sign in to comment.