Skip to content

Commit 42c4e6b

Browse files
committed
Use official OWASP cheat sheet URLs in importer branches
1 parent 03440ca commit 42c4e6b

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

application/utils/external_project_parsers/parsers/cheatsheets_parser.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
class Cheatsheets(ParserInterface):
1616
name = "OWASP Cheat Sheets"
17+
cheatsheetseries_base_url = "https://cheatsheetseries.owasp.org/cheatsheets"
1718

1819
def cheatsheet(
1920
self, section: str, hyperlink: str, tags: List[str]
@@ -25,6 +26,10 @@ def cheatsheet(
2526
hyperlink=hyperlink,
2627
)
2728

29+
def official_cheatsheet_url(self, markdown_filename: str) -> str:
30+
html_name = os.path.splitext(markdown_filename)[0] + ".html"
31+
return f"{self.cheatsheetseries_base_url}/{html_name}"
32+
2833
def parse(self, cache: db.Node_collection, ph: prompt_client.PromptHandler):
2934
c_repo = "https://github.com/OWASP/CheatSheetSeries.git"
3035
cheatsheets_path = "cheatsheets/"
@@ -55,7 +60,7 @@ def register_cheatsheets(
5560
name = title.group("title")
5661
cre_id = cre.group("cre")
5762
cres = cache.get_CREs(external_id=cre_id)
58-
hyperlink = f"{repo_path.replace('.git','')}/tree/master/{cheatsheets_path}{mdfile}"
63+
hyperlink = self.official_cheatsheet_url(mdfile)
5964
cs = self.cheatsheet(section=name, hyperlink=hyperlink, tags=[])
6065
for cre in cres:
6166
cs.add_link(

0 commit comments

Comments
 (0)