From 7c7fcd068247501f58f92fdcedfd58ba288e4e1f Mon Sep 17 00:00:00 2001 From: Yasel Couce Date: Fri, 19 Mar 2021 12:23:25 -0300 Subject: [PATCH 1/9] requirements: Upgrade 'Django' Upgrade Django 2.2.10 -> 2.2.18 with fixes to some knows vulnerabilities - https://github.com/advisories/GHSA-fvgf-6h6h-3322 - https://github.com/advisories/GHSA-m6gj-h9gm-gw44 - https://github.com/advisories/GHSA-fr28-569j-53c4 --- requirements/extras.txt | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements/extras.txt b/requirements/extras.txt index dd5d96e8..4253188a 100644 --- a/requirements/extras.txt +++ b/requirements/extras.txt @@ -1,7 +1,7 @@ # note: it is NOT mandatory to register all dependencies of the required packages. # Required packages: -Django>=2.2.10,<3 +Django>=2.2.18,<3 djangorestframework>=3.10.3,<3.13 # Packages dependencies: diff --git a/setup.py b/setup.py index 0e3eb46b..3f2e1de3 100644 --- a/setup.py +++ b/setup.py @@ -35,7 +35,7 @@ def get_version(*file_paths: Sequence[str]) -> str: ] extras_requirements = { - 'django': ['Django>=2.2.10,<3'], + 'django': ['Django>=2.2.18,<3'], 'djangorestframework': ['djangorestframework>=3.10.3,<3.13'], } From e20120dc6fc27b01dbb7f2aefa5762014377bb91 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 24 Mar 2021 11:37:21 +0000 Subject: [PATCH 2/9] build(deps): bump lxml from 4.6.2 to 4.6.3 in /requirements Bumps [lxml](https://github.com/lxml/lxml) from 4.6.2 to 4.6.3. - [Release notes](https://github.com/lxml/lxml/releases) - [Changelog](https://github.com/lxml/lxml/blob/master/CHANGES.txt) - [Commits](https://github.com/lxml/lxml/compare/lxml-4.6.2...lxml-4.6.3) Signed-off-by: dependabot[bot] --- requirements/base.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/base.txt b/requirements/base.txt index e36a92c6..bf613c8f 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -5,7 +5,7 @@ cryptography==3.3.2 defusedxml==0.6.0 jsonschema==3.2.0 -lxml==4.6.2 +lxml==4.6.3 marshmallow==2.19.5 pydantic==1.6.1 pyOpenSSL==18.0.0 From e1eeb6811b525dd550fa63fff32925c51ab939cb Mon Sep 17 00:00:00 2001 From: Yasel Couce Date: Tue, 30 Mar 2021 13:16:39 -0300 Subject: [PATCH 3/9] rtc.data_models_aec: remove match validation for 'fecha_firma_dt' and 'fecha_cesion_dt' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The coincidence between the fields 'fecha_firma_dt' and 'fecha_cesion_dt' in a 'cesion' is not mentioned among the validations that the SII performs to accept an AEC XML Document, in fact, there are known cases of valid AEC XML Documents where these fields do not have the same date, with a slight difference of a few seconds, but still, the AEC is valid for the SII. Ref. Instructivo Técnico Registro Público Electrónico de Transferencia de Crédito Source: (https://github.com/cl-sii-extraoficial/archivos-oficiales/blob/master/src/docs/rtc/README.md#instructivo-t%C3%A9cnico) --- cl_sii/rtc/data_models_aec.py | 7 ++++++- tests/test_rtc_data_models_aec.py | 14 ++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/cl_sii/rtc/data_models_aec.py b/cl_sii/rtc/data_models_aec.py index a5f70612..e5969575 100644 --- a/cl_sii/rtc/data_models_aec.py +++ b/cl_sii/rtc/data_models_aec.py @@ -746,7 +746,12 @@ def validate_last_cesion_matches_some_fields( ) -> Mapping[str, object]: field_validations: Sequence[Tuple[str, str]] = [ # (AecXml field, CesionAecXml field): - ('fecha_firma_dt', 'fecha_cesion_dt'), + # Even though it seems reasonable to expect that the date in `fecha_firma_dt` + # in the AEC is later than the date in `fecha_cesion_dt`, we know of cases of + # AEC approved by the SII in which this is not fulfilled, we observe cases + # where the date in `fecha_firma_dt` was later or even before the date in + # `fecha_cesion_dt` by a difference of up to 6 hours. + # ('fecha_firma_dt', 'fecha_cesion_dt'), ('cedente_rut', 'cedente_rut'), ('cesionario_rut', 'cesionario_rut'), ] diff --git a/tests/test_rtc_data_models_aec.py b/tests/test_rtc_data_models_aec.py index 4066dc15..ea1b257e 100644 --- a/tests/test_rtc_data_models_aec.py +++ b/tests/test_rtc_data_models_aec.py @@ -660,16 +660,10 @@ def test_validate_last_cesion_matches_some_fields(self) -> None: { 'loc': ('__root__',), 'msg': - "'fecha_cesion_dt' of last 'cesion' must match 'fecha_firma_dt':" - " datetime.datetime(" - "2019, 4, 5, 12, 57, 32," - " tzinfo=" - ")" + "'cedente_rut' of last 'cesion' must match 'cedente_rut':" + " Rut('76389992-6')" " !=" - " datetime.datetime(" - "2019, 4, 5, 12, 0, 32," - " tzinfo=" - ").", + " Rut('76598556-0').", 'type': 'value_error', }, ] @@ -677,7 +671,7 @@ def test_validate_last_cesion_matches_some_fields(self) -> None: with self.assertRaises(pydantic.ValidationError) as assert_raises_cm: dataclasses.replace( obj, - fecha_firma_dt=obj.fecha_firma_dt.replace(minute=0), # Original minute is 57. + cedente_rut=obj.cesionario_rut, ) validation_errors = assert_raises_cm.exception.errors() From 4582fb8cd344a58e6d92f242f9ab62b547fbf9e2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 Apr 2021 04:47:49 +0000 Subject: [PATCH 4/9] build(deps): bump virtualenv from 20.0.31 to 20.4.3 Bumps [virtualenv](https://github.com/pypa/virtualenv) from 20.0.31 to 20.4.3. - [Release notes](https://github.com/pypa/virtualenv/releases) - [Changelog](https://github.com/pypa/virtualenv/blob/main/docs/changelog.rst) - [Commits](https://github.com/pypa/virtualenv/compare/20.0.31...20.4.3) Signed-off-by: dependabot[bot] --- requirements/test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/test.txt b/requirements/test.txt index c809ec07..86b15593 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -64,5 +64,5 @@ toml==0.10.1 typed-ast==1.4.2 typing-extensions==3.7.4.3 # urllib3 -virtualenv==20.0.31 +virtualenv==20.4.3 # zipp From fd35f4c356e3b14d1603b0765609bbd794e77c7d Mon Sep 17 00:00:00 2001 From: Yasel Couce Date: Thu, 8 Apr 2021 01:22:02 -0400 Subject: [PATCH 5/9] rtc.data_models_aec: remove validation for the progression of 'monto_cesion' across the 'cesiones' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Although the validation of the progression of the value 'monto_cesion' through the 'cesiones' in an AECXml seems to make a lot of sense, there are known SII-approved AECs where the 'monto_cesion' of a 'cesion' exceeds the value of its predecessor. This validation is not documented among those carried out by the SII at the time of uploading an AEC Ref. Instructivo Técnico Registro Público Electrónico de Transferencia de Crédito Source: (https://github.com/cl-sii-extraoficial/archivos-oficiales/blob/master/src/docs/rtc/README.md#instructivo-t%C3%A9cnico) --- cl_sii/rtc/data_models_aec.py | 33 ++++++++-------- tests/test_rtc_data_models_aec.py | 62 +++++++++++++++---------------- 2 files changed, 49 insertions(+), 46 deletions(-) diff --git a/cl_sii/rtc/data_models_aec.py b/cl_sii/rtc/data_models_aec.py index e5969575..62b6d4a6 100644 --- a/cl_sii/rtc/data_models_aec.py +++ b/cl_sii/rtc/data_models_aec.py @@ -703,21 +703,24 @@ def validate_cesiones_seq_order(cls, v: object) -> object: raise ValueError("items must be ordered according to their 'seq'") return v - @pydantic.validator('cesiones') - def validate_cesiones_monto_cesion_must_not_increase(cls, v: object) -> object: - if isinstance(v, Sequence): - if len(v) >= 2: - previous_cesion: Optional[CesionAecXml] = None - for cesion in v: - if previous_cesion is not None: - if not (cesion.monto_cesion <= previous_cesion.monto_cesion): - raise ValueError( - "items must have a 'monto_cesion'" - " that does not exceed the previous item's 'monto_cesion'.", - ) - previous_cesion = cesion - - return v + # Note: Even though this validation seems to make perfect sense, there are some + # real cases of SII-approved AEC where this is not fulfilled. + # We will keep this validation in case we need it in the future. + # @pydantic.validator('cesiones') + # def validate_cesiones_monto_cesion_must_not_increase(cls, v: object) -> object: + # if isinstance(v, Sequence): + # if len(v) >= 2: + # previous_cesion: Optional[CesionAecXml] = None + # for cesion in v: + # if previous_cesion is not None: + # if not (cesion.monto_cesion <= previous_cesion.monto_cesion): + # raise ValueError( + # "items must have a 'monto_cesion'" + # " that does not exceed the previous item's 'monto_cesion'.", + # ) + # previous_cesion = cesion + + # return v @pydantic.root_validator(skip_on_failure=True) def validate_dte_matches_cesiones_dtes( diff --git a/tests/test_rtc_data_models_aec.py b/tests/test_rtc_data_models_aec.py index ea1b257e..d469371d 100644 --- a/tests/test_rtc_data_models_aec.py +++ b/tests/test_rtc_data_models_aec.py @@ -574,37 +574,37 @@ def test_validate_cesiones_seq_order(self) -> None: for expected_validation_error in expected_validation_errors: self.assertIn(expected_validation_error, validation_errors) - def test_validate_cesiones_monto_cesion_must_not_increase(self) -> None: - self._set_obj_1() - - obj = self.obj_1 - - expected_validation_errors = [ - { - 'loc': ('cesiones',), - 'msg': - "items must have a 'monto_cesion'" - " that does not exceed the previous item's 'monto_cesion'.", - 'type': 'value_error', - }, - ] - - with self.assertRaises(pydantic.ValidationError) as assert_raises_cm: - dataclasses.replace( - obj, - cesiones=[ - dataclasses.replace( - obj.cesiones[0], - monto_cesion=obj.cesiones[1].monto_cesion - 1, - ), - obj.cesiones[1], - ], - ) - - validation_errors = assert_raises_cm.exception.errors() - self.assertEqual(len(validation_errors), len(expected_validation_errors)) - for expected_validation_error in expected_validation_errors: - self.assertIn(expected_validation_error, validation_errors) + # def test_validate_cesiones_monto_cesion_must_not_increase(self) -> None: + # self._set_obj_1() + + # obj = self.obj_1 + + # expected_validation_errors = [ + # { + # 'loc': ('cesiones',), + # 'msg': + # "items must have a 'monto_cesion'" + # " that does not exceed the previous item's 'monto_cesion'.", + # 'type': 'value_error', + # }, + # ] + + # with self.assertRaises(pydantic.ValidationError) as assert_raises_cm: + # dataclasses.replace( + # obj, + # cesiones=[ + # dataclasses.replace( + # obj.cesiones[0], + # monto_cesion=obj.cesiones[1].monto_cesion - 1, + # ), + # obj.cesiones[1], + # ], + # ) + + # validation_errors = assert_raises_cm.exception.errors() + # self.assertEqual(len(validation_errors), len(expected_validation_errors)) + # for expected_validation_error in expected_validation_errors: + # self.assertIn(expected_validation_error, validation_errors) def test_validate_dte_matches_cesiones_dtes(self) -> None: self._set_obj_1() From d46d19054b84cf194f4324c2219fd6321e4774aa Mon Sep 17 00:00:00 2001 From: Yasel Couce Date: Wed, 14 Apr 2021 12:39:05 -0400 Subject: [PATCH 6/9] config: Update Python version used in CI jobs to 3.8.9 --- .circleci/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 826646d8..8674c6e8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -79,7 +79,7 @@ jobs: dist: docker: - - image: docker.io/library/python:3.8.5 + - image: docker.io/library/python:3.8.9 working_directory: ~/repo @@ -119,7 +119,7 @@ jobs: deploy: docker: - - image: docker.io/library/python:3.8.5 + - image: docker.io/library/python:3.8.9 environment: <<: *x-deploy-environment @@ -149,7 +149,7 @@ workflows: parameters: python_version: - "3.7.9" - - "3.8.5" + - "3.8.9" - "3.9.1" - dist: requires: From 3231d4020e127e458be64ba9fef3cb4bc2147018 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 15 Apr 2021 20:55:22 +0000 Subject: [PATCH 7/9] build(deps): bump requests from 2.23.0 to 2.25.1 Bumps [requests](https://github.com/psf/requests) from 2.23.0 to 2.25.1. - [Release notes](https://github.com/psf/requests/releases) - [Changelog](https://github.com/psf/requests/blob/master/HISTORY.md) - [Commits](https://github.com/psf/requests/compare/v2.23.0...v2.25.1) Signed-off-by: dependabot[bot] --- requirements/release.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/release.txt b/requirements/release.txt index a293a4f2..cb9c48fa 100644 --- a/requirements/release.txt +++ b/requirements/release.txt @@ -46,7 +46,7 @@ keyring==21.4.0 pkginfo==1.7.0 # Pygments readme-renderer==25.0 -requests==2.23.0 +requests==2.25.1 requests-toolbelt==0.9.1 # SecretStorage # six From 0ba7c2efbd9fac04d56e80ed234351eeec39d56d Mon Sep 17 00:00:00 2001 From: Yasel Couce Date: Thu, 15 Apr 2021 17:08:07 -0400 Subject: [PATCH 8/9] HISTORY: update for new version --- HISTORY.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index 2c796c37..a848f852 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,6 +3,19 @@ History ------- +0.12.4 (2021-04-15) ++++++++++++++++++++++++ + +* (PR #195, 2021-04-15) build(deps): bump requests from 2.23.0 to 2.25.1 +* (PR #212, 2021-04-14) config: Update Python version used in CI jobs to 3.8.9 +* (PR #210, 2021-04-13) rtc.data_models_aec: remove validation for the progression of + 'monto_cesion' across the 'cesiones' +* (PR #207, 2021-04-08) build(deps): bump virtualenv from 20.0.31 to 20.4.3 +* (PR #208, 2021-04-08) rtc.data_models_aec: remove match validation for 'fecha_firma_dt' and + 'fecha_cesion_dt' +* (PR #205, 2021-03-26) build(deps): bump lxml from 4.6.2 to 4.6.3 +* (PR #204, 2021-03-24) requirements: Upgrade 'Django' + 0.12.3 (2021-02-26) +++++++++++++++++++++++ From 3c5ab2a4546dc1b9ab255dedc07ef6e2d6f8be9a Mon Sep 17 00:00:00 2001 From: Yasel Couce Date: Thu, 15 Apr 2021 17:28:17 -0400 Subject: [PATCH 9/9] =?UTF-8?q?Bump=20version:=200.12.3=20=E2=86=92=200.12?= =?UTF-8?q?.4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bumpversion.cfg | 2 +- cl_sii/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 5132f359..d3fd8445 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.12.3 +current_version = 0.12.4 commit = True tag = True diff --git a/cl_sii/__init__.py b/cl_sii/__init__.py index 0f05af73..eaa49a75 100644 --- a/cl_sii/__init__.py +++ b/cl_sii/__init__.py @@ -5,4 +5,4 @@ """ -__version__ = '0.12.3' +__version__ = '0.12.4'