#!/bin/bash
#####
#
# +===================================================+
# | © 2019 Privex Inc. |
# | https://www.privex.io |
# +===================================================+
# | |
# | JS File Integrity Generator |
# | Designed for use by CDNs |
# | |
# | License: X11/MIT |
# | |
# | Core Developer(s): |
# | |
# | (+) Chris (@someguy123) [Privex] |
# | |
# +===================================================+
#
#####
# Usage:
#
# - Place this bash file inside a folder which contains JS files (even in sub-folders)
# - Mark it executable with `chmod +x integrity_gen.sh`
# - Run it with `./integrity_gen.sh > integrity.txt` (saves output to integrity.txt)
#
# directory where the script is located, so we can source files regardless of where PWD is
export DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
EXCLUDE_PATHS=(
'lib/semanticui/Semantic-UI'
'lib/semanticui/2.4.2/components'
'lib/eosjs/.eosjs'
'lib/clipboard/src'
'lib/scatter-js/.scatter-js'
'lib/simple-jsonrpc/.src'
'lib/simple-jsonrpc/.privex-src'
'lib/simplemde/.simplemde'
'lib/highlightjs/.highlightjs'
)
# Base URL (generally with https) that your CDN is located at, for generating script tag examples
# Should NOT end with a slash.
: ${CDN_URL='https://cdn.privex.io'}
export CDN_URL
echo "
#####
#
# +===================================================+
# | © 2019 Privex Inc. |
# | https://www.privex.io |
# +===================================================+
# | |
# | HTML Asset File Integrity Generator |
# | Designed for use by CDNs |
# | |
# | License: X11/MIT |
# | |
# | Core Developer(s): |
# | |
# | (+) Chris (@someguy123) [Privex] |
# | |
# +===================================================+
#
#####
"
echo "This is a list of .js files found in this folder, followed by their SHA384 sum"
echo "The list has been generated by Privex Inc's (https://www.privex.io) integrity checking script, which can be found here:"
echo
echo "Integrity Checker Bash Script: https://cdn.privex.io/integrity_gen.sh"
echo
echo "You can use these sums inside of script tags to help prevent the risk of tampering, however it will cause updates to break your site."
echo "Example usage:"
echo
echo -e "\t \n"
echo -e "To force browsers to check the integrity of all script files, set the following CSP:\n"
echo -e "\t Content-Security-Policy: require-sri-for script;\n"
echo -e "To force browsers to check the integrity of all CSS (style) files, set the following CSP:\n"
echo -e "\t Content-Security-Policy: require-sri-for style;\n"
echo -e "This integrity list was last updated at: $(date)\n"
echo "
#######################################################
Below this notice, you will find (in order):
- sha384 base64 hashes for most JS files on this CDN (some spammy source ones generally only used for compilation may be excluded)
- sha384 base64 hashes for most CSS files on this CDN (some spammy source ones generally only used for compilation may be excluded)
- A list of \n"
done
} | sort | tr -s "\n"
echo -e "\n----------- Link Tags -----------\n"
{
for i in "${!CSS_HASHES[@]}"; do
echo -e "\n"
done
} | sort | tr -s "\n"
echo