Skip to content

Commit b136977

Browse files
committed
URL shortcuts #1300
A Contribution for URL shortcut, now, Abbreviation .html directs to the exact page!
1 parent d638007 commit b136977

File tree

3 files changed

+126
-49
lines changed

3 files changed

+126
-49
lines changed

Index.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Index Alphabetical
22

3-
**91** cheat sheets available.
3+
**94** cheat sheets available.
44

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

@@ -24,6 +24,8 @@
2424

2525
## B
2626

27+
[Browser Extension Vulnerabilities Cheat Sheet](cheatsheets/Browser_Extension_Vulnerabilities_Cheat_Sheet.md)
28+
2729
[Bean Validation Cheat Sheet](cheatsheets/Bean_Validation_Cheat_Sheet.md) ![Java](assets/Index_Java.svg) ![Xml](assets/Index_Xml.svg)
2830

2931
## C
@@ -120,10 +122,12 @@
120122

121123
[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)
122124

123-
[LDAP Injection Prevention Cheat Sheet](cheatsheets/LDAP_Injection_Prevention_Cheat_Sheet.md)
125+
[LDAP Injection Prevention Cheat Sheet](cheatsheets/LDAP_Injection_Prevention_Cheat_Sheet.md) ![Java](assets/Index_Java.svg)
124126

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

129+
[Legacy Application Management Cheat Sheet](cheatsheets/Legacy_Application_Management_Cheat_Sheet.md)
130+
127131
## M
128132

129133
[Microservices Security Cheat Sheet](cheatsheets/Microservices_Security_Cheat_Sheet.md)
@@ -190,6 +194,8 @@
190194

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

197+
[Software Supply Chain Security Cheat Sheet](cheatsheets/Software_Supply_Chain_Security_Cheat_Sheet.md)
198+
193199
[Secrets Management Cheat Sheet](cheatsheets/Secrets_Management_Cheat_Sheet.md)
194200

195201
[Symfony Cheat Sheet](cheatsheets/Symfony_Cheat_Sheet.md) ![Php](assets/Index_Php.svg) ![Bash](assets/Index_Bash.svg)
@@ -200,7 +206,7 @@
200206

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

203-
[Transport Layer Security Cheat Sheet](cheatsheets/Transport_Layer_Security_Cheat_Sheet.md) ![Bash](assets/Index_Bash.svg)
209+
[Transport Layer Security Cheat Sheet](cheatsheets/Transport_Layer_Security_Cheat_Sheet.md)
204210

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

scripts/Generate_Site_mkDocs.sh

Lines changed: 84 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -95,53 +95,91 @@ if ! python -m mkdocs build; then
9595
exit 1
9696
fi
9797

98-
echo "Step 6/7: Handling redirect for files that have changed"
99-
#Authorization_Testing_Automation.md -> Authorization_Testing_Automation_Cheat_Sheet.md
100-
#Injection_Prevention_Cheat_Sheet_in_Java.md -> Injection_Prevention_in_Java_Cheat_Sheet.md
101-
#JSON_WEB_Token_Cheat_Sheet_for_Java.md -> JSON_WEB_Token_for_Java_Cheat_Sheet.md
102-
#Ruby_on_Rails_Cheatsheet.md -> Ruby_on_Rails_Cheat_Sheet.md
103-
#Nodejs_security_cheat_sheet.html -> Nodejs_security_Cheat_Sheet.html
98+
echo "Step 6/7: Generate URL shortcuts for all cheat sheets"
99+
100+
# Debug current location
101+
echo "Current directory: $(pwd)"
102+
echo "WORK directory: $WORK"
103+
104+
# Function to generate shortcut name from filename
105+
generate_shortcut() {
106+
local filename=$1
107+
local shortcut=""
108+
109+
# Remove file extension and common suffixes
110+
local basename=${filename%%.html}
111+
basename=${basename%%_Cheat_Sheet}
112+
113+
# For cheat sheets, use first letters of each word
114+
shortcut=$(echo "$basename" | awk -F'_' '{for(i=1;i<=NF;i++)printf "%s", substr($i,1,1)}')
115+
116+
# echo "$shortcut"
117+
}
118+
119+
# Function to create redirect file
120+
create_redirect() {
121+
local shortcut=$1
122+
local target=$2
123+
local redirect_file="$WORK/site/${shortcut}"
124+
125+
#echo "Creating redirect: /${shortcut} -> ${target}"
126+
127+
# Create the redirect HTML file
128+
cat > "$redirect_file" << EOF
129+
<!DOCTYPE html>
130+
<html>
131+
<head>
132+
<meta http-equiv="refresh" content="0; url=/${target}">
133+
</head>
134+
<body>
135+
Redirecting to <a href="/${target}">${target}</a>...
136+
</body>
137+
</html>
138+
EOF
139+
140+
# Also create .html version
141+
cp "$redirect_file" "${redirect_file}.html"
142+
143+
# Verify creation
144+
if [ -f "$redirect_file" ] && [ -f "${redirect_file}.html" ]; then
145+
# echo "✅ Created shortcuts:"
146+
echo " - /${shortcut}"
147+
echo " - /${shortcut}.html"
148+
else
149+
#echo "❌ Failed to create shortcuts for ${shortcut}"
150+
fi
151+
}
152+
153+
# Process all cheat sheet files
154+
echo "Processing all cheat sheet files..."
155+
find "$WORK/site/cheatsheets" -type f -name "*_Cheat_Sheet.html" | while read -r file; do
156+
filename=$(basename "$file")
157+
filepath=${file#"$WORK/site/"}
158+
159+
#echo "Processing: $filename"
160+
161+
# Generate shortcut name
162+
shortcut=$(generate_shortcut "$filename")
163+
164+
# Skip if no shortcut generated
165+
[ -z "$shortcut" ] && continue
166+
167+
# Convert to uppercase
168+
#shortcut=$(echo "$shortcut" | tr '[:lower:]' '[:upper:]')
169+
170+
# Create redirect
171+
create_redirect "$shortcut" "$filepath"
172+
done
104173

105-
if [[ "$OSTYPE" == "darwin"* ]]; then
106-
# MacOS
107-
sed -i '' "1i\\
108-
---\\
109-
redirect_from: \"/cheatsheets/Authorization_Testing_Automation.html\"\\
110-
---\\
111-
" "$WORK/$GENERATED_SITE/cheatsheets/Authorization_Testing_Automation_Cheat_Sheet.html"
112-
sed -i '' "1i\\
113-
---\\
114-
redirect_from: \"/cheatsheets/Injection_Prevention_Cheat_Sheet_in_Java.html\"\\
115-
---\\
116-
" "$WORK/$GENERATED_SITE/cheatsheets/Injection_Prevention_in_Java_Cheat_Sheet.html"
117-
sed -i '' "1i\\
118-
---\\
119-
redirect_from: \"/cheatsheets/JSON_Web_Token_Cheat_Sheet_for_Java.html\"\\
120-
---\\
121-
" "$WORK/$GENERATED_SITE/cheatsheets/JSON_Web_Token_for_Java_Cheat_Sheet.html"
122-
sed -i '' "1i\\
123-
---\\
124-
redirect_from: \"/cheatsheets/Ruby_on_Rails_Cheatsheet.html\"\\
125-
---\\
126-
" "$WORK/$GENERATED_SITE/cheatsheets/Ruby_on_Rails_Cheat_Sheet.html"
127-
sed -i '' "1i\\
128-
---\\
129-
redirect_from: \"/cheatsheets/Nodejs_security_cheat_sheet.html\"\\
130-
---\\
131-
" "$WORK/$GENERATED_SITE/cheatsheets/Nodejs_Security_Cheat_Sheet.html"
132-
sed -i '' "1i\\
133-
---\\
134-
redirect_from: \"/cheatsheets/Application_Logging_Vocabulary_Cheat_Sheet.html\"\\
135-
---\\
136-
" "$WORK/$GENERATED_SITE/cheatsheets/Logging_Vocabulary_Cheat_Sheet.html"
137-
else
138-
sed -i "1i---\nredirect_from: \"/cheatsheets/Authorization_Testing_Automation.html\"\n---\n" $WORK/$GENERATED_SITE/cheatsheets/Authorization_Testing_Automation_Cheat_Sheet.html
139-
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
140-
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
141-
sed -i "1i---\nredirect_from: \"/cheatsheets/Ruby_on_Rails_Cheatsheet.html\"\n---\n" $WORK/$GENERATED_SITE/cheatsheets/Ruby_on_Rails_Cheat_Sheet.html
142-
sed -i "1i---\nredirect_from: \"/cheatsheets/Nodejs_security_cheat_sheet.html\"\n---\n" $WORK/$GENERATED_SITE/cheatsheets/Nodejs_Security_Cheat_Sheet.html
143-
sed -i "1i---\nredirect_from: \"/cheatsheets/Application_Logging_Vocabulary_Cheat_Sheet.html\"\n---\n" $WORK/$GENERATED_SITE/cheatsheets/Logging_Vocabulary_Cheat_Sheet.html
144-
fi
174+
# Print all available shortcuts
175+
#echo "Available shortcuts:"
176+
for file in "$WORK"/site/[A-Z]*; do
177+
if [ -f "$file" ] && [[ ! "$file" =~ \.(html|xml|gz)$ ]]; then
178+
shortcut=$(basename "$file")
179+
target=$(grep -o 'url=/[^"]*' "$file" | cut -d'=' -f2)
180+
#echo "- /${shortcut} -> ${target}"
181+
fi
182+
done
145183

146184
echo "Step 7/7 Cleanup."
147185
rm -rf cheatsheets

scripts/redirects.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Direct topic shortcuts
2+
SSRF: cheatsheets/Server_Side_Request_Forgery_Prevention_Cheat_Sheet.html
3+
XSS: cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html
4+
SQLi: cheatsheets/SQL_Injection_Prevention_Cheat_Sheet.html
5+
JWT: cheatsheets/JSON_Web_Token_for_Java_Cheat_Sheet.html
6+
DOS: cheatsheets/Denial_of_Service_Cheat_Sheet.html
7+
Auth: cheatsheets/Authentication_Cheat_Sheet.html
8+
CSRF: cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html
9+
Docker: cheatsheets/Docker_Security_Cheat_Sheet.html
10+
GraphQL: cheatsheets/GraphQL_Cheat_Sheet.html
11+
K8S: cheatsheets/Kubernetes_Security_Cheat_Sheet.html
12+
LDAP: cheatsheets/LDAP_Injection_Prevention_Cheat_Sheet.html
13+
OAuth: cheatsheets/OAuth_2.0_Cheat_Sheet.html
14+
SAML: cheatsheets/SAML_Security_Cheat_Sheet.html
15+
TLS: cheatsheets/Transport_Layer_Protection_Cheat_Sheet.html
16+
17+
# Language-specific shortcuts
18+
Java: cheatsheets/Java_Security_Cheat_Sheet.html
19+
NodeJS: cheatsheets/Nodejs_Security_Cheat_Sheet.html
20+
PHP: cheatsheets/PHP_Security_Cheat_Sheet.html
21+
Python: cheatsheets/Python_Security_Cheat_Sheet.html
22+
Ruby: cheatsheets/Ruby_on_Rails_Cheat_Sheet.html
23+
DotNet: cheatsheets/DotNet_Security_Cheat_Sheet.html
24+
25+
# Category-based shortcuts
26+
Mobile: cheatsheets/Mobile_Application_Security_Cheat_Sheet.html
27+
API: cheatsheets/REST_Security_Cheat_Sheet.html
28+
Cloud: cheatsheets/Cloud_Security_Cheat_Sheet.html
29+
Crypto: cheatsheets/Cryptographic_Storage_Cheat_Sheet.html
30+
Password: cheatsheets/Password_Storage_Cheat_Sheet.html
31+
Session: cheatsheets/Session_Management_Cheat_Sheet.html
32+
33+
# Add more redirects as needed

0 commit comments

Comments
 (0)