Skip to content

Commit

Permalink
Fix export script to handle all future languages (#617)
Browse files Browse the repository at this point in the history
* fix export script to handle all future languages
  • Loading branch information
cpholguera authored Jan 20, 2022
1 parent 4940836 commit 37f052d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
6 changes: 3 additions & 3 deletions tools/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

''' Tool for converting the MASVS requirements to various formats.
Usage: ./export.py [--format <csv/xml/json>] [--lang <es/ru/en/fr/de/zhtw/ja>]
Usage: ./export.py [--format <csv/xml/json>] [--lang <es/ru/en/fr/de/zhtw/ja...>]
By Bernhard Mueller, updated by Jeroen Beckers and Carlos Holguera
Copyright (c) 2021 OWASP Foundation
Copyright (c) OWASP Foundation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -33,7 +33,7 @@

parser = argparse.ArgumentParser(description='Export the MASVS requirements. Default language is en.')
parser.add_argument('-f', '--format', choices=['json', 'xml', 'csv', 'yaml'], required=True)
parser.add_argument('-l', '--lang', choices=['de', 'en', 'es', 'fa', 'fr', 'hi', 'ja', 'ko', 'ru', 'zhcn', 'zhtw'], default='en')
parser.add_argument('-l', '--lang', default='en')

args = parser.parse_args()

Expand Down
20 changes: 11 additions & 9 deletions tools/masvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
By Bernhard Mueller, updated by Jeroen Beckers and Carlos Holguera
Copyright (c) 2021 OWASP Foundation
Copyright (c) OWASP Foundation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -40,14 +40,16 @@
from io import StringIO

def order_filenames(target):
keys = [f"-V{k}-" for k in range(1,9)]
l = [file.name for file in Path(target).glob("0x*-V*.md")]
ret_l = []
for k in keys:
for name in l:
if k in name:
ret_l.append(name)
return ret_l
if Path(target).exists():
keys = [f"-V{k}-" for k in range(1,9)]
l = [file.name for file in Path(target).glob("0x*-V*.md")]
ret_l = []
for k in keys:
for name in l:
if k in name:
ret_l.append(name)
return ret_l
raise Exception(f"The provided path ({target}) does not exist. Does the corresponding language supported in the MASVS?")

class MASVS:
''' Creates requirements list out of markdown files. '''
Expand Down

0 comments on commit 37f052d

Please sign in to comment.