Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -120,10 +122,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 @@ -190,6 +194,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 @@ -200,7 +206,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
130 changes: 84 additions & 46 deletions scripts/Generate_Site_mkDocs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,53 +95,91 @@ if ! python -m mkdocs build; then
exit 1
fi

echo "Step 6/7: Handling redirect for files that have changed"
#Authorization_Testing_Automation.md -> Authorization_Testing_Automation_Cheat_Sheet.md
#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
echo "Step 6/7: Generate URL shortcuts for all cheat sheets"

# Debug current location
echo "Current directory: $(pwd)"
echo "WORK directory: $WORK"

# Function to generate shortcut name from filename
generate_shortcut() {
local filename=$1
local shortcut=""

# Remove file extension and common suffixes
local basename=${filename%%.html}
basename=${basename%%_Cheat_Sheet}

# For cheat sheets, use first letters of each word
shortcut=$(echo "$basename" | awk -F'_' '{for(i=1;i<=NF;i++)printf "%s", substr($i,1,1)}')

# echo "$shortcut"
}

# Function to create redirect file
create_redirect() {
local shortcut=$1
local target=$2
local redirect_file="$WORK/site/${shortcut}"

#echo "Creating redirect: /${shortcut} -> ${target}"

# Create the redirect HTML file
cat > "$redirect_file" << EOF
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="0; url=/${target}">
</head>
<body>
Redirecting to <a href="/${target}">${target}</a>...
</body>
</html>
EOF

# Also create .html version
cp "$redirect_file" "${redirect_file}.html"

# Verify creation
if [ -f "$redirect_file" ] && [ -f "${redirect_file}.html" ]; then
# echo "✅ Created shortcuts:"
echo " - /${shortcut}"
echo " - /${shortcut}.html"
else
#echo "❌ Failed to create shortcuts for ${shortcut}"
fi
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script fails here, I assume because there's nothing in the else clause except for the comment. Uncommenting the line fixes this.
However, when I run this locally and run make serve the shortcuts don't seem to work. I also don't see where the script reads redirects.yml - it looks like the script is automatically generating the shortcuts which makes me wonder how it will handle possible duplicates. Can you please clarify the process?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your feedback, @szh! I appreciate your insights and apologize for not testing every case @mackowski. The redirects.yml file now includes abbreviations for each path, and it can be easily modified and updated as needed. The XSS and auth issues should be resolved now, but please note that abbreviations should be followed by .html
Thank you, @jmanico, for bringing attention to my PR!

}

# Process all cheat sheet files
echo "Processing all cheat sheet files..."
find "$WORK/site/cheatsheets" -type f -name "*_Cheat_Sheet.html" | while read -r file; do
filename=$(basename "$file")
filepath=${file#"$WORK/site/"}

#echo "Processing: $filename"

# Generate shortcut name
shortcut=$(generate_shortcut "$filename")

# Skip if no shortcut generated
[ -z "$shortcut" ] && continue

# Convert to uppercase
#shortcut=$(echo "$shortcut" | tr '[:lower:]' '[:upper:]')

# Create redirect
create_redirect "$shortcut" "$filepath"
done

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/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/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
# Print all available shortcuts
#echo "Available shortcuts:"
for file in "$WORK"/site/[A-Z]*; do
if [ -f "$file" ] && [[ ! "$file" =~ \.(html|xml|gz)$ ]]; then
shortcut=$(basename "$file")
target=$(grep -o 'url=/[^"]*' "$file" | cut -d'=' -f2)
#echo "- /${shortcut} -> ${target}"
fi
done

echo "Step 7/7 Cleanup."
rm -rf cheatsheets
Expand Down
33 changes: 33 additions & 0 deletions scripts/redirects.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Direct topic shortcuts
SSRF: cheatsheets/Server_Side_Request_Forgery_Prevention_Cheat_Sheet.html
XSS: cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html
SQLi: cheatsheets/SQL_Injection_Prevention_Cheat_Sheet.html
JWT: cheatsheets/JSON_Web_Token_for_Java_Cheat_Sheet.html
DOS: cheatsheets/Denial_of_Service_Cheat_Sheet.html
Auth: cheatsheets/Authentication_Cheat_Sheet.html
CSRF: cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html
Docker: cheatsheets/Docker_Security_Cheat_Sheet.html
GraphQL: cheatsheets/GraphQL_Cheat_Sheet.html
K8S: cheatsheets/Kubernetes_Security_Cheat_Sheet.html
LDAP: cheatsheets/LDAP_Injection_Prevention_Cheat_Sheet.html
OAuth: cheatsheets/OAuth_2.0_Cheat_Sheet.html
SAML: cheatsheets/SAML_Security_Cheat_Sheet.html
TLS: cheatsheets/Transport_Layer_Protection_Cheat_Sheet.html

# Language-specific shortcuts
Java: cheatsheets/Java_Security_Cheat_Sheet.html
NodeJS: cheatsheets/Nodejs_Security_Cheat_Sheet.html
PHP: cheatsheets/PHP_Security_Cheat_Sheet.html
Python: cheatsheets/Python_Security_Cheat_Sheet.html
Ruby: cheatsheets/Ruby_on_Rails_Cheat_Sheet.html
DotNet: cheatsheets/DotNet_Security_Cheat_Sheet.html

# Category-based shortcuts
Mobile: cheatsheets/Mobile_Application_Security_Cheat_Sheet.html
API: cheatsheets/REST_Security_Cheat_Sheet.html
Cloud: cheatsheets/Cloud_Security_Cheat_Sheet.html
Crypto: cheatsheets/Cryptographic_Storage_Cheat_Sheet.html
Password: cheatsheets/Password_Storage_Cheat_Sheet.html
Session: cheatsheets/Session_Management_Cheat_Sheet.html

# Add more redirects as needed
Loading