Skip to content

Commit

Permalink
Modify Rule S4830: Add aiohttp support (APPSEC-1361) (#3383)
Browse files Browse the repository at this point in the history
## Review

A dedicated reviewer checked the rule description successfully for:

- [ ] logical errors and incorrect information
- [ ] information gaps and missing content
- [ ] text style and tone
- [ ] PR summary and labels follow [the
guidelines](https://github.com/SonarSource/rspec/#to-modify-an-existing-rule)
  • Loading branch information
daniel-teuchert-sonarsource authored Oct 31, 2023
1 parent 1daf5f7 commit 53c90ee
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
39 changes: 39 additions & 0 deletions rules/S4830/python/how-to-fix-it/aiohttp.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
== How to fix it in aiohttp

=== Code examples

include::../../common/fix/code-rationale.adoc[]

:cert_variable_name: verify_ssl
:cert_variable_unsafe_value: False
:cert_variable_safe_value: True

include::../../common/fix/code-rationale-setting.adoc[]

==== Noncompliant code example

[source,python,diff-id=41,diff-type=noncompliant]
----
import aiohttp
async def example():
async with aiohttp.ClientSession() as session:
session.get("https://example.com", verify_ssl=False) # Noncompliant
----

==== Compliant solution

[source,python,diff-id=41,diff-type=compliant]
----
import aiohttp
# By default, certificate validation is enabled
async def example():
async with aiohttp.ClientSession() as session:
session.get("https://example.com")
----

=== How does this work?

include::../../common/fix/validation.adoc[]
2 changes: 2 additions & 0 deletions rules/S4830/python/rule.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ include::how-to-fix-it/requests.adoc[]

include::how-to-fix-it/httpx.adoc[]

include::how-to-fix-it/aiohttp.adoc[]

== Resources

include::../common/resources/standards.adoc[]
Expand Down

0 comments on commit 53c90ee

Please sign in to comment.