Skip to content

Commit

Permalink
Add code snippets languages beside the CS name in Index
Browse files Browse the repository at this point in the history
  • Loading branch information
righettod committed Jan 11, 2019
1 parent ac1fa9f commit 9f94e05
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 16 deletions.
34 changes: 18 additions & 16 deletions Index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
**13** cheat sheets available.

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

[A](Index.md#a) [B](Index.md#b) [C](Index.md#c) [D](Index.md#d) [E](Index.md#e) [F](Index.md#f) [H](Index.md#h) [I](Index.md#i) [J](Index.md#j) [K](Index.md#k) [L](Index.md#l) [M](Index.md#m) [O](Index.md#o)

# A
Expand All @@ -8,25 +10,25 @@

[Access Control Cheat Sheet](cheatsheets/Access_Control_Cheat_Sheet.md).

[AJAX Security Cheat Sheet](cheatsheets/AJAX_Security_Cheat_Sheet.md).
[AJAX Security Cheat Sheet](cheatsheets/AJAX_Security_Cheat_Sheet.md). ![Json](assets/Index_Json.png)

[Attack Surface Analysis Cheat Sheet](cheatsheets/Attack_Surface_Analysis_Cheat_Sheet.md).

[Authentication Cheat Sheet](cheatsheets/Authentication_Cheat_Sheet.md).

[Authorization Testing Automation](cheatsheets/Authorization_Testing_Automation.md).
[Authorization Testing Automation](cheatsheets/Authorization_Testing_Automation.md). ![Java](assets/Index_Java.png) ![Xml](assets/Index_Xml.png)

# B

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

# C

[C-Based Toolchain Hardening Cheat Sheet](cheatsheets/C-Based_Toolchain_Hardening_Cheat_Sheet.md).

[Choosing and Using Security Questions Cheat Sheet](cheatsheets/Choosing_and_Using_Security_Questions_Cheat_Sheet.md).

[Clickjacking Defense Cheat Sheet](cheatsheets/Clickjacking_Defense_Cheat_Sheet.md).
[Clickjacking Defense Cheat Sheet](cheatsheets/Clickjacking_Defense_Cheat_Sheet.md). ![Javascript](assets/Index_Javascript.png) ![Html](assets/Index_Html.png)

[Credential Stuffing Prevention Cheat Sheet](cheatsheets/Credential_Stuffing_Prevention_Cheat_Sheet.md).

Expand All @@ -36,39 +38,39 @@

[Denial of Service Cheat Sheet](cheatsheets/Denial_of_Service_Cheat_Sheet.md).

[Deserialization Cheat Sheet](cheatsheets/Deserialization_Cheat_Sheet.md).
[Deserialization Cheat Sheet](cheatsheets/Deserialization_Cheat_Sheet.md). ![Java](assets/Index_Java.png) ![Csharp](assets/Index_Csharp.png) ![Python](assets/Index_Python.png)

[DOM based XSS Prevention Cheat Sheet](cheatsheets/DOM_based_XSS_Prevention_Cheat_Sheet.md).
[DOM based XSS Prevention Cheat Sheet](cheatsheets/DOM_based_XSS_Prevention_Cheat_Sheet.md). ![Javascript](assets/Index_Javascript.png) ![Html](assets/Index_Html.png)

[DotNet Security Cheat Sheet](cheatsheets/DotNet_Security_Cheat_Sheet.md).
[DotNet Security Cheat Sheet](cheatsheets/DotNet_Security_Cheat_Sheet.md). ![Csharp](assets/Index_Csharp.png) ![Html](assets/Index_Html.png) ![Xml](assets/Index_Xml.png) ![Sql](assets/Index_Sql.png)

# E

[Error Handling Cheat Sheet](cheatsheets/Error_Handling_Cheat_Sheet.md).
[Error Handling Cheat Sheet](cheatsheets/Error_Handling_Cheat_Sheet.md). ![Java](assets/Index_Java.png) ![Csharp](assets/Index_Csharp.png) ![Xml](assets/Index_Xml.png)

# F

[Forgot Password Cheat Sheet](cheatsheets/Forgot_Password_Cheat_Sheet.md).

# H

[HTML5 Security Cheat Sheet](cheatsheets/HTML5_Security_Cheat_Sheet.md).
[HTML5 Security Cheat Sheet](cheatsheets/HTML5_Security_Cheat_Sheet.md). ![Javascript](assets/Index_Javascript.png) ![Java](assets/Index_Java.png) ![Json](assets/Index_Json.png) ![Shell](assets/Index_Shell.png)

[HTTP Strict Transport Security Cheat Sheet](cheatsheets/HTTP_Strict_Transport_Security_Cheat_Sheet.md).

# I

[Injection Prevention Cheat Sheet in Java](cheatsheets/Injection_Prevention_Cheat_Sheet_in_Java.md).
[Injection Prevention Cheat Sheet in Java](cheatsheets/Injection_Prevention_Cheat_Sheet_in_Java.md). ![Java](assets/Index_Java.png) ![Xml](assets/Index_Xml.png)

[Input Validation Cheat Sheet](cheatsheets/Input_Validation_Cheat_Sheet.md).
[Input Validation Cheat Sheet](cheatsheets/Input_Validation_Cheat_Sheet.md). ![Java](assets/Index_Java.png)

[Insecure Direct Object Reference Prevention Cheat Sheet](cheatsheets/Insecure_Direct_Object_Reference_Prevention_Cheat_Sheet.md).
[Insecure Direct Object Reference Prevention Cheat Sheet](cheatsheets/Insecure_Direct_Object_Reference_Prevention_Cheat_Sheet.md). ![Java](assets/Index_Java.png)

# J

[JAAS Cheat Sheet](cheatsheets/JAAS_Cheat_Sheet.md).
[JAAS Cheat Sheet](cheatsheets/JAAS_Cheat_Sheet.md). ![Java](assets/Index_Java.png)

[JSON Web Token (JWT) Cheat Sheet for Java](cheatsheets/JSON_Web_Token_(JWT)_Cheat_Sheet_for_Java.md).
[JSON Web Token (JWT) Cheat Sheet for Java](cheatsheets/JSON_Web_Token_(JWT)_Cheat_Sheet_for_Java.md). ![Javascript](assets/Index_Javascript.png) ![Java](assets/Index_Java.png) ![Json](assets/Index_Json.png) ![Sql](assets/Index_Sql.png)

# K

Expand All @@ -82,8 +84,8 @@

# M

[Mass Assignment Cheat Sheet](cheatsheets/Mass_Assignment_Cheat_Sheet.md).
[Mass Assignment Cheat Sheet](cheatsheets/Mass_Assignment_Cheat_Sheet.md). ![Javascript](assets/Index_Javascript.png) ![Java](assets/Index_Java.png) ![Html](assets/Index_Html.png) ![Php](assets/Index_Php.png)

# O

[OS Command Injection Defense Cheat Sheet](cheatsheets/OS_Command_Injection_Defense_Cheat_Sheet.md).
[OS Command Injection Defense Cheat Sheet](cheatsheets/OS_Command_Injection_Defense_Cheat_Sheet.md). ![Java](assets/Index_Java.png) ![Csharp](assets/Index_Csharp.png) ![Shell](assets/Index_Shell.png)
Binary file added assets/Index_Bash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/Index_C.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/Index_Cpp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/Index_Csharp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/Index_Html.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/Index_Java.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/Index_Javascript.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/Index_Json.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/Index_Php.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/Index_Python.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/Index_Ruby.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/Index_Shell.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/Index_Sql.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/Index_Xml.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions scripts/Update_CheatSheets_Index.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,21 @@
import os
from collections import OrderedDict

# Define utility functions
def extract_languages_snippet_provided(cheatsheet):
languages = []
markers = ["javascript", "java", "csharp", "c", "cpp", "html", "xml", "python",
"ruby", "php", "json", "sql", "bash", "shell"]
with open("../cheatsheets/" + cheatsheet, encoding="utf8") as cs_file:
cs_content = cs_file.read().lower().replace(" ","")
for marker in markers:
if "```" + marker + "\n" in cs_content:
languages.append(marker.capitalize())
return languages

# Define templates
cs_md_link_template = "[%s](cheatsheets/%s)."
language_md_link_template = "![%s](assets/Index_%s.png)"
header_template = "# %s\n\n"
top_menu_template = "[%s](Index.md#%s)"
cs_count_template = "**%s** cheat sheets available."
Expand All @@ -31,6 +44,7 @@
with open("../Index.md", "w") as index_file:
index_count = len(index)
index_file.write(cs_count_template % index_count)
index_file.write("\n\n*Icons beside the cheat sheet name indicate in which language(s) code snippet(s) are provided.*")
index_file.write("\n\n")
# Generate the top menu
for letter in index:
Expand All @@ -46,6 +60,12 @@
for cs_file in index[letter]:
cs_name = cs_file.replace("_", " ").replace(".md", "").strip()
index_file.write(cs_md_link_template % (cs_name, cs_file))
languages = extract_languages_snippet_provided(cs_file)
if len(languages) > 0:
index_file.write(" ")
for language in languages:
index_file.write(language_md_link_template % (language, language))
index_file.write(" ")
i += 1
index_file.write("\n")
if i != cs_count:
Expand Down

0 comments on commit 9f94e05

Please sign in to comment.