Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions Index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Index Alphabetical

**91** cheat sheets available.
**94** cheat sheets available.

*Icons beside the cheat sheet name indicate in which language(s) code snippet(s) are provided.*

Expand All @@ -24,6 +24,8 @@

## B

[Browser Extension Vulnerabilities Cheat Sheet](cheatsheets/Browser_Extension_Vulnerabilities_Cheat_Sheet.md)

[Bean Validation Cheat Sheet](cheatsheets/Bean_Validation_Cheat_Sheet.md) ![Java](assets/Index_Java.svg) ![Xml](assets/Index_Xml.svg)

## C
Expand Down Expand Up @@ -122,10 +124,12 @@

[Laravel Cheat Sheet](cheatsheets/Laravel_Cheat_Sheet.md) ![Html](assets/Index_Html.svg) ![Php](assets/Index_Php.svg) ![Sql](assets/Index_Sql.svg) ![Bash](assets/Index_Bash.svg)

[LDAP Injection Prevention Cheat Sheet](cheatsheets/LDAP_Injection_Prevention_Cheat_Sheet.md)
[LDAP Injection Prevention Cheat Sheet](cheatsheets/LDAP_Injection_Prevention_Cheat_Sheet.md) ![Java](assets/Index_Java.svg)

[Logging Vocabulary Cheat Sheet](cheatsheets/Logging_Vocabulary_Cheat_Sheet.md)

[Legacy Application Management Cheat Sheet](cheatsheets/Legacy_Application_Management_Cheat_Sheet.md)

## M

[Microservices Security Cheat Sheet](cheatsheets/Microservices_Security_Cheat_Sheet.md)
Expand Down Expand Up @@ -192,6 +196,8 @@

[Session Management Cheat Sheet](cheatsheets/Session_Management_Cheat_Sheet.md)

[Software Supply Chain Security Cheat Sheet](cheatsheets/Software_Supply_Chain_Security_Cheat_Sheet.md)

[Secrets Management Cheat Sheet](cheatsheets/Secrets_Management_Cheat_Sheet.md)

[Symfony Cheat Sheet](cheatsheets/Symfony_Cheat_Sheet.md) ![Php](assets/Index_Php.svg) ![Bash](assets/Index_Bash.svg)
Expand All @@ -202,7 +208,7 @@

[TLS Cipher String Cheat Sheet](cheatsheets/TLS_Cipher_String_Cheat_Sheet.md)

[Transport Layer Security Cheat Sheet](cheatsheets/Transport_Layer_Security_Cheat_Sheet.md) ![Bash](assets/Index_Bash.svg)
[Transport Layer Security Cheat Sheet](cheatsheets/Transport_Layer_Security_Cheat_Sheet.md)

[Transport Layer Protection Cheat Sheet](cheatsheets/Transport_Layer_Protection_Cheat_Sheet.md)

Expand Down
296 changes: 198 additions & 98 deletions scripts/Generate_Site_mkDocs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,61 @@
# pip install mkdocs-material
# pip install pymdown-extensions

set -e # Exit on error

GENERATED_SITE=site
WORK=../generated
SITE_DIR="$WORK/site"
CHEATSHEETS_DIR="$WORK/cheatsheets"

check_dependencies() {
local deps=("mkdocs" "mkdocs-material" "pymdown-extensions")
python -c "import ${dep//-/_}" 2>/dev/null || {
echo "Missing dependency: $dep"
echo "Install with: pip install mkdocs mkdocs-material pymdown-extensions"
exit 1
}
done
}
Comment on lines +14 to +22

add_title() {
local file=$1
local title=$2

if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "1i\\
Title: $title\\
" "$file"
else
sed -i "1iTitle: $title\n" "$file"
fi
}

# Create redirect HTML page
create_redirect() {
local shortcut=$1
local target=$2
local output_file="$SITE_DIR/${shortcut}.html"

cat > "$output_file" << EOF
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="0; url=/${target}">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script>window.location.href = "/${target}";</script>
</head>
<body>
Redirecting to <a href="/${target}">${target}</a>...
</body>
</html>
EOF
}

echo "Generate a offline portable website with all the cheat sheets..."

echo "Step 1/7: Init work folder."
mkdir -p "$CHEATSHEETS_DIR"/{cheatsheets,assets}
Comment on lines +37 to +61
rm -rf $WORK 1>/dev/null 2>&1
mkdir $WORK
mkdir $WORK/cheatsheets
Expand Down Expand Up @@ -38,121 +87,172 @@ cp ../assets/WebSite_Favicon.png $WORK/custom_theme/img/apple-touch-icon-precomp

cp ./404.html $WORK/custom_theme/

add_title "$CHEATSHEETS_DIR/index.md" "Introduction"
add_title "$CHEATSHEETS_DIR/Glossary.md" "Index Alphabetical"
add_title "$CHEATSHEETS_DIR/IndexASVS.md" "Index ASVS"
add_title "$CHEATSHEETS_DIR/IndexMASVS.md" "Index MASVS"
add_title "$CHEATSHEETS_DIR/IndexProactiveControls.md" "Index Proactive Controls"
add_title "$CHEATSHEETS_DIR/IndexTopTen.md" "Index Top 10"

if [[ "$OSTYPE" == "darwin"* ]]; then
# MacOS
sed -i '' "1i\\
Title: Introduction\\
" "$WORK/cheatsheets/index.md"
sed -i '' 's/Index.md/Glossary.md/g' "$WORK/cheatsheets/Glossary.md"
sed -i '' "1i\\
Title: Index Alphabetical\\
" "$WORK/cheatsheets/Glossary.md"
sed -i '' "1i\\
Title: Index ASVS\\
" "$WORK/cheatsheets/IndexASVS.md"
sed -i '' "1i\\
Title: Index MASVS\\
" "$WORK/cheatsheets/IndexMASVS.md"
sed -i '' "1i\\
Title: Index Proactive Controls\\
" "$WORK/cheatsheets/IndexProactiveControls.md"
sed -i '' "1i\\
Title: Index Top 10\\
" "$WORK/cheatsheets/IndexTopTen.md"
sed -i '' 's/Index.md/Glossary.md/g' "$CHEATSHEETS_DIR/Glossary.md"
else
sed -i "1iTitle: Introduction\n" $WORK/cheatsheets/index.md
sed -i 's/Index.md/Glossary.md/g' $WORK/cheatsheets/Glossary.md
sed -i "1iTitle: Index Alphabetical\n" $WORK/cheatsheets/Glossary.md
sed -i "1iTitle: Index ASVS\n" $WORK/cheatsheets/IndexASVS.md
sed -i "1iTitle: Index MASVS\n" $WORK/cheatsheets/IndexMASVS.md
sed -i "1iTitle: Index Proactive Controls\n" $WORK/cheatsheets/IndexProactiveControls.md
sed -i "1iTitle: Index Top 10\n" $WORK/cheatsheets/IndexTopTen.md
sed -i 's/Index.md/Glossary.md/g' "$CHEATSHEETS_DIR/Glossary.md"
fi
Comment on lines 97 to 104

echo "Step 4/7: Inserting markdown metadata."
for fullfile in "$WORK"/cheatsheets/cheatsheets/*.md
do
filename=$(basename -- "$fullfile")
filename="${filename%_Cheat_Sheet.*}"

echo "Processing file: $fullfile - $filename"
if [[ "$OSTYPE" == "darwin"* ]]; then
# MacOS
sed -i '' "1i\\
Title: ${filename//[_]/ }\\
" "$fullfile"
else
sed -i "1iTitle: ${filename//[_]/ }\n" "$fullfile"
fi
# Add titles to cheat sheets
for file in "$CHEATSHEETS_DIR/cheatsheets"/*.md; do
filename=$(basename "$file" .md)
filename="${filename%_Cheat_Sheet}"
title="${filename//_/ }"
add_title "$file" "$title"
done

echo "Step 5/7: Generate the site."
echo "Step 4/5: Building site with MkDocs..."
echo "(This may take a few minutes for large sites...)"
cd "$WORK" || exit 1

cd $WORK || exit
python -m mkdocs build --verbose || {
echo "ERROR: MkDocs build failed!"
exit 1
}

if ! python -m mkdocs build; then
echo "Error detected during the generation of the site, generation failed!"
if [ ! -d "$SITE_DIR" ]; then
echo "ERROR: Site directory was not created!"
exit 1
fi

echo "Step 6/7: Handling redirect for files that have changed"
#Authorization_Testing_Automation.md -> Authorization_Testing_Automation_Cheat_Sheet.md
#Drone_security_sheet.html -> Drone_Security_Cheat_Sheet.html
#Injection_Prevention_Cheat_Sheet_in_Java.md -> Injection_Prevention_in_Java_Cheat_Sheet.md
#JSON_WEB_Token_Cheat_Sheet_for_Java.md -> JSON_WEB_Token_for_Java_Cheat_Sheet.md
#Ruby_on_Rails_Cheatsheet.md -> Ruby_on_Rails_Cheat_Sheet.md
#Nodejs_security_cheat_sheet.html -> Nodejs_security_Cheat_Sheet.html

if [[ "$OSTYPE" == "darwin"* ]]; then
# MacOS
sed -i '' "1i\\
---\\
redirect_from: \"/cheatsheets/Authorization_Testing_Automation.html\"\\
---\\
" "$WORK/$GENERATED_SITE/cheatsheets/Authorization_Testing_Automation_Cheat_Sheet.html"
sed -i '' "1i\\
---\\
redirect_from: \"/cheatsheets/Drone_security_sheet.html\"\\
---\\
" "$WORK/$GENERATED_SITE/cheatsheets/Drone_Security_Cheat_Sheet.html"
sed -i '' "1i\\
---\\
redirect_from: \"/cheatsheets/Injection_Prevention_Cheat_Sheet_in_Java.html\"\\
---\\
" "$WORK/$GENERATED_SITE/cheatsheets/Injection_Prevention_in_Java_Cheat_Sheet.html"
sed -i '' "1i\\
---\\
redirect_from: \"/cheatsheets/JSON_Web_Token_Cheat_Sheet_for_Java.html\"\\
---\\
" "$WORK/$GENERATED_SITE/cheatsheets/JSON_Web_Token_for_Java_Cheat_Sheet.html"
sed -i '' "1i\\
---\\
redirect_from: \"/cheatsheets/Ruby_on_Rails_Cheatsheet.html\"\\
---\\
" "$WORK/$GENERATED_SITE/cheatsheets/Ruby_on_Rails_Cheat_Sheet.html"
sed -i '' "1i\\
---\\
redirect_from: \"/cheatsheets/Nodejs_security_cheat_sheet.html\"\\
---\\
" "$WORK/$GENERATED_SITE/cheatsheets/Nodejs_Security_Cheat_Sheet.html"
sed -i '' "1i\\
---\\
redirect_from: \"/cheatsheets/Application_Logging_Vocabulary_Cheat_Sheet.html\"\\
---\\
" "$WORK/$GENERATED_SITE/cheatsheets/Logging_Vocabulary_Cheat_Sheet.html"
echo "Site built successfully"

cat > "$SITE_DIR/.htaccess" << 'EOF'
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html [L]
EOF

echo "Step 5/7: Generating URL shortcuts..."
if [ -f "../scripts/redirects.yml" ]; then
python3 << PYTHON_SCRIPT
import yaml
import os
import shutil

site_dir = "$SITE_DIR"
Comment on lines +116 to +145

def create_redirect(shortcut, target, site_dir):
# Create a directory for the shortcut to allow /shortcut/ access
target_path = os.path.join(site_dir, shortcut)

# If a file exists with the shortcut name, remove it to avoid conflicts
if os.path.isfile(target_path):
os.remove(target_path)

os.makedirs(target_path, exist_ok=True)

# The 'index.html' inside the folder makes the clean URL work
output_file = os.path.join(target_path, "index.html")
target_url = target if target.startswith('http') else f'/{target}'

html = f"""<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="0; url={target_url}">
<link rel="canonical" href="{target_url}">
<script>window.location.href = "{target_url}";</script>
Comment on lines +131 to +167
<title>Redirecting...</title>
</head>
<body>
Redirecting to <a href="{target_url}">{target_url}</a>...
</body>
</html>"""

with open(output_file, 'w') as f:
f.write(html)
print(f"{shortcut} → {target}")

# Load redirects
try:
with open('../scripts/redirects.yml', 'r') as f:
redirects = yaml.safe_load(f)
if redirects:
for shortcut, target in redirects.items():
# Clean the shortcut name (remove leading slashes or .html)
clean_shortcut = shortcut.lstrip('/').replace('.html', '')
create_redirect(clean_shortcut, target, site_dir)
print(f"Created {len(redirects)} clean URL redirects")
else:
print("No redirects found in redirects.yml")
except Exception as e:
print(f"Error processing redirects: {e}")
import sys
sys.exit(1)
PYTHON_SCRIPT
else
sed -i "1i---\nredirect_from: \"/cheatsheets/Authorization_Testing_Automation.html\"\n---\n" $WORK/$GENERATED_SITE/cheatsheets/Authorization_Testing_Automation_Cheat_Sheet.html
sed -i "1i---\nredirect_from: \"/cheatsheets/Drone_security_sheet.html\"\n---\n" $WORK/$GENERATED_SITE/cheatsheets/Drone_Security_Cheat_Sheet.html
sed -i "1i---\nredirect_from: \"/cheatsheets/Injection_Prevention_Cheat_Sheet_in_Java.html\"\n---\n" $WORK/$GENERATED_SITE/cheatsheets/Injection_Prevention_in_Java_Cheat_Sheet.html
sed -i "1i---\nredirect_from: \"/cheatsheets/JSON_Web_Token_Cheat_Sheet_for_Java.html\"\n---\n" $WORK/$GENERATED_SITE/cheatsheets/JSON_Web_Token_for_Java_Cheat_Sheet.html
sed -i "1i---\nredirect_from: \"/cheatsheets/Ruby_on_Rails_Cheatsheet.html\"\n---\n" $WORK/$GENERATED_SITE/cheatsheets/Ruby_on_Rails_Cheat_Sheet.html
sed -i "1i---\nredirect_from: \"/cheatsheets/Nodejs_security_cheat_sheet.html\"\n---\n" $WORK/$GENERATED_SITE/cheatsheets/Nodejs_Security_Cheat_Sheet.html
sed -i "1i---\nredirect_from: \"/cheatsheets/Application_Logging_Vocabulary_Cheat_Sheet.html\"\n---\n" $WORK/$GENERATED_SITE/cheatsheets/Logging_Vocabulary_Cheat_Sheet.html
echo "Warning: redirects.yml not found, skipping redirects"
fi

# echo "Step 6/7: Handling redirect for files that have changed"
# #Authorization_Testing_Automation.md -> Authorization_Testing_Automation_Cheat_Sheet.md
# #Drone_security_sheet.html -> Drone_Security_Cheat_Sheet.html
# #Injection_Prevention_Cheat_Sheet_in_Java.md -> Injection_Prevention_in_Java_Cheat_Sheet.md
# #JSON_WEB_Token_Cheat_Sheet_for_Java.md -> JSON_WEB_Token_for_Java_Cheat_Sheet.md
# #Ruby_on_Rails_Cheatsheet.md -> Ruby_on_Rails_Cheat_Sheet.md
# #Nodejs_security_cheat_sheet.html -> Nodejs_security_Cheat_Sheet.html

# if [[ "$OSTYPE" == "darwin"* ]]; then
# # MacOS
# sed -i '' "1i\\
# ---\\
# redirect_from: \"/cheatsheets/Authorization_Testing_Automation.html\"\\
# ---\\
# " "$WORK/$GENERATED_SITE/cheatsheets/Authorization_Testing_Automation_Cheat_Sheet.html"
# sed -i '' "1i\\
# ---\\
# redirect_from: \"/cheatsheets/Drone_security_sheet.html\"\\
# ---\\
# " "$WORK/$GENERATED_SITE/cheatsheets/Drone_Security_Cheat_Sheet.html"
# sed -i '' "1i\\
# ---\\
# redirect_from: \"/cheatsheets/Injection_Prevention_Cheat_Sheet_in_Java.html\"\\
# ---\\
# " "$WORK/$GENERATED_SITE/cheatsheets/Injection_Prevention_in_Java_Cheat_Sheet.html"
# sed -i '' "1i\\
# ---\\
# redirect_from: \"/cheatsheets/JSON_Web_Token_Cheat_Sheet_for_Java.html\"\\
# ---\\
# " "$WORK/$GENERATED_SITE/cheatsheets/JSON_Web_Token_for_Java_Cheat_Sheet.html"
# sed -i '' "1i\\
# ---\\
# redirect_from: \"/cheatsheets/Ruby_on_Rails_Cheatsheet.html\"\\
# ---\\
# " "$WORK/$GENERATED_SITE/cheatsheets/Ruby_on_Rails_Cheat_Sheet.html"
# sed -i '' "1i\\
# ---\\
# redirect_from: \"/cheatsheets/Nodejs_security_cheat_sheet.html\"\\
# ---\\
# " "$WORK/$GENERATED_SITE/cheatsheets/Nodejs_Security_Cheat_Sheet.html"
# sed -i '' "1i\\
# ---\\
# redirect_from: \"/cheatsheets/Application_Logging_Vocabulary_Cheat_Sheet.html\"\\
# ---\\
# " "$WORK/$GENERATED_SITE/cheatsheets/Logging_Vocabulary_Cheat_Sheet.html"
# else
# sed -i "1i---\nredirect_from: \"/cheatsheets/Authorization_Testing_Automation.html\"\n---\n" $WORK/$GENERATED_SITE/cheatsheets/Authorization_Testing_Automation_Cheat_Sheet.html
# sed -i "1i---\nredirect_from: \"/cheatsheets/Drone_security_sheet.html\"\n---\n" $WORK/$GENERATED_SITE/cheatsheets/Drone_Security_Cheat_Sheet.html
# sed -i "1i---\nredirect_from: \"/cheatsheets/Injection_Prevention_Cheat_Sheet_in_Java.html\"\n---\n" $WORK/$GENERATED_SITE/cheatsheets/Injection_Prevention_in_Java_Cheat_Sheet.html
# sed -i "1i---\nredirect_from: \"/cheatsheets/JSON_Web_Token_Cheat_Sheet_for_Java.html\"\n---\n" $WORK/$GENERATED_SITE/cheatsheets/JSON_Web_Token_for_Java_Cheat_Sheet.html
# sed -i "1i---\nredirect_from: \"/cheatsheets/Ruby_on_Rails_Cheatsheet.html\"\n---\n" $WORK/$GENERATED_SITE/cheatsheets/Ruby_on_Rails_Cheat_Sheet.html
# sed -i "1i---\nredirect_from: \"/cheatsheets/Nodejs_security_cheat_sheet.html\"\n---\n" $WORK/$GENERATED_SITE/cheatsheets/Nodejs_Security_Cheat_Sheet.html
# sed -i "1i---\nredirect_from: \"/cheatsheets/Application_Logging_Vocabulary_Cheat_Sheet.html\"\n---\n" $WORK/$GENERATED_SITE/cheatsheets/Logging_Vocabulary_Cheat_Sheet.html
# fi

echo "Step 7/7 Cleanup."
rm -rf cheatsheets
rm -rf custom_theme
rm mkdocs.yml
rm -rf cheatsheets custom_theme mkdocs.yml

echo "Generation finished to the folder: $WORK/$GENERATED_SITE"
echo "Generation finished to the folder: $SITE_DIR"
Loading
Loading