wenjin272 commented on code in PR #996:
URL: https://github.com/apache/flink-agents/pull/996#discussion_r3783511967
##########
tools/check-license.sh:
##########
@@ -20,41 +20,83 @@
# NOTE: This script is adapted from the Apache Spark project.
-acquire_rat_jar () {
+validate_rat_jar() {
+ local jar_cmd
+
+ if [ -n "${JAVA_HOME:-}" ] && [ -x "$JAVA_HOME/bin/jar" ]; then
+ jar_cmd="$JAVA_HOME/bin/jar"
+ elif command -v jar >/dev/null 2>&1; then
+ jar_cmd="$(command -v jar)"
+ elif command -v unzip >/dev/null 2>&1; then
+ unzip -tq "$JAR" >/dev/null 2>&1
+ return $?
+ else
+ printf "Cannot validate Apache RAT: install a JDK with 'jar' or install
'unzip'.\n" >&2
+ return 2
+ fi
-
URL="https://repo.maven.apache.org/maven2/org/apache/rat/apache-rat/${RAT_VERSION}/apache-rat-${RAT_VERSION}.jar"
+ "$jar_cmd" tf "$JAR" >/dev/null 2>&1
Review Comment:
Could we avoid propagating the raw validator exit code here? unzip -tq may
return 2 for a corrupt archive, while the caller reserves 2 to mean that no
validation tool is available. As a result, a corrupt cached RAT JAR can be
misclassified as unverifiable and kept for use. Please normalize any non-zero
exit code from an invoked unzip or jar command to validation failure, and
return 2 only when neither validator is available. It would also be useful to
add a regression test where unzip exits with 2.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]