From 7662c7f16b1642bcc267ff8f9095c4c5220c329f Mon Sep 17 00:00:00 2001 From: Francis Charette-Migneault Date: Wed, 9 Nov 2022 11:21:24 -0500 Subject: [PATCH] add missing bandit to GitHub CI and apply bandit fixes (#625) --- .github/workflows/ci-tests.yml | 2 +- schema_salad/cpp_codegen.py | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 55f126e8..ea2aa723 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -21,7 +21,7 @@ jobs: matrix: py-ver-major: [3] py-ver-minor: [6, 7, 8, 9, 10, 11] - step: [lint, unit, mypy] + step: [lint, bandit, unit, mypy] exclude: - py-ver-major: 3 py-ver-minor: 6 diff --git a/schema_salad/cpp_codegen.py b/schema_salad/cpp_codegen.py index 418cfe29..19ef8a62 100644 --- a/schema_salad/cpp_codegen.py +++ b/schema_salad/cpp_codegen.py @@ -65,7 +65,10 @@ def safename2(name: Dict[str, str]) -> str: # into its class path and non class path def split_name(s: str) -> Tuple[str, str]: t = s.split("#") - assert len(t) == 2 + if len(t) != 2: + raise ValueError( + "Expected field to be formatted as 'https://xyz.xyz/blub#cwl/class'." + ) return (t[0], t[1]) @@ -73,7 +76,10 @@ def split_name(s: str) -> Tuple[str, str]: def split_field(s: str) -> Tuple[str, str, str]: (namespace, field) = split_name(s) t = field.split("/") - assert len(t) == 2 + if len(t) != 2: + raise ValueError( + "Expected field to be formatted as 'https://xyz.xyz/blub#cwl/class'." + ) return (namespace, t[0], t[1]) @@ -596,8 +602,6 @@ def parse(self, items: List[Dict[str, Any]]) -> None: types = {i["name"]: i for i in items} # type: Dict[str, Any] for stype in items: - assert "type" in stype - if "type" in stype and stype["type"] == "documentation": continue