Skip to content

Commit

Permalink
Adding support for mapping in multiple languages if required.
Browse files Browse the repository at this point in the history
  • Loading branch information
sydseter committed Apr 24, 2024
1 parent 0859db9 commit 46a4f21
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
- name: Generate new output files
run: |
pipenv run python scripts/convert.py -l all -t all -s all
pipenv run python scripts/gen_mappings.py --cres source/cre-mappings.yaml --target output/owasp_cornucopia_ecommerce_cre_mapping_1.30.json --lang source/ecommerce-cards-1.30-en.yaml
pipenv run python scripts/gen_mappings.py --cres source/cre-mappings.yaml --target output/owasp_cornucopia_ecommerce_cre_mapping_en_1.30.json --lang source/ecommerce-cards-1.30-en.yaml
- uses: marvinpinto/action-automatic-releases@919008cf3f741b179569b7a6fb4d8860689ab7f0 # v1.2.1
name: "Create pre-release"
with:
Expand Down Expand Up @@ -126,5 +126,6 @@
output/owasp_cornucopia_ecommerce_cards_pt-br_1.30_static.docx
output/owasp_cornucopia_ecommerce_cards_pt-br_1.30_static.idml
output/owasp_cornucopia_ecommerce_cards_pt-br_1.30_static.pdf
output/owasp_cornucopia_ecommerce_cre_mapping_en_1.30.json
README.md
source/*.yaml
4 changes: 2 additions & 2 deletions .github/workflows/run-tests-generate-output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
- name: Generate new output files
run: |
pipenv run python scripts/convert.py -l all -t all -s all
pipenv run python scripts/gen_mappings.py --cres source/cre-mappings.yaml --target output/owasp_cornucopia_ecommerce_cre_mapping_1.30.json --lang source/ecommerce-cards-1.30-en.yaml
pipenv run python scripts/gen_mappings.py --cres source/cre-mappings.yaml --target output/owasp_cornucopia_ecommerce_cre_mapping_en_1.30.json --lang source/ecommerce-cards-1.30-en.yaml
- name: Create pull request artifacts
uses: gavv/pull-request-artifacts@93f32f061d1fabdb41104db2493f2260c7db774f # v2.1
with:
Expand Down Expand Up @@ -156,4 +156,4 @@ jobs:
output/owasp_cornucopia_ecommerce_cards_pt-br_1.30_static.docx
output/owasp_cornucopia_ecommerce_cards_pt-br_1.30_static.idml
output/owasp_cornucopia_ecommerce_cards_pt-br_1.30_static.pdf
output/owasp_cornucopia_ecommerce_cre_mapping_1.30.json
output/owasp_cornucopia_ecommerce_cre_mapping_en_1.30.json
8 changes: 6 additions & 2 deletions scripts/gen_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
from typing import Any, Dict

base_url = "https://github.com/OWASP/cornucopia/wiki/"
CORNUCOPIA_VERSION = "1.30"


def produce_ecommerce_mappings(source_file: Dict[Any, Any], language_mapping: Dict[Any, Any]) -> Dict[Any, Any]:
base = {
"meta": {"edition": "ecommerce", "component": "mappings", "language": "ALL", "version": CORNUCOPIA_VERSION},
"meta": {
"edition": "ecommerce",
"component": "mappings",
"language": language_mapping["meta"]["language"],
"version": language_mapping["meta"]["version"]
},
"standards": [],
}
for indx, suit in enumerate(source_file.copy()["suits"]):
Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/gen_mappings_utest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_can_produce_ecommerce_mappings(self):
]
}
expected = {
"meta": {"component": "mappings", "edition": "ecommerce", "language": "ALL", "version": "1.30"},
"meta": {"component": "mappings", "edition": "ecommerce", "language": "EN", "version": "1.30"},
"standards": [
{
"doctype": "Tool",
Expand Down

0 comments on commit 46a4f21

Please sign in to comment.