From 1ea1da49a7fe48f41148e8c1f17418421395fb39 Mon Sep 17 00:00:00 2001 From: capmonster-sdk-bot Date: Thu, 5 Nov 2026 10:17:24 +0000 Subject: [PATCH 1/3] Add optional minScore parameter to RecaptchaV2EnterpriseRequest --- .../requests/RecaptchaV2EnterpiseRequest.py | 18 ++++++++- capmonstercloud_client/version.txt | 2 +- test/recaptchaV2Enterprise_test.py | 37 +++++++++++++++++++ 3 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 test/recaptchaV2Enterprise_test.py diff --git a/capmonstercloud_client/requests/RecaptchaV2EnterpiseRequest.py b/capmonstercloud_client/requests/RecaptchaV2EnterpiseRequest.py index 559b4f2..e707657 100644 --- a/capmonstercloud_client/requests/RecaptchaV2EnterpiseRequest.py +++ b/capmonstercloud_client/requests/RecaptchaV2EnterpiseRequest.py @@ -1,5 +1,5 @@ from typing import Dict, Union, Optional -from pydantic import Field +from pydantic import Field, field_validator from .baseRequestWithProxy import BaseRequestWithProxy @@ -22,6 +22,8 @@ class RecaptchaV2EnterpriseRequest(BaseRequestWithProxy): domain. pageAction: The action name configured for the reCAPTCHA Enterprise challenge on the target website. + minScore: The minimum acceptable score for the token, in the range + 0.1-0.9. recaptchaDataSValue: The one-time token from the widget's "data-s" parameter, if present on the page. userAgent: The User-Agent string of the browser that should be @@ -35,11 +37,21 @@ class RecaptchaV2EnterpriseRequest(BaseRequestWithProxy): enterprisePayload: Optional[str] = Field(default=None, description='Additional parameters passed to the reCAPTCHA Enterprise widget, such as a custom "s" value used by some implementations.') apiDomain: Optional[str] = Field(default=None, description='The domain to load the reCAPTCHA API from, used when the challenge is served from a domain other than the default Google domain.') pageAction: Optional[str] = Field(default=None, description='The action name configured for the reCAPTCHA Enterprise challenge on the target website.') + minScore: Optional[float] = Field(default=None, description='Minimum acceptable score for the token, in the range 0.1-0.9.') recaptchaDataSValue: Optional[str] = Field(default=None, description='The one-time token from the widget\'s "data-s" parameter, if present on the page.') userAgent: Optional[str] = Field(default=None, description='The User-Agent string of the browser that should be emulated while solving the challenge.') cookies: Optional[str] = Field(default=None, description='Cookies to be sent along with the request when solving the challenge.') - def getTaskDict(self) -> Dict[str, Union[str, int]]: + @field_validator('minScore') + @classmethod + def validate_min_score(cls, value): + if value is not None: + if not 0.1 <= value <= 0.9: + raise ValueError(f'Minimum score value should be found in interval 0.1 - 0.9, ' \ + f'current "{value}".') + return value + + def getTaskDict(self) -> Dict[str, Union[str, int, float]]: task = {} task['type'] = self.type task['websiteURL'] = self.websiteUrl @@ -56,6 +68,8 @@ def getTaskDict(self) -> Dict[str, Union[str, int]]: task['apiDomain'] = self.apiDomain if self.pageAction is not None: task['pageAction'] = self.pageAction + if self.minScore is not None: + task['minScore'] = self.minScore if self.recaptchaDataSValue is not None: task['recaptchaDataSValue'] = self.recaptchaDataSValue if self.userAgent is not None: diff --git a/capmonstercloud_client/version.txt b/capmonstercloud_client/version.txt index e91d9be..eda862a 100644 --- a/capmonstercloud_client/version.txt +++ b/capmonstercloud_client/version.txt @@ -1 +1 @@ -4.3.3 +4.3.4 diff --git a/test/recaptchaV2Enterprise_test.py b/test/recaptchaV2Enterprise_test.py new file mode 100644 index 0000000..e3b0d4b --- /dev/null +++ b/test/recaptchaV2Enterprise_test.py @@ -0,0 +1,37 @@ +import unittest + +from pydantic import ValidationError +from capmonstercloudclient.requests import RecaptchaV2EnterpriseRequest + + +class RecaptchaV2EnterpriseRequestTest(unittest.TestCase): + websiteUrlExample = "https://example.com" + websiteKeyExample = "6Le0xVgUAAAAAIt20XEB4rVhYOODgTl00d8juDob" + + def test_min_score_in_task_dict(self): + request = RecaptchaV2EnterpriseRequest( + websiteUrl=self.websiteUrlExample, + websiteKey=self.websiteKeyExample, + minScore=0.7, + ) + self.assertEqual(request.getTaskDict()["minScore"], 0.7) + + def test_min_score_omitted(self): + request = RecaptchaV2EnterpriseRequest( + websiteUrl=self.websiteUrlExample, + websiteKey=self.websiteKeyExample, + ) + self.assertNotIn("minScore", request.getTaskDict()) + + def test_min_score_out_of_range(self): + for value in (0.0, 1.0): + with self.assertRaises(ValidationError): + RecaptchaV2EnterpriseRequest( + websiteUrl=self.websiteUrlExample, + websiteKey=self.websiteKeyExample, + minScore=value, + ) + + +if __name__ == "__main__": + unittest.main() From de5d26fe6d24509d9b3a54141230c3174c3aa389 Mon Sep 17 00:00:00 2001 From: grk717 <48102140+grk717@users.noreply.github.com> Date: Thu, 5 Nov 2026 12:30:32 +0200 Subject: [PATCH 2/3] Update Python versions in workflow configuration Removed Python 3.8 and 3.9 from the workflow matrix. --- .github/workflows/python.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index 46b7f9c..1908040 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] # asyncio isolated unittest work >= 3.8 + python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] # asyncio isolated unittest work >= 3.8 steps: - uses: actions/checkout@v3 From 89c838c9f42418220f4b081cb72559750ac51919 Mon Sep 17 00:00:00 2001 From: "pavel.grinkevich" Date: Thu, 5 Nov 2026 10:43:23 +0000 Subject: [PATCH 3/3] Strip trailing newline from version in User-Agent header --- capmonstercloud_client/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/capmonstercloud_client/utils.py b/capmonstercloud_client/utils.py index 00a98db..700f998 100644 --- a/capmonstercloud_client/utils.py +++ b/capmonstercloud_client/utils.py @@ -17,4 +17,4 @@ def parseVersion(versionFile: str = getDefaultVersionPath(), else: with open(versionFile, 'r') as f: version = f.read() - return version \ No newline at end of file + return version.strip() \ No newline at end of file