Skip to content

Commit

Permalink
Prepare for 2.0 release and mobile app release and shorten the build …
Browse files Browse the repository at this point in the history
…time.
  • Loading branch information
sydseter committed May 20, 2024
1 parent 7bc1c77 commit 9652274
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
run: |
pipenv run python scripts/convert.py -l all -t all -s all -v 1.22 -e webapp
pipenv run python scripts/convert.py -l all -t all -s all -v 2.00 -e webapp
pipenv run python scripts/convert.py -l all -t all -s all -v 1.00 -e mobileapp
pipenv run python scripts/convert.py -l en -t all -s all -v 1.00 -e mobileapp
- uses: marvinpinto/action-automatic-releases@919008cf3f741b179569b7a6fb4d8860689ab7f0 # v1.2.1
name: "Create pre-release"
with:
Expand Down
41 changes: 21 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@
run: pipenv run coverage report --fail-under 85 scripts/convert*
- name: Generate new output files
run: |
pipenv run python scripts/convert.py -l all -t all -s all -v 1.22 -e webapp
pipenv run python scripts/convert.py -l all -t all -s all -v 2.00 -e webapp
pipenv run python scripts/convert.py -l all -t all -s all -v 1.00 -e mobileapp
pipenv run python scripts/convert.py -l en -t all -s all -v 1.00 -e mobileapp
- uses: marvinpinto/action-automatic-releases@919008cf3f741b179569b7a6fb4d8860689ab7f0 # v1.2.1
name: "Create release"
with:
Expand All @@ -80,24 +79,26 @@
creative-commons-attribution-3.0.txt
LICENSE
LICENSE.md
output/owasp_cornucopia_webapp_cards_en_1.22_leaflet.idml
output/owasp_cornucopia_webapp_guide_en_1.22_static.docx
output/owasp_cornucopia_webapp_cards_en_1.22_static.idml
output/owasp_cornucopia_webapp_cards_es_1.22_leaflet.idml
output/owasp_cornucopia_webapp_guide_es_1.22_static.docx
output/owasp_cornucopia_webapp_cards_es_1.22_static.idml
output/owasp_cornucopia_webapp_guide_fr_1.22_static.docx
output/owasp_cornucopia_webapp_cards_fr_1.22_static.idml
output/owasp_cornucopia_webapp_cards_fr_1.22_leaflet.idml
output/owasp_cornucopia_webapp_cards_nl_1.22_leaflet.idml
output/owasp_cornucopia_webapp_guide_nl_1.22_static.docx
output/owasp_cornucopia_webapp_cards_nl_1.22_static.idml
output/owasp_cornucopia_webapp_cards_no-nb_1.22_leaflet.idml
output/owasp_cornucopia_webapp_guide_no-nb_1.22_static.docx
output/owasp_cornucopia_webapp_cards_no-nb_1.22_static.idml
output/owasp_cornucopia_webapp_cards_pt-br_1.22_leaflet.idml
output/owasp_cornucopia_webapp_guide_pt-br_1.22_static.docx
output/owasp_cornucopia_webapp_cards_pt-br_1.22_static.idml
output/owasp_cornucopia_webapp_cards_en_2.00_leaflet.idml
output/owasp_cornucopia_webapp_guide_en_2.00_static.docx
output/owasp_cornucopia_webapp_cards_en_2.00_static.idml
output/owasp_cornucopia_webapp_cards_es_2.00_leaflet.idml
output/owasp_cornucopia_webapp_guide_es_2.00_static.docx
output/owasp_cornucopia_webapp_cards_es_2.00_static.idml
output/owasp_cornucopia_webapp_cards_fr_2.00_leaflet.idml
output/owasp_cornucopia_webapp_guide_fr_2.00_static.docx
output/owasp_cornucopia_webapp_cards_fr_2.00_static.idml
output/owasp_cornucopia_webapp_cards_nl_2.00_leaflet.idml
output/owasp_cornucopia_webapp_guide_nl_2.00_static.docx
output/owasp_cornucopia_webapp_cards_nl_2.00_static.idml
output/owasp_cornucopia_webapp_cards_no-nb_2.00_leaflet.idml
output/owasp_cornucopia_webapp_guide_no-nb_2.00_static.docx
output/owasp_cornucopia_webapp_cards_no-nb_2.00_static.idml
output/owasp_cornucopia_webapp_cards_pt-br_2.00_leaflet.idml
output/owasp_cornucopia_webapp_guide_pt-br_2.00_static.docx
output/owasp_cornucopia_webapp_cards_pt-br_2.00_static.idml
output/owasp_cornucopia_mobileapp_cards_en_1.00_static.idml
output/owasp_cornucopia_mobileapp_cards_en_1.00_leaflet.idml
README.md
source/*.yaml
resources/case/owasp_cornucopia_webapp_1.22_case.ai
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/run-tests-generate-output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ jobs:
pipenv install -d
- name: Generate new output files
run: |
pipenv run python scripts/convert.py -l en -t docx -s dynamic -v 1.22 -e webapp
pipenv run python scripts/convert.py -l en -t docx -s dynamic -v 2.00 -e webapp
pipenv run python scripts/convert.py -l all -t all -s all -v 1.22 -e webapp
pipenv run python scripts/convert.py -l all -t all -s all -v 2.00 -e webapp
pipenv run python scripts/convert.py -l all -t all -s all -v 1.00 -e mobileapp
pipenv run python scripts/convert.py -l en -t all -s all -v 1.00 -e mobileapp
- name: Create pull request artifacts
uses: gavv/pull-request-artifacts@93f32f061d1fabdb41104db2493f2260c7db774f # v2.1
with:
Expand Down
33 changes: 17 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,43 +55,44 @@ For font licensing, please read font [README.md](./resources/fonts/README.md)
Merges to the main branch will generate new DOCX and IDML files to use to print off new version of the deck but if you wish to produce these locally yourself then use the ./scripts/convert.py scipt to do this:

```bash
(cornucopia) ➜ cornucopia git:(master) ✗ python ./scripts/convert.py --help
usage: convert.py [-h] [-i INPUTFILE] [-t {all,docx,pdf,idml}] [-o OUTPUTFILE] [-l {template,all,en,es,fr,nl,no-nb,pt-br}] [-d] [-s {all,static,dynamic}] [-u URL]
-(cornucopia) ➜ cornucopia git:(master) ✗ python ./scripts/convert.py --help
usage: convert.py [-h] [-i INPUTFILE] [-v {all,latest,1.00,1.20,1.21,1.22,2.00}] [-t {all,docx,pdf,idml}] [-o OUTPUTFILE] [-l {template,all,en,es,fr,nl,no-nb,pt-br}] [-d]
[-s {all,static,dynamic,leaflet}] [-e {all,webapp,mobileapp}] [-u URL]

Tool to output OWASP Cornucopia playing cards into different file types and languages.
Tool to output OWASP Cornucopia playing cards into different file types and languages.
Example usage: $ ./cornucopia/convert.py -t docx -l es -v 2.00
Example usage: c:\cornucopia\scripts\convert.py -t idml -l fr -s static -v 2.00 -o 'my_output_folder/owasp_cornucopia_edition_language_version.idml'
Example usage: c:\cornucopia\scripts\convert.py -t idml -l fr -v 2.00 -o 'my_output_folder/owasp_cornucopia_edition_language_version.idml'

options:
-h, --help show this help message and exit
-i INPUTFILE, --inputfile INPUTFILE
Input (template) file to use.
Default=resources/templates/owasp_cornucopia_edition_lang_ver_template.(docx|idml)
Default=resources\templates\owasp_cornucopia_edition_lang_ver_template.(docx|idml)
Template type is dependent on output type (-t) or file (-o) specified.
-v {1.00,1.20,1.21,1.22,2.00}, --version {1.00,1.20,1.21,1.22,2.00}
Output version to produce. [`1.20`, `1.21`, `1.22`, `2.00`]
-v {all,latest,1.00,1.20,1.21,1.22,2.00}, --version {all,latest,1.00,1.20,1.21,1.22,2.00}
Output version to produce. [`all`, `latest`, `1.00`, `1.20`, `1.21`, `1.22`, `2.00`]
Version 1.20 and 1.2x will deliver cards mapped to ASVS 3.0.1
Version 2.00 and 2.0x will deliver cards mapped to ASVS 4.0
Version 1.00 and 1.0x will deliver cards mapped to MASVS 2.0
Version all will deliver all versions
Version latest will deliver the latest deck versions
-t {all,docx,pdf,idml}, --outputfiletype {all,docx,pdf,idml}
Type of file to output. Default = docx. If specified, this overwrites the output file extension
Type of file to output. Default = (docx, idml). If specified, this overwrites the output file extension
-o OUTPUTFILE, --outputfile OUTPUTFILE
Specify a path and name of output file to generate. (caution: existing file will be overwritten).
default = output/owasp_cornucopia_edition_component_lang_ver.(docx|pdf|idml)
Specify a path and name of output file to generate. (caution: existing file will be overwritten).
default = output\owasp_cornucopia_edition_component_lang_ver.(docx|pdf|idml)
-l {template,all,en,es,fr,nl,no-nb,pt-br}, --language {template,all,en,es,fr,nl,no-nb,pt-br}
Output language to produce. [`en`, `es`, `fr`, `nl`, `no-nb`, `pt-br`, `template`]
Template will attempt to create a template from the english input file and
Output language to produce. [`en`, `es`, `fr`, `nl`, `no-nb`, `pt-br`, `template`]
Template will attempt to create a template from the english input file and
replacing strings with the template lookup codes
-d, --debug Output additional information to debug script
-s {all,static,dynamic,leaflet}, --style {all,static,dynamic,leaflet}
Output style to produce. [`static`, `dynamic` or `leaflet`]
Static cards have the mappings printed on them, dynamic ones a QRCode that points to an maintained list.The leaflet contains the instructions
-e {all,webapp,mobileapp}, --edition {all,webapp,mobileapp}
Output decks to produce. [`all`, `webapp` or `mobileapp`]
The various Cornucopia decks. `web` will give you the web webapp edition.`mobileapp` will give you the MASVS/MASTG edition.
-s {all,static,dynamic,leaflet}, --style {all,static,dynamic,leaflet}
Output style to produce. [`static`, `dynamic` or `leaflet`]
Static cards have the mappings printed on them, dynamic ones a QRCode that points to an maintained list.The leaflet contains the instructions
-u URL, --url URL Specify a URL to use in generating dynamic cards. (caution: URL will be suffixed with / and the card ID).
-u URL, --url URL Specify a URL to use in generating dynamic cards. (caution: URL will be suffixed with / and the card ID).
```

## Printing
Expand Down
11 changes: 5 additions & 6 deletions scripts/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def parse_arguments(input_args: List[str]) -> argparse.Namespace:
description = "Tool to output OWASP Cornucopia playing cards into different file types and languages. "
description += "\nExample usage: $ ./cornucopia/convert.py -t docx -l es -v 2.00"
description += "\nExample usage: c:\\cornucopia\\scripts\\convert.py -t idml -l fr -v 2.00"
description += "-o 'my_output_folder/owasp_cornucopia_edition_language_version.idml'"
description += " -o 'my_output_folder/owasp_cornucopia_edition_language_version.idml'"
parser = argparse.ArgumentParser(description=description, formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument(
"-i",
Expand Down Expand Up @@ -252,7 +252,7 @@ def parse_arguments(input_args: List[str]) -> argparse.Namespace:
"--outputfiletype",
type=str,
choices=convert_vars.FILETYPE_CHOICES,
help="Type of file to output. Default = docx. If specified, this overwrites the output file extension",
help="Type of file to output. Default = (docx, idml). If specified, this overwrites the output file extension",
)
parser.add_argument(
"-o",
Expand Down Expand Up @@ -313,7 +313,7 @@ def parse_arguments(input_args: List[str]) -> argparse.Namespace:
parser.add_argument(
"-u",
"--url",
default="https://copi.securedelivery.io/cards",
default="https://copi.owasp.org/cards",
type=str,
help=(
"Specify a URL to use in generating dynamic cards. (caution: URL will be suffixed with / and the card ID). "
Expand Down Expand Up @@ -762,9 +762,8 @@ def get_valid_mapping_for_version(version: str, edition: str) -> str:
def get_valid_styles() -> List[str]:
styles = []
if convert_vars.args.style.lower() == "all":
for style in convert_vars.STYLE_CHOICES:
if style != "all":
styles.append(style)
styles.append("static")
styles.append("leaflet")
elif convert_vars.args.style == "":
styles.append("static")
else:
Expand Down
1 change: 1 addition & 0 deletions tests/scripts/convert_utest.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ def test_get_valid_style_choices_all(self) -> None:
c.convert_vars.args = argparse.Namespace(style="all")
want_style = c.convert_vars.STYLE_CHOICES
want_style.remove("all")
want_style.remove("dynamic")

got_style = c.get_valid_styles()
self.assertListEqual(want_style, got_style)
Expand Down

0 comments on commit 9652274

Please sign in to comment.