I'm creating a new script. I would like to implement a way to verify this script. So I'm using those commands to check the content of the file.
lang-bash
remote_file="$(curl -m2 -s "$1")"
checksum_remote="$(echo "$remote_file" | sha256sum | cut -d ' ' -f1)"
checksum_current="$(sha256sum < "$COMMAND_NAME" | cut -d ' ' -f1)"
But after further developments I realize that I could use my script with the command curl -s $SCRIPT_URL | bash
. In this case my check [ "$checksum_remote" != "$checksum_current" ]
always succeed as the $COMMAND_NAME
is bash
and not the content of my script.
Is anyone know how to retrieve the whole source code with the bash script itself when we are using pipe execution?
Asked by olive007
(131 rep)
Nov 20, 2023, 03:15 PM