관리되지 않는 모든 JAR 파일 스캔
단일 폴더의 모든 JAR 파일 스캔 및 각 JAR 파일 개별적으로 스캔
모든 하위 폴더 재귀적으로 스캔
#!/bin/bash
SNYK_CLI_BINARY_NAME=snyk-cli
SNYK_CLI_BINARY_LOCATION=https://github.com/snyk/cli/releases/latest/download/
REMOTE_REPO_URL= # 여기에 원하는 Snyk UI 프로젝트 이름 삽입
detected_jars=""
undetected_jars=""
detected_count=0
undetected_count=0
[[ -z "$REMOTE_REPO_URL" ]] && { echo "REMOTE_REPO_URL이 비어 있습니다. REMOTE_REPO_URL(6행)을 입력하고 스크립트를 다시 실행하십시오." ; exit 1; }
# OS(MacOS 또는 Linux)에 특화된 Snyk 바이너리 다운로드
case "$(uname -s)" in
Darwin)
curl -L -O $SNYK_CLI_BINARY_LOCATION/snyk-macos
mv snyk-macos snyk-cli
;;
Linux)
curl -L -O $SNYK_CLI_BINARY_LOCATION/snyk-linux
mv snyk-linux snyk-cli
;;
esac
chmod +x $SNYK_CLI_BINARY_NAME
# 모든 .jar 파일을 찾기 위해 폴더를 재귀적으로 반복
# 참고: 이름에 공백이 있거나 이름에 공백이 있는 디렉토리에 포함된 파일은 ERROR가 발생합니다.
for file in $(find . -type f -name '*.jar' | uniq)
do
echo ""
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="
echo $file
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="
# 각 .jar에 대해 Snyk 모니터 실행
if (./$SNYK_CLI_BINARY_NAME monitor --scan-unmanaged --file=$file --project-name=$file --remote-repo-url=$REMOTE_REPO_URL) then
detected_jars+=$file'\n'
let detected_count++
else
undetected_jars+=$file'\n'
let undetected_count++
fi
done
# 콘솔에 메트릭 출력
echo ""
echo ""
echo ""
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="
echo "감지된 jar ($detected_count) - 전이 종속성 포함 안 함:"
echo ""
if [ ${detected_count} -gt 0 ]; then
printf "${detected_jars}"
fi
echo ""
echo ""
echo ""
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="
echo "감지되지 않은 jar ($undetected_count) - Maven Central에서 찾을 수 없음:"
echo ""
if [ ${undetected_count} -gt 0 ]; then
printf "${undetected_jars}"
fi
Last updated