From 5da77a8b93c540f531ca04299fe70272d289b9fa Mon Sep 17 00:00:00 2001 From: benyissa Date: Fri, 24 Jan 2025 12:44:19 +0100 Subject: [PATCH 1/5] Fix scan source is not none --- src/ostorlab/apis/scan_create.py | 12 +++--------- tests/cli/ci_scan/run/run_test.py | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/ostorlab/apis/scan_create.py b/src/ostorlab/apis/scan_create.py index b67d5e45c..ab13c0e1e 100644 --- a/src/ostorlab/apis/scan_create.py +++ b/src/ostorlab/apis/scan_create.py @@ -97,16 +97,10 @@ def data(self) -> Optional[Dict]: "credentialIds": self._test_credential_ids, "sboms": [None for _ in self._sboms], "scanSource": { - "source": self._scan_source.source - if self._scan_source is not None - else None, - "repository": self._scan_source.repository - if self._scan_source is not None - else None, + "source": self._scan_source.source, + "repository": self._scan_source.repository, "prNumber": self._scan_source.pr_number - if self._scan_source is not None - else None, - }, + } if self._scan_source is not None else None, }, } ), diff --git a/tests/cli/ci_scan/run/run_test.py b/tests/cli/ci_scan/run/run_test.py index c8b69434c..11c65f0ce 100644 --- a/tests/cli/ci_scan/run/run_test.py +++ b/tests/cli/ci_scan/run/run_test.py @@ -424,7 +424,7 @@ def testRunWebScanCLI_withsboms_callApi( ) assert api_caller_mock.call_count == 2 - + assert api_caller_mock.call_args_list[0].args[0]._scan_source is None def testRunScanCLI_withSourceGithub_callApi(mocker: plugin.MockerFixture) -> None: """Test ostorlab ci_scan with invalid break_on_risk_rating. it should exit with error exit_code = 2.""" From a4b43b587225bceafd4850b1584822a7de5eaa19 Mon Sep 17 00:00:00 2001 From: benyissa Date: Fri, 24 Jan 2025 12:49:37 +0100 Subject: [PATCH 2/5] Ruff ! --- src/ostorlab/apis/scan_create.py | 6 ++++-- tests/cli/ci_scan/run/run_test.py | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ostorlab/apis/scan_create.py b/src/ostorlab/apis/scan_create.py index ab13c0e1e..e57d8d2c0 100644 --- a/src/ostorlab/apis/scan_create.py +++ b/src/ostorlab/apis/scan_create.py @@ -99,8 +99,10 @@ def data(self) -> Optional[Dict]: "scanSource": { "source": self._scan_source.source, "repository": self._scan_source.repository, - "prNumber": self._scan_source.pr_number - } if self._scan_source is not None else None, + "prNumber": self._scan_source.pr_number, + } + if self._scan_source is not None + else None, }, } ), diff --git a/tests/cli/ci_scan/run/run_test.py b/tests/cli/ci_scan/run/run_test.py index 11c65f0ce..9d56d41a3 100644 --- a/tests/cli/ci_scan/run/run_test.py +++ b/tests/cli/ci_scan/run/run_test.py @@ -426,6 +426,7 @@ def testRunWebScanCLI_withsboms_callApi( assert api_caller_mock.call_count == 2 assert api_caller_mock.call_args_list[0].args[0]._scan_source is None + def testRunScanCLI_withSourceGithub_callApi(mocker: plugin.MockerFixture) -> None: """Test ostorlab ci_scan with invalid break_on_risk_rating. it should exit with error exit_code = 2.""" scan_create_dict = {"data": {"createMobileScan": {"scan": {"id": "1"}}}} From f0a025aec731279d1cd70a5eaf6bc83afb6fcbcd Mon Sep 17 00:00:00 2001 From: benyissa Date: Fri, 24 Jan 2025 14:28:41 +0100 Subject: [PATCH 3/5] Release 1.3.6 --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 45fba01b2..7cdcf69aa 100644 --- a/setup.cfg +++ b/setup.cfg @@ -13,7 +13,7 @@ license_files = LICENSE long_description = file: README.md long_description_content_type = text/markdown url = https://github.com/Ostorlab/ostorlab -version=1.3.5 +version=1.3.6 project_urls = Documentation = https://oxo.ostorlab.co/ Source = https://github.com/Ostorlab/oxo From 021010860b9a43300d7e3c34ad3c723d2c017402 Mon Sep 17 00:00:00 2001 From: benyissa Date: Fri, 24 Jan 2025 15:25:07 +0100 Subject: [PATCH 4/5] Fix unit test --- setup.cfg | 2 +- tests/cli/ci_scan/run/run_test.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index 7cdcf69aa..45fba01b2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -13,7 +13,7 @@ license_files = LICENSE long_description = file: README.md long_description_content_type = text/markdown url = https://github.com/Ostorlab/ostorlab -version=1.3.6 +version=1.3.5 project_urls = Documentation = https://oxo.ostorlab.co/ Source = https://github.com/Ostorlab/oxo diff --git a/tests/cli/ci_scan/run/run_test.py b/tests/cli/ci_scan/run/run_test.py index 9d56d41a3..72f50e38f 100644 --- a/tests/cli/ci_scan/run/run_test.py +++ b/tests/cli/ci_scan/run/run_test.py @@ -424,7 +424,7 @@ def testRunWebScanCLI_withsboms_callApi( ) assert api_caller_mock.call_count == 2 - assert api_caller_mock.call_args_list[0].args[0]._scan_source is None + assert hasattr(api_caller_mock.call_args_list[0].args[0], "_scan_source") == False def testRunScanCLI_withSourceGithub_callApi(mocker: plugin.MockerFixture) -> None: From da3fe9b408854a1a0ad4574514811bc43defa65d Mon Sep 17 00:00:00 2001 From: benyissa Date: Fri, 24 Jan 2025 15:28:50 +0100 Subject: [PATCH 5/5] Ruff ! --- tests/cli/ci_scan/run/run_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cli/ci_scan/run/run_test.py b/tests/cli/ci_scan/run/run_test.py index 72f50e38f..7d630b1fb 100644 --- a/tests/cli/ci_scan/run/run_test.py +++ b/tests/cli/ci_scan/run/run_test.py @@ -424,7 +424,7 @@ def testRunWebScanCLI_withsboms_callApi( ) assert api_caller_mock.call_count == 2 - assert hasattr(api_caller_mock.call_args_list[0].args[0], "_scan_source") == False + assert hasattr(api_caller_mock.call_args_list[0].args[0], "_scan_source") is False def testRunScanCLI_withSourceGithub_callApi(mocker: plugin.MockerFixture) -> None: